[arch-general] Mounting /var early in systemd

Paul Gideon Dann pdgiddie at gmail.com
Wed Dec 12 06:10:24 EST 2012


On Wednesday 12 Dec 2012 00:40:43 Tom Gundersen wrote:
> Sockets in /var should automatically be ordered After=var.mount, so
> this should in theory just work. How are you mounting /var? I assume
> an fstab entry would not do in your setting, so I guess you somehow
> generate a custom var.mount file? Please link to the code so I could
> have a look.

That's what I hoped too.  I've tried several approaches.  I'm trying a mount 
unit here, because I was hoping there might be a bit more magic to it.  
However, it does mean that I had to hardcode the mount path (%H doesn't seem 
to work), but if I can get this working, I have a oneshot unit that should 
take care of that.

I created a "sockets-pre.target" unit, ordered before "sockets.target", and 
the following unit is ordered before that, because I was hoping that might 
help.  It doesn't, presumably because the socket units and this unit are all 
"before" sockets.target, and all get started at the same time.  If the sockets 
were set "after" sockets-pre.target, this would probably work.  (But in that 
case they might as well be specified directly in the unit, and the sockets-pre 
target can be dropped.)

[Unit]
Description=/var directory for the node
DefaultDependencies=false
Requires=sockets-pre.target
Before=sockets-pre.target

[Mount]
What=192.168.0.1:/srv/nfs/cluster-store/vars/node07
Where=/var
Type=nfs
Options=v3,nolock

[Install]
RequiredBy=local-fs.target

Bootchart is available here:
http://giddie.homeip.net/screenshots/cluster-node-var-mount-boot-chart.png

Thanks,
Paul


More information about the arch-general mailing list