[BusyBox] tmpfs with pivot_root / failed umount

imitev at obs.bg imitev at obs.bg
Tue Jan 27 10:54:23 UTC 2004


hello

i'm sorry if the post is off-topic for busybox, but as i'm using busybox for my embedded system, i thought that it would be the right place to ask...

i'm trying to migrate my system's root from ramdisk/ext2 to tmpfs. migrating to ramfs has already been discussed in busybox's list. There is a whole thread about it, with a good conclusion in that post: http://www.busybox.net/lists/busybox/2001-October/004920.html

there are also other posts related to that, plus the tuxscreen pivotroot wiki page

i spent a lot of time trying to make it work, but i couldn't; maybe i'm missing an obious point; i'm doing the following things:

- boot a custom i386 2.4.22 kernel with PXE; boot options are "init=/linuxrc root=/dev/ram0"

- the ramdisk is only a static 1pre5 busybox with a few shell scripts:

/linuxrc is responsible of pivoting the root; (sorry, i don't have the file itself here, so i retype all the commands).


#!/bin/sh
# /linuxrc
# prepare the "new" root
mkdir /tmpfs
mkdir /tmpfs/proc /tmpfs/oldroot
mount -t tmpfs none tmpfs
cp -a /bin /sbin /etc tmpfs/
cd /tmpfs
# pivot_root
pivot_root . /tmpfs/oldroot
exec /sbin/init

until here, everything is successful
then, my /etc/inittab starts /etc/systemrc:

# !/bin/sh
# /etc/systemrc
mount -t proc proc /proc
umount /oldroot
# and lots of other things 


the "umount /oldroot" fails with the "device or resource busy" message. so something is still accessing /oldroot; however, a fuser on it doesn't give anything.
in theory, as far as i understand it, nothing should access /oldroot anymore, as init is started after the pivot root

i tried so many combinations/changes that i can't remember them all; but none of them work:

 - try to umount /oldroot by hand after init has started shells in other ttys
 - instead of execing init, exec a shell, and manually type the commands in it
 - try to use a different shell (i'm using ash), because i thought ash might not release a file descriptor, and thus could keep the /oldroot busy
 - exec init with the chroot blahblah as in "man pivotroot", with or without console redircections.
 - place the "umount /oldroot" at all the possible places in the scripts (damn - if i do that, i really exhausted all my ideas), with or without proc/ mounted
 - use /etc/mtab instead of /proc/mounts (i saw a post from erik saying it could be about that)
 - use suse's /sbin/init instead of busybox init

the only thing i think i didn't try was to use older busybox versions or older/more recent kernels.


after the pivot_root, my mount entries look like:

/dev/root on /oldroot type ext2 (rw)
none on / type tmpfs (rw)
none on /proc type proc (rw) # (it's mounted just to display the mounts as i'm not using mtab)

i also tried "mount -t tmpfs /dev/root /tmpfs", but it seems that "/dev/root" is like a comment. (i can write mount -t tmpfs blahblah and it'll still work)


any help would be greatly appreciated !

thanks, ivan



More information about the busybox mailing list