41

mount -a works fine as a one-time action. But auto-mount of removable media reverts to settings that were in fstab at the last reboot.

How to make the OS reload /etc/fstab so auto-mounts use the new settings when media is connected?

The specific example seen with Raspbian (Debian) Stretch:

  • FAT-formatted SD card; configured fstab to auto-mount; rebooted; volume auto-mounts, but read-only.

  • Changed umask options in /etc/fstab; mount -a while media is connected, and volume is now read-write.

  • Unmount and re-insert the media; auto-mount works, but using the options in /etc/fstab from the last reboot, so volume is read-only.

  • Reboot; OS loads updated /etc/fstab; auto-mount works when media is connected, and volume is read-write. How to get this effect without a reboot?

FWIW, the (updated) /etc/fstab syntax was:

/dev/sdb1   /Volumes/boot   vfat    rw,user,exec,nofail,umask=0000  0   0
Kusalananda
  • 333,661
RichardH
  • 513

3 Answers3

33

I suspect this is caused by systemd’s conversion of /etc/fstab; traditional mount doesn’t remember the contents of /etc/fstab.

To refresh systemd’s view of the world, including changes to /etc/fstab, run

systemctl daemon-reload
Stephen Kitt
  • 434,908
  • Sigh. An auto-generated comment in the top of /etc/fstab reminding/advising people it has now been deprecated - and how to update systemd - would go a long way. – Chris Davies Oct 25 '18 at 20:14
  • 2
    Thanks! You can imagine Google returned nothing but 'mount -a' hits for this query. Are there any unwanted side-effects when doing this on-the-fly re-gen of the tables? Doesn't seem to be. – RichardH Oct 25 '18 at 21:45
  • For more, see https://unix.stackexchange.com/a/236968/5132 and https://unix.stackexchange.com/questions/90723/ . Note that the Debian service that used to run mount -a is nowadays masked. – JdeBP Oct 26 '18 at 00:03
24

To elaborate the answer from @Stephen Kitt: for example I have this entry in /etc/fstab:

vnetsvr-home:/etc/skel   /etc/skel    nfs4   sec=krb5p,noauto,x-systemd.automount,x-systemd.idle-timeout=10min   0   0

and only doing sudo systemctl daemon-reload doesn't reloaded the fstab. I have to do:

sudo systemctl daemon-reload
sudo systemctl restart remote-fs.target

To reload an entry to mount a local filesystem, you should use:

sudo systemctl daemon-reload
sudo systemctl restart local-fs.target
Ingo
  • 626
0

I know that these solutions might not work in every linux distro and version. However this method would generally works for all Linux versions.
1- Do your configuration and change the fstab file
2- Use this command to remount the device_file you have changed its configuration in the fstab file:
# mount -o remount [device_file]
This way you will mount the partition with its new configuration read from "fstab" file.
If you removed a partition from "fstab" file, simply umount [device_file]. Be sure, the partition stays unmounted after the reboot.

Any time you can check the result by running mount command.