Re: live rootfs from squashfs and read write ability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2014-05-29 at 14:39 +0800, Dave Young wrote:
> On 05/23/14 at 01:04am, Vasiliy Tolstov wrote:
> > 2014-05-22 13:59 GMT+04:00 Dave Young <dyoung@xxxxxxxxxx>:
> > >
> > > I don't think there's easy solution for read-write mount since it need stacked fs like
> > > unionfs. But maybe you can try mount some folder as tmpfs such as /tmp, /var etc.
> > > and only write to the specific folders.
> > >
> > > I imagine a simpe implement for unionfs specific for initramfs use..
> > >
> > > Thanks
> > 
> > 
> > I'm try to implement overlayfs mount (backend squashfs, frontend tmpfs).
> > Can you check https://github.com/haraldh/dracut/pull/20.patch or
> > https://github.com/haraldh/dracut/pull/20 and give to me some
> > suggestion, how can i best do this?
> 
> Sorry I'm not familar with livenet I can not comment anything now.
> BTW, overlayfs is not in mainline kernel yet.
> 
> What I would like to see is something like squashinitramfs, a squashed initrd can be
> automatilly recognized and union mounted while kernel booting without any userspace
> hacks. But seems nobody is doing like this.

You can also look at modules.d/90dmsquash-live, which makes a
squashfs-compressed filesystem writeable by using device-mapper to
redirect writes to a different block device (like a loop device backed
by a file on tmpfs).

Note, though, that this requires a filesystem image *inside* squashfs.
The trouble with squashfs is that it's not writeable - it doesn't even
support the "write()" system call. So you can't just tell device-mapper
"send writes over here", because writes aren't allowed.

So instead you put (e.g.) an ext3 filesystem image inside squashfs, and
create an overlay file in tmpfs to use as the write device, and it looks
like this:

squashfs.img -> /rootfs.img -> /dev/loop0 
tmpfs        -> /overlay    -> /dev/loop1
/dev/loop0 + /dev/loop1     -> /dev/mapper/live-rw

See dmsquash-live-root.sh for how it's actually done.

If you just want to try it out, you can do this:

1) make a dracut initramfs that contains the 'dmsquash-live' module
2) make a ext3 image named 'rootfs.img' that contains your real root
3) make a squashfs image that contains '/rootfs.img'
4) put the squashfs image in the initramfs (say at /squashfs.img)
5) boot with 'root=live:/squashfs.img'[1]

It's not super-pretty, but it gets the job done.
(This is how the RHEL/Fedora installer runs, btw.)

Hope that's useful somehow...

-w

[1] You can also do stuff like "root=live:http://.../squashfs.img"; or 
    root=live:LABEL=LIVEDEV (if the image is at /LiveOS/rootfs.img)



--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux