Context is as in this other question of mine. TL,DR: most of my home folder is on an external drive that I carry along with me and mount at my various workplaces and at home.
Mount is done as unionfs /HomeLocal=RW:/mnt/external_drive/HomeRoaming=RW /home
thanks to the following line in fstab
:
/HomeLocal=RW:/mnt/external_drive/HomeRoaming=RW /home fuse.unionfs auto,suid,exec,nonempty,max_files=32768,allow_other,x-systemd.requires=/mnt/external_drive
(/HomeLocal holds my local config files, and local users' homes.)
This works well but local users cannot use the computer when I'm not there, because unionfs fails when external_drive is not present. So I would like to write a SystemD mount unit to achieve this:
- if external_drive is present, mount it, then unionfs as explained
- if not, simply (bind) mount /HomeLocal on /home
I don't know if SystemD on its own has got what it takes to set up this kind of branching. If not, I guess I can resort to a script called by a mount unit, but then I need advice on how to write a correct unit file to achieve this.