[Unionfs] UnionFS as root filesystem

joerg jungermann joju at math.upb.de
Tue Mar 14 07:02:11 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Moin Francesco Carsana,

> I'd like to use UnionFS as root filesystem in order to merge hda1 (read
> only) and hda2 (read write).
> In this way all the system chages will be saved in hda2, leaving hda1
> unchanged.
> I use an initrd tha contains the following linuxrc:
> 
>  #!/bin/sh
Add: set -x
>  export PATH=.:/:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
>  mount -t proc /proc /proc
>  mkdir -p /mnt
>  mkdir -p /mnt/hda2
>  mount -nt ext3 -o rw /dev/hda2 /mnt/hda2
>  mkdir -p /mnt/hda1
>  mount -nt ext3 -o ro /dev/hda1 /mnt/hda1
>  modprobe unionfs
>  mount -t unionfs -o dirs="/mnt/hda2=rw:/mnt/hda1=ro" unionfs /mnt/hda2
>  umount /proc
>  cd /mnt/hda2
>  mkdir -p initrd
>  pivot_root . initrd
Add: exec chroot . /sbin/init <dev/console >dev/console 2>&1

> 
> At boot I obtain a kernel panic:
> 
>  Kernel panic: VFS: Unable to mount root fs on 03:02
!

> I use grub as boot manager, with this configuration:
> 
>  kernel    /boot/vmlinuz-2.4.27 root=/dev/hda2 ro ramdisk_size=100000 \
>              init=/etc/init lang=us apm=power-off nomce

I expect if you add the "set -x" line, you will see that initrd's
linuxrc is executed.

And the kernel panic is caused, because when linuxrc exits, kernel
mounts new root 03:02 (/dev/hda2) and remounts initrd to /initrd.
There your kernel gets the error.

rename in your RAMDISK /linuxrc to /etc/init and add the "exec chroot
..."-line.

> If I add this line at linuxrc, after pivot root:
> 
>  exec chroot . bin/bash <dev/console >dev/console 2>&1
> 
> I obtain that:
> 
> - The system doesn't crash and UnionFS is correctly mounted as root
> filesystem
> - The init process doesn't start: in this way I can't use the graphical
> environment (KDE)!
This is because linuxrc and its children have to be executed as PID 1.

> My goal is to obtain a system that works in the same way as if I boot
> from
> hda1 only, but that doesn't modify hda1 (the changes are written only on
> hda2).
> Is it possible?
> Can anyone help me to resolve the problem?
> Are there any alternative methods to obtain what I want?
I do it in a similar way to have diskless router from a minicd. I do it
with an Squashfs-Initrd, that firstly unpacks/copies itself to tmpfs
changing root to it, and then mounting cdrom and loop-squashfs-root.
Then i create the unionfs. Lastly pivot_root to union, chroot to it and
exec init.

cya
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEFrDDsta551Pt/1URAtS1AJ47r27WBeLABmHlQF4viCneSoB/YgCeIJ09
PKMdvUEtUgt08tIzk6ZSEY0=
=Facf
-----END PGP SIGNATURE-----



More information about the unionfs mailing list