What's an easy way to to use a union filesystem (read-only SquashFS + R/W overlay) as /? I'm thinking of using a custom boot script as the kernel init= argument. The script would mount the SquashFS + overlay, then chroot into the mounted filesystem and run the real /sbin/init... however I'm not sure how well this works with systemd init, and I'm wondering if there isn't a simpler option.

  • 2
    Why not do this from an initramfs? Mounting the root filesystem is what they're for. What distribution is your system based on? What bootloader do you use? Jun 16, 2015 at 22:52
  • 1
    Besides chiming in to endorse the above comment, there is this. If at all possible, though, avoid UnionFS/awfs/etc like the plague.
    – mikeserv
    Jun 16, 2015 at 23:26
  • @Gilles: Ubuntu; and I guess I've never understood much about initrd's, but I'm willing to learn
    – Anul
    Jun 17, 2015 at 0:55

1 Answer 1


That configuration is related to a major application category called Live Linux systems. Common implementations include Ubuntu Live CD (with casper) and its derivative, Debian Live (with live-boot). They are using layered filesystems aufs for /, namely tmpfs on squashfs.

user@debian:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
aufs            501M  7.7M  493M   2% /
tmpfs           201M  4.4M  196M   3% /run
/dev/sr0        416M  416M     0 100% /lib/live/mount/medium
/dev/loop0      302M  302M     0 100% /lib/live/mount/rootfs/filesystem.squashfs
tmpfs           501M     0  501M   0% /lib/live/mount/overlay
devtmpfs         10M     0   10M   0% /dev
tmpfs           501M     0  501M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           501M     0  501M   0% /sys/fs/cgroup
tmpfs           501M     0  501M   0% /tmp

user@debian:~$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run type tmpfs (rw,nosuid,relatime,size=204868k,mode=755)
/dev/sr0 on /lib/live/mount/medium type iso9660 (ro,noatime)
/dev/loop0 on /lib/live/mount/rootfs/filesystem.squashfs type squashfs (ro,noatime)
tmpfs on /lib/live/mount/overlay type tmpfs (rw,relatime)
tmpfs on /lib/live/mount/overlay type tmpfs (rw,noatime,mode=755)
aufs on / type aufs (rw,noatime,si=b1cf5f036a329049,noxino)
devtmpfs on /dev type devtmpfs (rw,nosuid,size=10240k,nr_inodes=124332,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw,relatime)

And it seems current Debian jessie based Live CD runs systemd flawlessly.

I recommend you to download a ISO here and try it out on VM host (VirtualBox, KVM, etc.). Debian Live has a relatively sophisticated way to build live images (live-build), so you can easily create your own Live Linux distribution based on Debian Live.

  • ... and use a "Live HDD", so to speak? I suppose that might be interesting. Though I worry about upgradability, esp. upgrading the kernel (which isn't normally done with a live cd)
    – Anul
    Jun 17, 2015 at 0:56
  • @Anul live-build has built-in support for USB-HDD. You can write the image into your HDD using dd and boot off from it much like USB sticks. Regarding upgrading, you will need to replace a squashfs image in huge size, so you might want to apply a binary patch with bsdiff in your upgrading script. Fortunately binary diff of 2 squashfs images tends to fit in reasonably small size because squashfs uses per file / block aligned compression.
    – yaegashi
    Jun 17, 2015 at 2:02
  • I understand the need to periodically "flatten" changes into a (revised) squashfs image to save space. But I'm not sure how easy it is to upgrade e.g. the kernel without doing a "Live HDD" rebuild.
    – Anul
    Jun 17, 2015 at 2:04
  • @Anul I think live systems are not suitable for long term consecutive use in the common manner of Linux distros. With a persist rw partition, you can preserve filesystem changes by package upgrades, but for example kernel upgrades won't work as expected at all. It would be a pain to dodge package script errors and replace vmlinuz/inird in the live partition by hand every time. Live systems rather suit well with embedded applications, which feature a pre-built fixed system and upgrades without any user intervention, much like ChromeOS or Android.
    – yaegashi
    Jun 17, 2015 at 8:17
  • That's exactly what I thought. Which is why I might prefer a unionfs solution with a small "boot distro" (as described in the question)
    – Anul
    Jun 17, 2015 at 11:55

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.