[fedora-virt] Re: febootstrap question

Richard W.M. Jones rjones at redhat.com
Wed Jun 17 21:38:02 UTC 2009

[CC'd to fedora-virt]

On Wed, Jun 17, 2009 at 05:25:26PM -0400, Christopher Johnston wrote:
> I had a question about febootstrap and a specific
> use case of mine at my company where I am implementing a stateless solution
> for our grid.  I wanted to be able to take the initramfs image that is spun
> up out of febootstrap and put a custom linuxrc in there which will
> essentially take the contents of the initramfs and copy them directly into a
> tmpfs filesystem thats mounted as /sysroot then do a pivot_root into it and
> then do a full execution of init.

I'm a bit confused why you'd want to do this, but maybe I'm missing
something.  Why copy the initramfs image into a tmpfs?  The initramfs
is already loaded into kernel memory at boot time and so it has all
the same properties / benefits of tmpfs.

> I have been using nash currently to do
> this and I have ran into a few issue when the system boots up once init
> forks off where it segfaults.  Below is my custom linuxrc:

I would tend to avoid using nash.  If it's possible to add bash to the
image, just use bash.

You might find it helpful to look at what we do in libguestfs, here:


> #!/sbin/nash
> mount -t proc /proc /proc
> echo Mounting proc filesystem
> echo Mounting sysfs filesystem
> mount -t sysfs /sys /sys
> echo Creating /dev
> mount -o mode=0755 -t tmpfs /dev /dev
> mkdir /dev/pts
> mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
> mkdir /dev/shm
> mkdir /dev/mapper
> echo Creating initial device nodes
> mknod /dev/null c 1 3
> mknod /dev/zero c 1 5
> mknod /dev/systty c 4 0
> mknod /dev/tty c 5 0
> mknod /dev/console c 5 1
> mknod /dev/ptmx c 5 2
> mknod /dev/fb c 29 0
> mknod /dev/tty0 c 4 0
> mknod /dev/tty1 c 4 1
> mknod /dev/tty12 c 4 12
> mknod /dev/ttyS0 c 4 64
> mknod /dev/ttyS1 c 4 65
> mknod /dev/ttyS2 c 4 66
> mknod /dev/ttyS3 c 4 67
> /lib/udev/console_init tty0
> mkchardevs
> mkblkdevs
> echo Creating tmpfs filesystem
> mkdir -p /sysroot
> mkrootdev -t tmpfs -o defaults,ro /dev/root
> mount -o mode=0755 -t tmpfs /dev/root /sysroot
> mkdir -p /sysroot/proc
> mkdir -p /sysroot/sys
> mkdir -p /sysroot/.oldroot
> echo Copying rootfs->tmpfs
> cp -a bin /sysroot
> cp -a dev /sysroot
> cp -a etc /sysroot
> cp -a home /sysroot
> cp -a lib /sysroot
> cp -a lib64 /sysroot
> cp -a mnt /sysroot
> cp -a sbin /sysroot
> cp -a tmp /sysroot
> cp -a usr /sysroot
> cp -a var /sysroot
> cp -a root /sysroot
> echo Setting up the new root tmpfs filesystem
> setuproot
> echo Switching from rootfs to tmpfs
> switchroot
> -Chris


Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.

More information about the Fedora-virt mailing list