[uClinux-dev] re-mount root filesystem
Jamie Lokier
jamie at shareable.org
Fri Nov 2 11:53:28 EST 2007
advan wrote:
> I have one embedded device(mips R4000) with Kernel-2.4.25, it boots
> with a root filesystem in JFFS2 format (/dev/mtdblock1), I would like
> to switch the root filesystem to another in a RAMDISK with an ext2
> filesystem, but I can't umount the JFFS2 root filesystem (device is
> busy). I tried to use 'fuser' to check who is using / root filesystem
> , but busybox doesn't support the 'fuser' command. Anyone know how to
> switch root filesystems, any feedback appreciated.
To switch root filesystem, use the pivot_root() system call.
Before pivoting, use chdir() in the the new root directory, and after
pivoting, use chroot() into the root directory, for consistent
behaviour across kernels.
E.g., in C, if your current root is JFFS2, and your new ext2 in
RAMdisk is mounted on /new, then:
chdir("/new");
mkdir("old");
pivot_root(".", "old");
chroot(".");
umount("old");
rmdir("old");
-- Jamie
More information about the uClinux-dev
mailing list