switch_root: zap the last directory for the mount point of new-root

阿保 純一 abo_junghichi at yahoo.co.jp
Fri Aug 2 14:16:33 UTC 2019

> Speaking of, since we are now overmounting the root before zapping the
> initramfs, I wonder if we can remove one check about whether the new root
> is a mount point (this saves code size; mount() would fail with EINVAL in
> that case).
At least, I must check other mount points.
For example, below is the init-script I'm using in initramfs.

mount -t vfat /dev/sda2 /disk
mount -o loop,ro -t squashfs /disk/squash.img /base
mount -o loop -t xfs /disk/xfs.img /vary
mount -o lowerdir=/base,upperdir=/vary/rootfs,workdir=/vary/work \
        -t overlay overlay /root
mount --move /disk /root/initfs/disk
mount --move /base /root/initfs/base
mount --move /vary /root/initfs/vary
my_standalone_switch_root -c /dev/tty1 /root /sbin/init

I think switch_root in busybox is written already so dense, so every it's check-codes treats not only the new-root but also other storages.

More information about the busybox mailing list