OverlayFS Home

I've configured some single use systems (raspberry pis, but also a couple intel boxes) that do one thing and one thing only. I have them set up headless, but sometimes the app they need to run requires X, which doesn't care for read only directories.

Shutting systems down is a pain in the ass, and if the system isn't required to save state, I'd rather mount the thing read only and control power using a hard switch to the power supply.

I've tried setting up the whole system to run with OverlayFS1) but mkinitcpio is less than trivial, and frankly, systemd will do it for my anyway.

Like so:

/etc/systemd/system/overlay.service:

[Unit]
DefaultDependencies=false

[Install]
WantedBy=local-fs-pre.target

[Service]
Type=oneshot
RemainAfterExit=true

# Remount /home and /var as aufs
ExecStart=/bin/mount -t tmpfs tmpfs /var/overlay
ExecStart=/bin/mkdir -p -m0755 /var/overlay/upper /var/overlay/work
ExecStart=/bin/mount -t overlay -o rw,upperdir=/var/overlay/upper,workdir=/var/overlay/work,lowerdir=/home overlay /home

~~LINKBACK~~

1)
replacement for UnionFS and AUFS as of 3.18