Cute systemd trick of the day: auto-mounting remote shares

Thanks to Lennart for this one.

If you have remote drives - cifs, nfs, whatever - in /etc/fstab with typical options, then you'll probably find that F15 will sit there and wait for the network to come up on boot, then mount them, before boot completes. That's not terrible, but it's not awesome either.

In F14 and earlier, btw, there's a 'netfs' service which controls whether upstart tries to mount remote shares at boot or not. If it's enabled, it tries (and in my experience often fails, by trying to do it before the network's really up, so I just turned it off). F15 doesn't have this.

But the good news - you can make it more awesome. To more or less replicate the 'netfs' functionality, just use the 'noauto' mount option; if you specify 'noauto' as an option for a mount point, systemd won't try and bring up that mount point on boot. You'll only be able to do it manually.

But to make it super awesome, add two options: 'noauto comment=systemd.automount' . Then what happens is the share gets mounted as soon as something tries to access it...but not before. So boot runs as fast as possible, and as soon as you actually try to access the share, it gets mounted. Thanks, systemd!

Comments

NuxRo wrote on 2011-05-13 09:04:
Soo.. systemd will replace automount?
adamw wrote on 2011-05-13 16:04:
replace? i doubt it, just another way to do automounting...what's that, 15 now? :)
[...] Cute systemd trick of the day: auto-mounting remote shares [...]