switch_root working correctly?

Denys Vlasenko vda.linux at googlemail.com
Fri Feb 11 22:28:19 UTC 2011


On Thursday 10 February 2011 17:36, David Henderson wrote:
> Gang,
> 
>     I was checking some mount points and noticed that rootfs is still 
> mounted even after busybox's switch_root is called.  Shouldn't that file 
> system be destroyed after running switch_root?

rootfs can not be destroyed.

util-linux/switch_root.c:

Note that you cannot ever umount rootfs, for approximately the same reason you
can't kill PID 1.  The kernel tracks mount points as a doubly linked list, and
the pointer to the start/end of that list always points to an entry that's
known to be there (rootfs), so it never has to worry about moving that pointer
and it never has to worry about the list being empty.  (Back around 2.6.13
there _was_ a bug that let you umount rootfs, and the system locked hard the
instant you did so endlessly looping to find the end of the mount list and
never stopping.  They fixed it.)

> I'm just not sure if  
> this will cause problems as I now have two root (/) mounts:
> 
> rootfs on / type rootfs (rw,size=1532252k,nr_inodes=216619)
> tmpfs on / type tmpfs (rw,relatime,size=100000k)

Almost everybody has two root mounts:

# cat /proc/mounts | grep ' / '
rootfs / rootfs rw 0 0
/dev/root / ext3 ro,relatime,errors=continue,barrier=0,data=writeback 0 0


-- 
vda


More information about the busybox mailing list