Manjaro Fstab - использование автомонтирования SystemD

Fstab - использование автомонтирования SystemD

From Manjaro
Revision as of 18:34, 14 January 2023 by Krotesk (talk | contribs) (Created page with "Устройство, вызванное таким образом через /etc/fstab, монтируется при первой попытке доступа к данн...")
Other languages:
English • ‎Türkçe • ‎español • ‎français • ‎русский • ‎中文(中国大陆)‎

Введение

Я нашел комбинацию опций systemd (на ArchWiki [1]), которую можно использовать в /etc/fstab при монтировании устройств хранения - будь то внутренние, внешние или сетевые ресурсы.

Магия (для меня) этих опций монтирования заключается в том, что если сетевой ресурс или внешний диск, вызываемый через /etc/fstab, отсутствует - они спасают Вашу машину от зависания на минуту или две во время процесса загрузки.

Устройство, вызванное таким образом через /etc/fstab, монтируется при первой попытке доступа к данным с него. Только при этом первом монтировании возникает (незначительная) заметная задержка по сравнению с монтированием устройства "старым" способом.

Подходящий пример проблемы

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.

I attempted to get AutoFS [2]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 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!)

Как вы его используете?

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.

Ускорьте загрузку

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
Это позволит службам, не зависящим от /home, запускаться, пока /home проверяется fsck. Монтируя /home при первом обращении к нему - ядро будет буферизировать все обращения к файлам в /home до тех пор, пока он не будет готов.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.