Friday, January 29, 2016

Automount with systemd

Standard

Automount with systemd 


Introduction 


As many others I have used autofs for automagically mounting nfs / cifs shares from my clients to my local servers for a while. You can see some of my experiments with this here.

However systemd has now got this as a standard feature with a few small steps. This all reqires nfs server to be configured at your local server before setting this up on your client.

/etc/fstab content 


You need to add you server to your local /etc/fstab 

my.server.com:/server/files /my/files nfs noauto,x-systemd.automount,soft,rsize=16384,wsize=16384,timeo=14,intr 0 0 

You can do this by restarting the system or using sysctl.

$> sudo systemctl daemon-reload 
$> sudo systemctl restart remote-fs.target 
$> sudo systemctl restart local-fs.target 

You need to add you server to your local /etc/fstab

Conclusion 


Your shares should now automount when you cd into the folder. Here that would me /my/files on the client.