Difference between revisions of "Fstab - Use SystemD automount"

m
imported>Handy
imported>Richard
Line 1: Line 1:
=Introduction=
=Introduction=


I found a combination of systemd options (on the ArchWiki [https://wiki.archlinux.org/index.php/Systemd#Automount]) that can be used in the /etc/fstab when mounting storage devices - be they internal external or network shares.  
I found a combination of systemd options (on the ArchWiki [https://wiki.archlinux.org/index.php/Systemd#Automount]) that can be used in the /etc/fstab when mounting storage devices --be they internal, external, or network shares.  


The magic these mount options bring (to me) is that if a network share or an external drive that is being called via /etc/fstab is not present, they save your machine from hanging for a minute or two during the boot process.
The magic (to me) that these mount options bring is that if a network share or an external drive that is being called via /etc/fstab is not present, they save your machine from hanging for a minute or two during the boot process.


A device called this way via /etc/fstab is mounted the first time data is attempted to be accessed from it. Only on this first mount is there any (minor) noticeable delay, when compared to having the device mounted the "old" way.
A device called this way via /etc/fstab is mounted the first time data is attempted to be accessed from it. Only on this first mount is there any (minor) noticeable delay, when compared to having the device mounted the "old" way.


<br clear="all"/>
<br clear="all"/>
==A suitable problem - example==
==A suitable problem example==


I have a ReadyNAS Duo v1. which is connected to my LAN. These days I quite often turn it off as it doesn't need to run perpetually.
I have a ReadyNAS Duo v1, which is connected to my LAN. These days I quite often turn it off as it doesn't need to run perpetually.


A problem that this causes is that if I forget to comment out the NFS share(s) that I'm using from the /etc/fstab file, I have to wait for a minute or two during the boot process whilst the system repetitively tries to make a connection.
A problem that this causes is that if I forget to comment out the NFS share(s) that I'm using from the /etc/fstab file, I have to wait for a minute or two during the boot process whilst the system repetitively tries to make a connection.
Line 16: Line 16:
I attempted to get AutoFS to work for me. I got close but I just wasn't allowed to see the files on the NFS NAS share.
I attempted to get AutoFS to work for me. I got close but I just wasn't allowed to see the files on the NFS NAS share.


So then I looked at the following extremely simple & effective solution. (Wish I had of done this one first, as it would have saved me a couple of hours of a loosing battle!)
So then I found the following extremely simple & effective solution. (Wish I had of done this one first, as it would have saved me a couple of hours of a loosing battle!)


<br clear="all"/>
<br clear="all"/>
==How do you do use it?==
==How do you do use it?==


Add the following to the beginning of the options section in your /etc/fstab the numbers at the end are a time limit for how long it should try to make a connection before giving up & moving on:
Add the following to the beginning of the options section in your /etc/fstab, the numbers at the end are a time limit for how long it should try to make a connection before giving up & moving on:


  noauto,x-systemd.automount,x-systemd.device-timeout=10
  noauto,x-systemd.automount,x-systemd.device-timeout=10
Line 40: Line 40:
  UUID=<id.number> /home noauto,x-systemd.automount,ext4 defaults 0 1
  UUID=<id.number> /home noauto,x-systemd.automount,ext4 defaults 0 1


This will allow services that do not depend on /home to start while /home is checked by fsck, mounting /home when it is first accessed; the kernel will buffer all file access to /home until it is ready.
This will allow services that do not depend on /home to start while /home is checked by fsck. Mounting /home when it is first accessed, the kernel will buffer all file access to /home until it is ready.


<br clear="all"/>
<br clear="all"/>
Anonymous user