Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

OSインストーラーの自作方法

3,601 views

Published on

9月27日に開催されたLINE Developer meetup #45 in Kyotoでの登壇資料です

Published in: Technology
  • Be the first to comment

OSインストーラーの自作方法

  1. 1. LINE DEVELOPER MEETUP #45 IN KYOTO2018-09-27 TOMOHIRO KIMURA @ LINE CORPORATION OS
  2. 2. • Tomohiro Kimura • LINE • IT Service Center – System dept – System Engineering Team • Engineer • LINE • • OS
  3. 3. Agenda • LINE OS • pxeboot • • OS
  4. 4. LINE OS
  5. 5. • LINE 90% • • ( ) • VM / Container • • LINE OS
  6. 6. Hypervisor / VM / Container OS OS
  7. 7. OS LINE OS old new RAID OS pxeboot webui DHCP, TFTP Installer kickstart pkg yum tar other config Profile & Debuggable • RAID • Kickstart yum pkg •
  8. 8. LINE OS Frontend (WebUI,API,DB) Backend (dhcp,tftp,pxe,os image) http pxeboot • Fronend • Hostname,macaddr,ipaddr,RAID ,OS • Backend: dhcp,tftp • pxeboot • • RAID • Partition, FileSystem • OS Image http • • reboot
  9. 9. PXEBOOT
  10. 10. dhcpd.conf PXEBOOT dhcpd.conf host host01 { hardware ethernet 64:5e:be:ab:cd:ef; # host01 Macaddr fixed-address 192.168.123.11; # host01 IPaddr option host-name ”host01"; next-server 192.168.123.10; # tftp IPaddr filename "pxelinux.0”; }
  11. 11. pxelinux.cfg PXEBOOT pxelinux.cfg/c0a87b08 DEFAULT menu.c32 PROMPT 0 TIMEOUT 50 MENU TITLE Support PXE LABEL Installer (ttyS0,115200n8) MENU LABEL Installer CentOS 6.9 x86_64 (ttyS0,115200n8) kernel boot/centos/6/vmlinuz append initrd=boot/centos/6/initrd.img root= rw console=tty1 console=ttyS0,115200n8 • c0a87b08 192.168.123.11 hex • join('', map {sprintf "¥U%02x", $_} split(/¥./, $ip)); • vmlinuz Distribution Kernel • initrd.img initram image • root= rootfs kernel panic
  12. 12. • pxelinux.cfg linux kernel initrd.img tftp • Kernel • Initrd.img • Kernel /sbin/init # see linux/init/main.c • sysvinit upstart /sbin/init • systemd /lib/systemd/systemd • /sbin/init • bash python perl init #!/bin/bash reboot
  13. 13. • Daemon systemd systemd • Systemd /sbin/init systemd service • sysvinit /etc/rc.*/ systemd
  14. 14. • initramfs nfs rootfs / • initramfs • Storage Network kernel module • ( busybox) • /etc (udev, passwd ) • initramfs • • daemon • /sbin/init initramfs
  15. 15. • pure initramfs • initramfs (gz cpio) • /sbin/init • • • initramfs initramfs
  16. 16. INITRAMFS # dracut –c dracut.conf initrd_base.img 2.6.32 # zcat initrd_base.img | cpio –i -c $ cat dracut.conf dracutmodules+="base dash network kernel-modules terminfo nfs udev- rules” add_drivers+="hpsa e1000 igb megaraid_sas"
  17. 17. INITRAMFS # yum -y --installroot=`pwd` install `cat install_rpm_list` # rm –rf `cat neet_not_list` • rpm initramfs • busybox • dracut.conf • man
  18. 18. INITRAMFS # find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initrd.img
  19. 19. • /dev • kernel module • • • daemon • pkg • LINE pkg /SBIN/INIT
  20. 20. RAID RAID # MegaCli64 CfgLdDel -LALL -a0 -NoLog; MegaCli64 -AdpSetProp -EnableJBOD -0 -a0 # MegaCli64 -CfgLdAdd -r0[32:0] CachedBadBBU -a0 -NoLog
  21. 21. Partition # dd if=/dev/zero of=/dev/sda bs=65536 count=1 # /usr/sbin/sgdisk -Z /dev/sda # parted -s /dev/sda mklabel gpt # parted -s /dev/sda unit B mkpart primary ext3 1048576 1074790400 # parted -s /dev/sda set 1 boot on # parted -s /dev/sda unit B mkpart primary linux-swap 1074790912 3222274560 # parted -s /dev/sda unit B mkpart primary xfs 3222275072 100% Number Start End Size File system Name Flags 17.4kB 1049kB 1031kB Free Space 1 1049kB 1075MB 1074MB primary boot 2 1075MB 3222MB 2147MB linux-swap(v1) primary 3 3222MB 479GB 476GB xfs primary
  22. 22. filesystem # mkfs.xfs -b size=1024 -f /dev/sda3 # mount -t xfs /dev/sda3 /mnt/ # mkfs.ext3 -F /dev/sda1 # tune2fs -O +dir_index /dev/sda1 # mount -t ext3 /dev/sda1 /mnt/boot # mkswap -f -c /dev/sda2 # mount -o bind /dev /mnt/dev # mount -t proc none /mnt/proc # mount -o bind /sys /mnt/sys
  23. 23. OS # wget -q -O - http://192.168.123.10/images/centos_6.9_x86_64.tgz | tar -- numeric-owner -xzf - -C /mnt # chroot /mnt /sbin/grub-install /dev/sda # /mnt Network # /mnt hostname # (chef ansible )
  24. 24. reboot # reboot -f
  25. 25. OS
  26. 26. OS # mkdir -p ${BUILDROOT} # yum -y --installroot=${BUILDROOT} install `cat packages/10_base.list` # tar cvzf artifact/centos_6.9.tgz -C ${BUILDROOT} . Packer
  27. 27. • Webui,api • pxeboot pxeboot • initramfs • raid • os yum • os • Distribution
  28. 28. Anaconda
  29. 29. THANK YOU

×