I'm trying to set up a virtual machine running Red Hat EL (actually Scientific Linux, but same difference) where the root file system is protected and not writable. I'd like to accomplish this with a union mount using aufs. That is, a writable file system (on a different virtual HDD) is overlayed on the root file system.

Is there a HOWTO on this anywhere? I have the aufs module installed, and I've been able to mount a union file system, but the trick is to do this for the root file system.

I've seen initramfs scripts help.ubuntu.com/community/aufsRootFileSystemOnUsbFlash written for Debian/Ubuntu-style distributions that do this sort of thing inside the /init script: Before the real root is mounted, the protected root is mounted somewhere as read-only, the overlayed file system is mounted elsewhere as read-write, the union file system is created and mounted, and then the union mount becomes the real root. Hence, the original protected root file system is never mounted as read-write.

I'd like to know how to do this in the nash /init script of Red Hat distributions.

Even more specific questions: What exactly do the nash commands "setuproot" and "switchroot" do? The man page for nash(8) documents switchroot with a single argument, but my /init script calls it without any arguments.

(Motivation: the virtual machine will be subjected to software fault injection; I want to protect the root file system from the effects of a faulty system so that I can quickly reboot the VM into a non-faulty state.)


P.S. Yes, I could just download some LiveCD and see how it's done there, but I thought somebody should have written a HOWTO that my Googling skills have not discovered.


The initrd contains a gzipped cpio dump that's put onto a ramdisk during init. Setuproot loads any necessary modules (contained in the initrd), generally for things like LVM, populates /dev (the initrd contains a limited /dev). Switchroot pivots off the cpio archive to the real root filesystem.

nash is extremely limited. Every binary must be static, scripting is virtually impossible, etc. This may be helpful (build scripts are in his SVN repo).

| improve this answer | |
  • Ok, so basically, LiveCD's and other distributions that need fancy stuff done inside initrd use a more capable shell such as ash or bash. – Posco Grubb Dec 16 '09 at 20:03
  • Busybox is very common as an inclusion just to yank ash, yes. ash and dash are preferred. You can yank this. Check in /livecd-3.0.2/linux-live.sl/initrd and you'll find a linuxrc that does almost exactly what you want. – phresus Dec 16 '09 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.