Created
December 7, 2014 06:38
-
-
Save sunnyone/4950c54d7cf89883ff4d to your computer and use it in GitHub Desktop.
VyOS mount process while booting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initrd内init: scripts/liveをkickする存在 | |
maybe_break mount | |
log_begin_msg "Mounting root file system" | |
. /scripts/${BOOT} | |
parse_numeric ${ROOT} | |
maybe_break mountroot | |
mountroot | |
log_end_msg | |
→${BOOT}は/proc/cmdline(kernelパラメータ)のboot=の値。grub.cfgは以下なのでboot=live. | |
menuentry "VyOS 1.1.0 linux (KVM console)" { | |
linux /boot/1.1.0/vmlinuz boot=live quiet vyatta-union=/boot/1.1.0 console=ttyS0,9600 console=tty0 | |
initrd /boot/1.1.0/initrd.img | |
} | |
/etc/mtab | |
$ cat /etc/mtab | |
overlayfs / overlayfs rw 0 0 | |
tmpfs /lib/init/rw tmpfs rw,nosuid,mode=0755 0 0 | |
proc /proc proc rw,noexec,nosuid,nodev 0 0 | |
sysfs /sys sysfs rw,noexec,nosuid,nodev 0 0 | |
udev /dev tmpfs rw,mode=0755 0 0 | |
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0 | |
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0 | |
/dev/sda1 /live/image ext4 rw,relatime,data=ordered 0 0 | |
/dev/sda1 /live/cow ext4 rw,relatime,data=ordered 0 0 | |
tmpfs /live tmpfs rw,relatime 0 0 | |
tmpfs /tmp tmpfs rw,nosuid,nodev,relatime 0 0 | |
/dev/sda1 /opt/vyatta/etc/config ext4 rw,relatime,data=ordered 0 0 | |
tmpfs /var/run tmpfs rw,nosuid,nodev 0 0 | |
fusectl /sys/fs/fuse/connections fusectl rw 0 0 | |
none /opt/vyatta/config tmpfs rw,nosuid,nodev,mode=775,nr_inodes=0 0 0 | |
/live/image/boot/1.1.0 /boot none rw,bind 0 0 | |
/live/image/boot/grub /boot/grub none rw,bind 0 0 | |
$ cat /proc/mounts | |
rootfs / rootfs rw,size=246316k,nr_inodes=61579 0 0 | |
none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 | |
none /proc proc rw,nosuid,nodev,noexec,relatime 0 0 | |
none /dev devtmpfs rw,relatime,size=246324k,nr_inodes=61581,mode=755 0 0 | |
none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620 0 0 | |
/dev/sda1 /live/image ext4 rw,relatime,data=ordered 0 0 | |
/dev/loop0 /1.1.0.squashfs squashfs ro,noatime 0 0 | |
/dev/sda1 /live-rw-backing ext4 rw,relatime,data=ordered 0 0 | |
/dev/sda1 /live/cow ext4 rw,relatime,data=ordered 0 0 | |
overlayfs / overlayfs rw,relatime,lowerdir=//1.1.0.squashfs,upperdir=/cow 0 0 | |
tmpfs /live tmpfs rw,relatime 0 0 | |
tmpfs /tmp tmpfs rw,nosuid,nodev,relatime 0 0 | |
/dev/sda1 /opt/vyatta/etc/config ext4 rw,relatime,data=ordered 0 0 | |
tmpfs /lib/init/rw tmpfs rw,nosuid,relatime,mode=755 0 0 | |
tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0 | |
tmpfs /var/run tmpfs rw,nosuid,nodev,relatime 0 0 | |
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0 | |
none /opt/vyatta/config tmpfs rw,nosuid,nodev,relatime,nr_inodes=0,mode=775 0 0 | |
/dev/sda1 /boot ext4 rw,relatime,data=ordered 0 0 | |
/dev/sda1 /boot/grub ext4 rw,relatime,data=ordered 0 0 | |
===> は、対応する/proc/mountsの行 | |
https://github.com/vyos/initramfs-tools/blob/573e21e410934f2293d5ac4c738af5f77083b43b/init | |
mountroot #init:L218 | |
https://github.com/vyos/live-initramfs/blob/47cb65a9b94ca48696e8e0255c921167ddcfb49b/scripts/live | |
mountroot #L1605 | |
-> livefs_root=$(find_livefs ${i}) | |
# $i: 0...60 (timeoutカウンタ) | |
-> check_dev "${dev}" # L1546 | |
# $dev: "/dev/sda1" #L1531,L1533,L1544の結果からおそらく | |
-> mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} #L1449 | |
# $fstype: "ext4" #L1445のget_fstypeの結果からおそらく | |
# $devname: "/dev/sda1" #L1423の結果からおそらく | |
# $mountpoint: "/live/image" #L10 | |
===> mount -t ext4 -o ro,noatime /dev/sda1 /live/image (後の/dev/sda1 /live/image ext4 rw,relatime,data=ordered 0 0) | |
# livefs_rootには/live/imageが入る | |
-> mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}" # L1700 | |
-> setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}" # L609 | |
# $directory: $livefs_root | |
# $LIVE_MEDIA_PATH: "live" #L11 | |
-> mount -t "${fstype}" -o ro,noatime "${backdev}" "${croot}/${imagename}" # L1178 | |
# $backdev: backdev=$(get_backing_device "${image}" "-r") #L1161 | |
# $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}") #L569 | |
# $croot: "/" #L1071 | |
# $imagename: imagename=$(basename "${image}") #L1142 | |
===> mount -t squashfs -o ro,noatime /dev/loop0 /1.1.0.squashfs (/dev/loop0 /1.1.0.squashfs squashfs ro,noatime 0 0) | |
-> # cowprobe=$(find_cow_device "${root_persistence}") #L1223 | |
# $root_persistence: "live-rw" #L13 | |
-> find_cow_device #scripts/live-helpers:L333 | |
-> if ! try_mount "${devname}" "${cow_backing}" "rw" | |
# $cow_backing: cow_backing="/${pers_label}-backing" #script/live-helpers:L339 | |
# $pers_label: $root_persistence #script/live-helpers:L338 | |
# つまり、$cow_backingは"/live-rw-backing" | |
# $devname: 探索の結果から/dev/sda1 (のはず) | |
-> mount -o remount,"${opts}" "${dev}" "${old_mountp}" | |
# $opts: "rw" #L291 | |
# $dev: "/dev/sda" #L289 | |
# $old_mountp: "/live/image" | |
===> mount -o remount,rw /dev/sda1 /live/image (後の/dev/sda1 /live/cow ext4 rw,relatime,data=ordered 0 0) | |
-> mount -o bind "${old_mountp}" "${mountp}" #script/live-helpers:L314 | |
# $old_mountp: おそらく"/live/image" #L294 | |
# $mountp: /live-rw-backing | |
===> mount -o bind /live/image /live-rw-backing | |
(/dev/sda1 /live-rw-backing ext4 rw,relatime,data=ordered 0 0) | |
## find_cow_deviceはecho "${pers_fpath}"を返す #script/live-helpers:L389 | |
# $pers_fpath: ${cow_backing}/${PERSISTENT_PATH}/${pers_label} #script/live-helpers:L346 | |
# $PERSISTENT_PATH: "$LIVE_MEDIA_PATH" #L482 | |
# $LIVE_MEDIA_PATH: "${ARGUMENT#vyatta-union=}" #L481 | |
# grubのvyatta-union=は/boot/1.1.0 | |
# すなわち、$pers_fpathは"/live-rw-backing/boot/1.1.0/live-rw" | |
# find_cow_deviceは${cow_backing}/${PERSISTENT_PATH}/${pers_label}である | |
# "/live-rw-backing/boot/1.1.0/live-rw" を返している | |
-> mount -o bind ${cowdevice} /cow #L1297 | |
===> mount -o bind /live-rw-backing/boot/1.1.0/live-rw /cow (後の/dev/sda1 /live/cow ext4 rw,relatime,data=ordered 0 0) | |
# $cowdevice: ${cowprobe} #L1249 | |
-> mount -t ${UNIONTYPE} -o noatime,lowerdir=${rofsstring},upperdir=/cow overlayfs "${rootmnt}" #L1345 | |
# $UNIONTYPE: "overlayfs" #/etc/live.conf | |
# $rofsstring: "${croot}/${imagename}${roopt}:${rofsstring}" #L1178 | |
# $croot: "/" #L1071 | |
# $imagename: imagename=$(basename "${image}") #L1142 | |
# $roopt: "" #L1087 | |
# $rofsstring: "" #L1074 | |
# rofsstring=${rofsstring%:} #L1183 | |
# $rootmnt: "/root" #L62, #init:L51 | |
==> mount -t overlayfs -o noatime,lowerdir=//1.1.0.squashfs,upperdir=/cow overlayfs /root | |
(overlayfs / overlayfs rw,relatime,lowerdir=//1.1.0.squashfs,upperdir=/cow 0 0) | |
-> mount -t tmpfs tmpfs ${rootmnt}/live #L1364 | |
==> mount -t tmpfs tmpfs /root/live (tmpfs /live tmpfs rw,relatime 0 0) | |
-> mount -o move /cow "${rootmnt}/live/cow" #L1411 | |
==> mount -o move /cow /root/live/cow (/dev/sda1 /live/cow ext4 rw,relatime,data=ordered 0 0) | |
run_scripts /scripts/live-bottom #L1708 | |
-> live-bottom/05mountpoints https://github.com/vyos/live-initramfs/blob/47cb65a9b94ca48696e8e0255c921167ddcfb49b/scripts/live-bottom/05mountpoints | |
-> mount --move /live/image /root/live/image #scripts/live-bottom/05mountpoints:L33 | |
===> mount --move /live/image /root/live/image (/dev/sda1 /live/image ext4 rw,relatime,data=ordered 0 0) | |
-> live-bottom/50vyatta | |
https://github.com/vyos/build-iso/blob/4ddda254c76d2bfb807ed7c2c5ea992037638bf7/livecd/config.vyatta/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/50vyatta | |
-> mount -o bind /root/live/cow/config /root/opt/vyatta/etc/config #L51 | |
===> mount -o bind /root/live/cow/config /root/opt/vyatta/etc/config (/dev/sda1 /opt/vyatta/etc/config ext4 rw,relatime,data=ordered 0 0) | |
init起動 | |
exec run-init ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console #L303 | |
check_とかprobe_とかでマウントしてそのまま使うのが気持ち悪いけど、2度マウントする無駄は避けたいか… | |
/etc/init.d/mountall.sh | |
``` | |
tmpfs /var/run tmpfs nosuid,nodev 0 0 | |
overlayfs / overlayfs rw 0 0 | |
tmpfs /tmp tmpfs nosuid,nodev 0 0 | |
``` | |
/etc/init.d/vyatta-router | |
https://github.com/vyos/vyatta-cfg/blob/84c14e0983b3c2b9659af2e701b606e43306ccb2/etc/init.d/vyatta-router | |
-> start #L159 | |
-> mount -o $tmpfs_opts -t tmpfs none ${vyatta_configdir} #L169 | |
# $tmpfs_opts: nosuid,nodev,mode=775,nr_inodes=0 #L168 | |
# $vyatta_configdir: "/opt/vyatta/config" # /etc/default/vyattaより | |
===> mount -o nosuid,nodev,mode=775,nr_inodes=0 -t tmpfs none /opt/vyatta/config (none /opt/vyatta/config tmpfs rw,nosuid,nodev,relatime,nr_inodes=0,mode=775 0 0) | |
-> mount_slashconfig #L175 | |
-> mount --bind /opt/vyatta/etc/config /config #L154 | |
===> /proc/mountsにはなし。このbind mountはlive環境でもそうでないときでも/configが存在するようにという配慮らしい(L139) | |
-> bind_mount_boot #L193 #ツール類が正しく操作できるようにという配慮(L112) | |
-> mount --bind /live/image/boot/$image_name /boot #L123 | |
===> mount --bind /live/image/boot/1.1.0 /boot (/dev/sda1 /boot ext4 rw,relatime,data=ordered 0 0) | |
-> mount --bind /live/image/boot/grub /boot/grub #L130 | |
===> mount --bind /live/image/boot/grub /boot/grub (/dev/sda1 /boot/grub ext4 rw,relatime,data=ordered 0 0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment