sudo mksquashfs /usr /usr_squash/usr.sfs -b 65536 -comp xz
I add to fstab:
/usr_squash/usr.sfs /usr_squash/sq squashfs loop,ro 0 0 overlay /usr overlay defaults,lowerdir=/usr_squash/sq,upperdir=/usr_squash/upd,workdir=/usr_squash/tmp 0 0
Of course, mount points sq, upd and tmp are created, too.
With default kernel, I have the following error:
failed: No such device which is, obviously, because overlayfs is a kernel [M]odule, not a [*].
With a custom kernel, overlayfs starts but produces the following error:
overlayfs: failed to resolve '/usr_squash/upd': -2 mount: mounting overlay on /root/usr failed: No such file or directory overlayfs: upper fs is r/o, try multi-lower layers mount
Setting the directory relative to Initial Ramdrive root, not the main root (
upperdir=/root/usr_squash/upd instead of
upperdir=/usr_squash/upd) does not help. And even if, I can't rebuild a custom kernel on every update.
So, what's the best way to mount compressed /usr? I don't want to break the auto-update, and I don't want auto-update break my system. Should I write a custom hook and run
update-initramfs -u -k all? But how?