What I want to do?

I want to configure my /etc/fstab so that my NFS share was:

  • mounted automatically when accessed (auto-mount on-demand),
  • unmounted automatically after specified idle timeout (x-systemd.idle-timeout).

AFAIK, I can achieve this behavior using AutoFS or systemd automount. I prefer systemd because I don't want to install additional packages unless needed.

What's my problem?

This is excerpt from my /etc/fstab (I followed this tutorial): /mnt/someuser_share nfs noauto,x-systemd.automount,x-systemd.device-timeout=30,x-systemd.idle-timeout=1min,_netdev 0 0

Note that in the above line there is:


but it doesn't work. After waiting 1 minute without using /mnt/someuser_share it is still mounted.

Why it doesn't work as expected?

Additional info

Note that after system bootup my share is not mounted as expected. After I type eg. ls /mnt/someuser_share it's mounted (if is online). After next 1 minute I would expect that my share will be unmounted, but it isn't.

I'm using Debian Stretch (9.6), ie. current Debian Stable. systemd version: 232.

As a side note: I'm aware that systemd reads /etc/fstab and creates unit files, specifically automount and mount unit files that can be listed using systemctl command and viewed using systemctl cat name-of-the-unit-file.

Update #1

Removing _netdev mount option from /etc/fstab worked (as suggested by @D'Arcy Nader in the comment below), but I don't understand why it actually helped. _netdev is intended to be used with the remote shares because it forces systemd to consider the mount unit a network mount. So why it breaks things up?

Content of mnt-someuser_share.automount before and after removing _netdev mount option remains the same:

root@someuser:~$ systemctl cat mnt-someuser_share.automount
# /run/systemd/generator/mnt-someuser_share.automount
# Automatically generated by systemd-fstab-generator

Documentation=man:fstab(5) man:systemd-fstab-generator(8)


as opposed to content of mnt-someuser_share.mount which differs. Before removing _netdev:

root@parents-desktop:~$ systemctl cat mnt-someuser_share.mount
# /run/systemd/generator/mnt-someuser_share.mount
# Automatically generated by systemd-fstab-generator

Documentation=man:fstab(5) man:systemd-fstab-generator(8)


After removing _netdev last line changes – instead of:


there is:


Update #2

After experimenting with NFS shares and mount options, I noticed that my /mnt/someuser_share share is automatically mounted immediately after system bootup and it's not unmounted after 1 minute (again), even though I don't have _netdev option in my /etc/fstab. After I removed all the files from /mnt/someuser_share it worked again.

To make things even more confusing, after I made it work again, I appended _netdev option back to /etc/fstab and it still works fine, so there must be some misunderstanding what does it actually mean that the remote share is idle for 1 minute.

  • can you specify both which version of systemd and distribution are you using ? – D'Arcy Nader Dec 28 '18 at 20:25
  • 1
    I updated my post (Debian Stable, ie. Debian Stretch [9.6] + systemd ver. 232). – patryk.beza Dec 28 '18 at 20:42
  • 1
    have you tried without _netdev and using seconds insted of minutes for x-systemd.idle-timeout= ? i would . – D'Arcy Nader Dec 28 '18 at 20:57
  • 1
    Wow! @D'ArcyNader: honestly, I was quite skeptical about your suggestion, but it actually worked! It turned out that after removing _netdev option, my share is automatically unmounted after specified time (I didn't need to replace 1min with 60). Do you know why is that? You can post the answer with the explanation, so that I can accept it. :-) – patryk.beza Dec 29 '18 at 15:11
  • 1
    I turned out that removing _netdev didn't help (I misinterpreted it), but removing the files from the remote share did help. See update in my post. – patryk.beza Dec 29 '18 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.