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!

4 Responses

  1. NuxRo
    NuxRo May 13, 2011 at 1:04 am | | Reply

    Soo.. systemd will replace automount?

  2. Links 13/5/2011: Lubuntu 11.04 in Focus | Techrights

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

Leave a Reply to adamw Cancel reply

Your email address will not be published. Required fields are marked *