SlideShare a Scribd company logo
LINE DEVELOPER MEETUP #45 IN KYOTO2018-09-27
TOMOHIRO KIMURA @ LINE CORPORATION
OS
• Tomohiro Kimura
• LINE
• IT Service Center – System dept – System Engineering Team
• Engineer
• LINE
•
• OS
Agenda • LINE OS
• pxeboot
•
• OS
LINE OS
• LINE 90%
•
• ( )
• VM / Container
•
•
LINE OS
Hypervisor / VM / Container OS
OS
OS
LINE OS
old new
RAID OS
pxeboot webui
DHCP, TFTP
Installer kickstart
pkg yum tar
other config Profile &
Debuggable
• RAID
• Kickstart yum pkg
•
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
PXEBOOT
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”;
}
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
OSインストーラーの自作方法
• 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
• Daemon systemd systemd
• Systemd /sbin/init systemd service
• sysvinit /etc/rc.*/
systemd
• initramfs nfs rootfs /
• initramfs
• Storage Network kernel module
• ( busybox)
• /etc (udev, passwd )
• initramfs
•
• daemon
• /sbin/init
initramfs
• pure initramfs
• initramfs (gz cpio)
• /sbin/init
•
•
• initramfs
initramfs
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"
INITRAMFS
# yum -y --installroot=`pwd` install `cat install_rpm_list`
# rm –rf `cat neet_not_list`
• rpm initramfs
• busybox
• dracut.conf
• man
INITRAMFS
# find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initrd.img
• /dev
• kernel module
•
•
• daemon
• pkg
• LINE pkg
/SBIN/INIT
RAID
RAID
# MegaCli64 CfgLdDel -LALL -a0 -NoLog; MegaCli64 -AdpSetProp -EnableJBOD -0 -a0
# MegaCli64 -CfgLdAdd -r0[32:0] CachedBadBBU -a0 -NoLog
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
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
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 )
reboot
# reboot -f
OS
OS
# mkdir -p ${BUILDROOT}
# yum -y --installroot=${BUILDROOT} install `cat packages/10_base.list`
# tar cvzf artifact/centos_6.9.tgz -C ${BUILDROOT} .
Packer
OSインストーラーの自作方法
• Webui,api
• pxeboot pxeboot
• initramfs
• raid
• os yum
• os
• Distribution
Anaconda
THANK YOU

More Related Content

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

  • 1. LINE DEVELOPER MEETUP #45 IN KYOTO2018-09-27 TOMOHIRO KIMURA @ LINE CORPORATION OS
  • 2. • Tomohiro Kimura • LINE • IT Service Center – System dept – System Engineering Team • Engineer • LINE • • OS
  • 3. Agenda • LINE OS • pxeboot • • OS
  • 5. • LINE 90% • • ( ) • VM / Container • • LINE OS
  • 6. Hypervisor / VM / Container OS OS
  • 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. 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
  • 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. 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
  • 13. • 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
  • 14. • Daemon systemd systemd • Systemd /sbin/init systemd service • sysvinit /etc/rc.*/ systemd
  • 15. • initramfs nfs rootfs / • initramfs • Storage Network kernel module • ( busybox) • /etc (udev, passwd ) • initramfs • • daemon • /sbin/init initramfs
  • 16. • pure initramfs • initramfs (gz cpio) • /sbin/init • • • initramfs initramfs
  • 17. 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"
  • 18. INITRAMFS # yum -y --installroot=`pwd` install `cat install_rpm_list` # rm –rf `cat neet_not_list` • rpm initramfs • busybox • dracut.conf • man
  • 19. INITRAMFS # find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initrd.img
  • 20. • /dev • kernel module • • • daemon • pkg • LINE pkg /SBIN/INIT
  • 21. RAID RAID # MegaCli64 CfgLdDel -LALL -a0 -NoLog; MegaCli64 -AdpSetProp -EnableJBOD -0 -a0 # MegaCli64 -CfgLdAdd -r0[32:0] CachedBadBBU -a0 -NoLog
  • 22. 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
  • 23. 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
  • 24. 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 )
  • 26. OS
  • 27. OS # mkdir -p ${BUILDROOT} # yum -y --installroot=${BUILDROOT} install `cat packages/10_base.list` # tar cvzf artifact/centos_6.9.tgz -C ${BUILDROOT} . Packer
  • 29. • Webui,api • pxeboot pxeboot • initramfs • raid • os yum • os • Distribution