It doesn't really overlay `/`
The script doesn't really work / overlay the actual root:
(deck@ysd ~)$ tmp/Qbert/qbert.sh -S pv
[sudo] password for deck:
@#?%&#*!
(Overlay is mounted!)
....
warning: warning given when extracting /usr/bin/pv (Can't create '/usr/bin/pv')
...
touch: setting times of '/usr': Read-only file system
error: command failed to execute correctly
(deck@ysd ~)$ touch /usr/aaa
touch: cannot touch '/usr/aaa': Read-only file system
The script mounts the overlayed root fs into ~/.qbert/merged but doesn't really overlay/change the fs root (/). So you can access and change everything under ~/.qbert/merged, but / is still read-only.
(A+)(root@ysd ~)# mount | grep overlay
overlay on /etc type overlay (rw,relatime,lowerdir=/sysroot/etc,upperdir=/sysroot/var/lib/overlays/etc/upper,workdir=/sysroot/var/lib/overlays/etc/work)
overlay on /home/deck/.qbert/merged type overlay (rw,relatime,lowerdir=/,upperdir=/home/deck/.qbert/upperdir,workdir=/home/deck/.qbert/work)
(A+)(root@ysd ~)# ls /usr
bin lib lib32 lib64 libexec local sbin share src
(A+)(root@ysd ~)# ls /home/deck/.qbert/merged/usr/
bin lib lib32 lib64 libexec local sbin share src
(A+)(root@ysd ~)# touch /usr/aaaa
touch: cannot touch '/usr/aaaa': Read-only file system
(1)(A+)(root@ysd ~)# touch /home/deck/.qbert/merged/usr/aaaa
(A+)(root@ysd ~)# ls /home/deck/.qbert/merged/usr
aaaa bin lib lib32 lib64 libexec local sbin share src
(A+)(root@ysd ~)# ls /usr
bin lib lib32 lib64 libexec local sbin share src
You would need to mount the overlay over / itself... however there are some complications with that, becaues you need to mount it before the other mounts, especially /proc , /sys etc..
The easiest way to do that is from an initrd, before the normal init system starts mounting everything else, but with simple init systems it should be possible to change it also there directly. (I have done this only on custom ebedded systems or a system with a custom initrd, but haven't looked into what support for this "normal" distros have. Systemd has a systemd.volatile=overlay option, but that puts the overlay data on a temporary in-memory filesystem, which will get lost on reboot).
Alternatively for your use case (allowing pacman installs) you could just create an overlay for just /usr, the same way steamos already has one configured for /etc, just check out /usr/lib/systemd/system/etc.mount, but basically (not tested ;):
-
create
/etc/systemd/system/usr.mountwith[Unit] Description=usr overlay [Mount] Where=/usr What=overlay Type=overlay Options=lowerdir=/usr,upperdir=/var/lib/overlays/usr/upper,workdir=/var/lib/overlays/usr/work [Install] WantedBy=local-fs.target -
run (it should be actually possible to do the mkdir automatically as a dependent systemd service or something ;)
mkdir -p /var/lib/overlays/usr/{upper,work} systemctl enable usr.mount -
reboot. Alternatively you could just start
systemctl start usr.mountto start it using right away, but already running apps would keep open files from the originalusrwhich might cause some confusion (for a similar reason, it will be hard to disable it again without a restart)
Yes, I noticed that the stuff is still installed into the real fs, I am troubleshooting it. Thanks for your analysis very detailed and precious!
Anything new on that?