Overlayfs cannot handle zram


I have moved from aufs to overlay filesystem (it used to be named overlayfs, but they changed the name to just overlay, which is a very strange decision).

The documentation for overlay states that direct writes to the lower layers is forbidden, so that rules it out for Puppy Linux.

However, usage in Quirky does not require writes to lower layers, so overlay looks good.

Except that I have just run into a brick wall. I have discovered that overlay cannot handle the upper rw layer being a zram.

A zram is used for the live-CD. I thought that I had done everything correctly, however the 'init' script in the initramfs was failing, the kernel crashing.

I setup an experiment. Created folders just like in the initramfs: q_ro/q_sfs, q_rw, tempwork, q_new.

Using the same busybox from the initramfs, this works:
# ./busybox mount -t overlay -o lowerdir=./q_ro/q_sfs,upperdir=./q_rw,workdir=./tempwork overlay ./q_new

Then, mounting a squashfs file on the ro layer:
# ./busybox umount ./q_new
# ./busybox mount -t squashfs ./q_ro/q.sfs ./q_ro/q_sfs
# ./busybox mount -t overlay -o lowerdir=./q_ro/q_sfs,upperdir=./q_rw,workdir=./tempwork overlay ./q_new


Success again. Now create a zram:
# ./busybox umount ./q_new
# ALLOCK=1000
# USEK=500
# echo "${ALLOCK}K" > /sys/block/zram0/disksize
# echo "${USEK}K" > /sys/block/zram0/mem_limit
# mkfs.ext2 -m 0 -L qrw /dev/zram0
# mount -t ext2 /dev/zram0 ./q_rw


And try again:
# busybox mount -t overlay -o lowerdir=./q_ro/q_sfs,upperdir=./q_rw,workdir=./tempwork overlay ./q_new
mount: mounting overlay on ./q_new failed: Invalid argument


Have I misunderstood something here? Do I have to go back to aufs?


Comments:

Overlay multiple ro folders   Posted on 12 Jan 2017, 10:47 by admin
For those who are interested in overlay, it can handle more than one ro layer. For example:

# busybox mount -t overlay -o lowerdir=./q_ro/q_sfs:/q_ro/q_sfs2:/q_ro/q_sfs3,upperdir=./q_rw/rw,workdir=./q_rw/tempwork overlay ./q_new

Just put colon separators, for as many ro layers as desired. The right-most one is at the bottom.

There can only be one rw layer.

In Puppy Linux, there is a mode of operation in which files can be flushed from the rw layer down to a lower layer. Overlay cannot do this.
However, this restriction does mean that overlay is simpler and faster.


Overlay can handle zram   Posted on 12 Jan 2017, 8:09 by admin
Got it!

The problem is that 'tempwork' folder. It has to be in the same filesystem as the rw layer. So:

# mkdir ./q_rw/tempwork
# mkdir ./q_rw/rw
# busybox mount -t overlay -o lowerdir=./q_ro/q_sfs,upperdir=./q_rw/rw,workdir=./q_rw/tempwork overlay ./q_new


...success!


Overlay cannot handle tmpfs   Posted on 12 Jan 2017, 7:59 by admin
Overlay cannot handle a tmpfs on the upperdir rw layer either.