Fstab - Utilisation du montage automatique SystemD

Revision as of 01:43, 5 February 2022 by Senkuu (talk | contribs) (Created page with "C'est alors que j'ai trouvé la solution suivante, extrêmement simple et efficace. (J'aurais aimé utiliser cette solution en premier, car elle m'aurait épargné quelques he...")
Other languages:
English • ‎Türkçe • ‎español • ‎français • ‎русский • ‎中文(中国大陆)‎

Introduction

J'ai trouvé une combinaison d'options systemd (sur l'ArchWiki [1]) qui peuvent être utilisées dans le /etc/fstab lors du montage de périphériques de stockage -- qu'ils soient internes, externes ou partagés sur le réseau.

La magie (pour moi) que ces options de montage apportent est que si un partage réseau ou un disque externe qui est appelé via /etc/fstab n'est pas présent, elles évitent à votre machine d'être suspendue pendant une minute ou deux pendant le processus de démarrage.

Un périphérique appelé de cette façon via /etc/fstab est monté la première fois que l'on tente d'accéder à ses données. Ce n'est que lors de ce premier montage qu'un retard (mineur) est perceptible, par rapport au montage du périphérique selon l'"ancienne" méthode.

Un exemple de problème approprié

Je possède un ReadyNAS Duo v1, qui est connecté à mon réseau local. Ces jours-ci, je l'éteins assez souvent car il n'a pas besoin de fonctionner en permanence.

Si j'oublie de commenter le(s) partage(s) NFS que j'utilise dans le fichier /etc/fstab, je dois attendre une minute ou deux pendant le processus de démarrage pendant que le système essaie de manière répétitive d'établir une connexion.

J'ai essayé de faire fonctionner AutoFS [2]. Je m'en suis approché mais je n'ai pas été autorisé à voir les fichiers sur le partage NAS NFS.

C'est alors que j'ai trouvé la solution suivante, extrêmement simple et efficace. (J'aurais aimé utiliser cette solution en premier, car elle m'aurait épargné quelques heures d'une bataille perdue d'avance !)

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:
/etc/fstab
noauto,x-systemd.automount,x-systemd.device-timeout=10


After I added the above to the following line in my fstab:

/etc/fstab
192.168.1.15:/media-2 /mnt/NAS-media-2 nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,hard,intr,noatime 0 0


I could boot Manjaro whilst the ReadyNAS' Cat-6 network cable was unplugged, & there was NO noticeable delay. After the system was booted, I plugged the cable in & then called the NFS share /media-2 in Worker & it read the drive & listed the contents.

After that I unplugged the drive, which had Worker (my file manager of choice) looking for it as I hadn't changed out of the the media-2 directory. When I plugged the cable back in, it took ~10 seconds or so & then Worker automatically re-listed the contents or this very large partition that has well over 2000 directories, each holding multiple files.

Speed up your boot

If you have a very large /home & the boot process is held up when a scheduled fsck takes place (really not a big problem if you are using ext4), you can add the x-systemd.automount section to the options section of the line in your fstab for /home like so:
/etc/fstab
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.