I could do with some help. I have created two systemd mount files for two nfs shares. However they do not mount during boot (although sometimes one, sometimes both but mostly none). Once booted I can mount them without any problem.
Here are the two systemd mountfiles I use (located in /etc/systemd/system):
arjan@arjanpc:/etc/systemd/system> cat tenhoopen.mount
[Unit]
Description=Mount unit for /tenhoopen
After=network.target
[Mount]
What=192.168.2.6:/volume1/tenhoopen
Where=/tenhoopen
Type=nfs
Options=_netdev,nfsvers=3
[Install]
WantedBy=multi-user.target
and
arjan@arjanpc:/etc/systemd/system> cat MediaNAS.mount
[Unit]
Description=Mount unit for /MediaNAS
After=network.target
[Mount]
What=192.168.2.6:/volume1/Media
Where=/MediaNAS
Type=nfs
Options=_netdev,nfsvers=3
[Install]
WantedBy=multi-user.target
I think these are correct, _netdev is to make sure NFS knows that these are not local and nfsvers=3 is because the NAS I use is an old friend
This is what I get after the system is booted:
arjan@arjanpc:/etc/systemd/system> sudo systemctl status tenhoopen.mount MediaNAS.mount
× tenhoopen.mount - Mount unit for /tenhoopen
Loaded: loaded (/etc/systemd/system/tenhoopen.mount; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2022-07-21 18:03:46 CEST; 31s ago
Where: /tenhoopen
What: 192.168.2.6:/volume1/tenhoopen
jul 21 18:03:45 arjanpc systemd[1]: Mounting Mount unit for /tenhoopen...
jul 21 18:03:45 arjanpc mount[1315]: Created symlink /run/systemd/system/remote-fs.target.wants/rpc-statd.service → /usr/lib/systemd/system/rpc-statd.service.
jul 21 18:03:46 arjanpc mount[1251]: mount.nfs: Network is unreachable
jul 21 18:03:46 arjanpc systemd[1]: tenhoopen.mount: Mount process exited, code=exited, status=32/n/a
jul 21 18:03:46 arjanpc systemd[1]: tenhoopen.mount: Failed with result 'exit-code'.
jul 21 18:03:46 arjanpc systemd[1]: Failed to mount Mount unit for /tenhoopen.
× MediaNAS.mount - Mount unit for /MediaNAS
Loaded: loaded (/etc/systemd/system/MediaNAS.mount; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2022-07-21 18:03:46 CEST; 31s ago
Where: /MediaNAS
What: 192.168.2.6:/volume1/Media
jul 21 18:03:45 arjanpc systemd[1]: Mounting Mount unit for /MediaNAS...
jul 21 18:03:46 arjanpc mount[1249]: mount.nfs: Network is unreachable
jul 21 18:03:46 arjanpc systemd[1]: MediaNAS.mount: Mount process exited, code=exited, status=32/n/a
jul 21 18:03:46 arjanpc systemd[1]: MediaNAS.mount: Failed with result 'exit-code'.
jul 21 18:03:46 arjanpc systemd[1]: Failed to mount Mount unit for /MediaNAS.
Once the system is booted I can mount them without any problems:
[FONT=monospace]arjan@arjanpc:/etc/systemd/system> sudo systemctl start tenhoopen.mount MediaNAS.mount
arjan@arjanpc:/etc/systemd/system> sudo systemctl status tenhoopen.mount MediaNAS.mount
**●** tenhoopen.mount - Mount unit for /tenhoopen
Loaded: loaded (/etc/systemd/system/tenhoopen.mount; enabled; vendor preset: disabled)
Active: **active (mounted)** since Thu 2022-07-21 18:09:40 CEST; 7s ago
Where: /tenhoopen
What: 192.168.2.6:/volume1/tenhoopen
Tasks: 0 (limit: 4915)
CGroup: /system.slice/tenhoopen.mount
jul 21 18:09:39 arjanpc.thuis.net systemd[1]: Mounting Mount unit for /tenhoopen...
jul 21 18:09:40 arjanpc.thuis.net systemd[1]: Mounted Mount unit for /tenhoopen.
**●** MediaNAS.mount - Mount unit for /MediaNAS
Loaded: loaded (/etc/systemd/system/MediaNAS.mount; enabled; vendor preset: disabled)
Active: **active (mounted)** since Thu 2022-07-21 18:09:40 CEST; 7s ago
Where: /MediaNAS
What: 192.168.2.6:/volume1/Media
Tasks: 0 (limit: 4915)
CGroup: /system.slice/MediaNAS.mount
jul 21 18:09:39 arjanpc.thuis.net systemd[1]: Mounting Mount unit for /MediaNAS...
jul 21 18:09:40 arjanpc.thuis.net systemd[1]: Mounted Mount unit for /MediaNAS.
Why are you not simply defining your NFS mounts in /etc/fstab? I know you can create special systemd configurations, but AFAIK, the systemd documentation advises to use /etc/fstab.
There were several reports like yours over time here on the forums. Timing is probably the reason. By making the mounts into automounts this can be avoided. (And when using NetworkManager and the NFS file systems only used during login, this even works for NM connections made during login only).
This is what I published here in other threads and that seemed to help several people:
The noauto and the nofail are for not mounting it on boot (that is not needed, because we mount it on need) and nofail to avoid extra problems when the mounting fails.
You can of cource vary in the value of the x-stystemd.idle-timeout, after that many minutes of not being in use the fs will unmounted.
I am using networkmanager, to my knowledge system connections, although I am not sure about system/user. How do I distinguish?
The whole reason I went to systemd is because I had it in /etc/fstab, but they never got mounted (although after booting mount -a did mount them all as well). Secondly … systemd is the future, fstab is the past (my opinion). However I will have a look at your fstab suggestions.
Mount units may either be configured via unit files, or via /etc/fstab (see fstab(5) for details). Mounts listed in /etc/fstab will be converted into native units dynamically at boot and when the configuration of the system manager is reloaded. In general, configuring mount points through /etc/fstab is the preferred approach. See systemd-fstab-generator(8) for details about the conversion.
Henk … you got me there >:( … “douze points” !! Nevertheless I assume that the systemd guys sooner or later will change that. But stil you got “douze points”.
I carefully looked at your config and notices that you actually use the automounter (x-systemd.automount). For sure then it will work, although it feels like driving a car with an AA-mechanic on the backseat. For now however this seems for me the way to go (need to have it working for my own convenience).
As stubborn as I am … I do it with systemd automount files (also probably not the preferred approach). For those who are intersted I created next to the .mount files .automount files. Example for /tenhoopen (/MediaNAS is very similar), name the file tenhoopen.automount with the following content:
After=network.target orders your mount after NetworkManager was started. But NetworkManager activates connection asynchronously, which means network may still be down long after network.target has been reached. If you need to ensure that network is really up (for some interpretation of “up”) you need to enable NetworkManager-wait-online.service and make your unit
Default timeout is 30 seconds, you can change it in /etc/sysconfig/network/config (NM_ONLINE_TIMEOUT).
Alternative is to mount these filesystems in NetworkManager dispatcher script. openSUSE comes with nfs script that automatically unmounts NFS on network down and mounts again on network up, but this only works for mounts in /etc/fstab.
Sorry @karlmistelberger, buit we are talking about the automounter functionality as originally implemenet using /etc/auto.master and now re-implemented with systemd.automount.
As I read your post, you are talking about the mounts done by a desktop environment of a logged in user. I am afraid that many peeple also call this “automounting”, but that is not about the automounter.
I am aware of systemd.automount. However disabling autofs.service did not prevent the HDDs from being mounted by udisks2.service. Services using the HDDs now exclusively mount and unmount the drives
on their own using /etc/fstab which helps regarding reliability as does disabling SATA.
If the package “autofs” – “A Kernel-Based Automounter” – is installed (usually, due to dependencies) then, that’ll running in parallel to the systemd “Automount unit configuration”.
But this behaviour is NOT the subject of this thread!
This is about a problem with NFS mounts (remark, no real/physical disks, SATA or not, involved at all!). You are going way off-topic, confusing readers of this thread.
A mount is a mount, be it btrfs, cifs, nfs, squashfs, bind or some other fancy thing. Treating them differently creates lots of confusion and unneeded actions. What works best on all my Tumbleweed hosts is /etc/fstab which is readily converted into systemd services. Even many of my USB devices have their own entry. The only action beyond maintaining /etc/fstab is hiding the disks.
Automounting is a great feature be it autofs or udisks2 unless lt gets in the way. Depending on the use case doing everything in a single service can be the preferred option. This USB disk has an entry in /etc/fstab:
This backup service requires the mount, no “automounting” involved:
**erlangen:~ #** systemctl cat backup-home-WD25.service
**# /etc/systemd/system/backup-home-WD25.service**
[Unit]
Description=Backup /home to USB disk
**Requires=WD25.mount
After=WD25.mount **
After=local-fs.target
[Service]
ExecStart=/usr/bin/rsync -a --exclude=.cache --exclude=covid-19-data /home/ /WD25/backup/home/
**erlangen:~ #**
With the external disk being attached, but unmounted starting backup-home-WD25 results in invocation of WD25.mount. backup-home-WD25 waits for the disk being mounted and fails smoothly if the mount fails.
**erlangen:~ #** journalctl -b -u backup-home-WD25
Jul 22 13:23:02 erlangen systemd[1]: Started Backup /home to USB disk.
Jul 22 13:30:19 erlangen systemd[1]: backup-home-WD25.service: Deactivated successfully.
Jul 22 13:30:19 erlangen systemd[1]: backup-home-WD25.service: Consumed 17.428s CPU time.
--------------------------
Jul 22 13:34:49 erlangen systemd[1]: **Dependency failed for Backup /home to USB disk.**
Jul 22 13:34:49 erlangen systemd[1]: **backup-home-WD25.service: Job backup-home-WD25.service/start failed with result 'dependency'.**
**erlangen:~ #**
I tested this without the expected behaviour, e.g. it did not get mounted after boot
To be completely accurate: I moved tenhoopen.automount to tenhoopen.automountSTACK and modified tenhoopen.mount to:
arjan@arjanpc:/etc/systemd/system> cat tenhoopen.mount
[Unit]
Description=Mount unit for /tenhoopen
#After=network.target
Wants=network-online.target
After=network-online.target
[Mount]
What=192.168.2.6:/volume1/tenhoopen
Where=/tenhoopen
Type=nfs
Options=_netdev,nfsvers=3
[Install]
WantedBy=multi-user.target
After reboot it resulted in
arjan@arjanpc:/etc/systemd/system> sudo systemctl status tenhoopen.mount
**×** tenhoopen.mount - Mount unit for /tenhoopen
Loaded: loaded (/etc/systemd/system/tenhoopen.mount; enabled; vendor preset: disabled)
Active: **failed** (Result: exit-code) since Fri 2022-07-22 20:49:30 CEST; 4min 50s ago
Where: /tenhoopen
What: 192.168.2.6:/volume1/tenhoopen
jul 22 20:49:29 arjanpc systemd[1]: Mounting Mount unit for /tenhoopen...
jul 22 20:49:29 arjanpc mount[1270]: mount.nfs: Network is unreachable
jul 22 20:49:30 arjanpc systemd[1]: **tenhoopen.mount: Mount process exited, code=exited, status=32/n/a**
jul 22 20:49:30 arjanpc systemd[1]: **tenhoopen.mount: Failed with result 'exit-code'.**
jul 22 20:49:30 arjanpc systemd[1]: **Failed to mount Mount unit for /tenhoopen.**
Although I have to admit that this is strange since the status of network-onlin. target gives
arjan@arjanpc:/etc/systemd/system> sudo systemctl status network-online.target
**●** network-online.target - Network is Online
Loaded: loaded (/usr/lib/systemd/system/network-online.target; static)
Active: **active** since Fri 2022-07-22 20:49:29 CEST; 7min ago
Docs: man:systemd.special(7)
https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
jul 22 20:49:29 arjanpc systemd[1]: Reached target Network is Online.
Target network-online is active since 20:49:29 and at that time mounting of /tenhoopen starts.
This is what happend at 20:49:29
sudo journalctl --boot | grep 'jul 22 20:49:29'
jul 22 20:49:29 arjanpc systemd[1]: Started Snap Daemon.
jul 22 20:49:29 arjanpc dbus-daemon[779]: [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service' requested by ':1.10' (uid=0 pid=797 comm="/usr/lib/snapd/snapd ")
jul 22 20:49:29 arjanpc systemd[1]: Starting Time & Date Service...
jul 22 20:49:29 arjanpc systemd-udevd[720]: Using default interface naming scheme 'sle15-sp4'.
jul 22 20:49:29 arjanpc systemd[1]: Starting Save/Restore Sound Card State...
jul 22 20:49:29 arjanpc systemd-udevd[720]: vboxnetctl: /usr/lib/udev/rules.d/60-vboxdrv.rules:3 Only network interfaces can be renamed, ignoring NAME="vboxnetctl".
jul 22 20:49:29 arjanpc kernel: ee1004 0-0050: 512 byte EE1004-compliant SPD EEPROM, read-only
jul 22 20:49:29 arjanpc kernel: iTCO_vendor_support: vendor-support=0
jul 22 20:49:29 arjanpc kernel: iTCO_wdt iTCO_wdt: Found a Intel PCH TCO device (Version=4, TCOBASE=0x0400)
jul 22 20:49:29 arjanpc kernel: iTCO_wdt iTCO_wdt: initialized. heartbeat=30 sec (nowayout=0)
jul 22 20:49:29 arjanpc NetworkManager[780]: <info> [1658515769.2888] manager: startup complete
jul 22 20:49:29 arjanpc NetworkManager[780]: <info> [1658515769.2889] device (eth0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
jul 22 20:49:29 arjanpc dbus-daemon[779]: [system] Successfully activated service 'org.freedesktop.timedate1'
jul 22 20:49:29 arjanpc kernel: Generic FE-GE Realtek PHY r8169-0-200:00: attached PHY driver (mii_bus:phy_addr=r8169-0-200:00, irq=MAC)
jul 22 20:49:29 arjanpc avahi-daemon[777]: Server startup complete. Host name is arjanpc.local. Local service cookie is 2285989977.
jul 22 20:49:29 arjanpc kernel: intel_rapl_common: Found RAPL domain package
jul 22 20:49:29 arjanpc kernel: intel_rapl_common: Found RAPL domain core
jul 22 20:49:29 arjanpc kernel: intel_rapl_common: Found RAPL domain dram
jul 22 20:49:29 arjanpc kernel: r8169 0000:02:00.0 eth0: Link is Down
jul 22 20:49:29 arjanpc systemd[1]: Condition check resulted in Manage Sound Card State (restore and store) being skipped.
jul 22 20:49:29 arjanpc systemd[1]: Started MariaDB database server.
jul 22 20:49:29 arjanpc systemd[1]: Finished Network Manager Wait Online.
jul 22 20:49:29 arjanpc systemd[1]: Finished Save/Restore Sound Card State.
jul 22 20:49:29 arjanpc systemd[1]: Started Time & Date Service.
jul 22 20:49:29 arjanpc systemd[1]: Reached target Network is Online.
jul 22 20:49:29 arjanpc systemd[1]: Listening on Load/Save RF Kill Switch Status /dev/rfkill Watch.
jul 22 20:49:29 arjanpc systemd[1]: Mounting Mount unit for /MediaNAS...
jul 22 20:49:29 arjanpc systemd[1]: Mounting Mount unit for /tenhoopen...
jul 22 20:49:29 arjanpc systemd[1]: Starting Login and scanning of iSCSI devices...
jul 22 20:49:29 arjanpc systemd[1]: Starting System Logging Service...
jul 22 20:49:29 arjanpc systemd[1]: Starting Load extra kernel modules for sound stuff...
jul 22 20:49:29 arjanpc systemd[1]: Starting LSB: web-based administration interface for Unix systems...
jul 22 20:49:29 arjanpc iscsiadm[1269]: iscsiadm: No records found
jul 22 20:49:29 arjanpc iscsiadm[1283]: iscsiadm: No records found
jul 22 20:49:29 arjanpc iscsiadm[1285]: iscsiadm: Could not get list of targets from firmware. (err 21)
jul 22 20:49:29 arjanpc systemd[1]: Finished Login and scanning of iSCSI devices.
jul 22 20:49:29 arjanpc systemd[1]: Listening on RPCbind Server Activation Socket.
jul 22 20:49:29 arjanpc systemd[1]: Reached target RPC Port Mapper.
jul 22 20:49:29 arjanpc systemd[1]: Starting Notify NFS peers of a restart...
jul 22 20:49:29 arjanpc systemd[1]: Starting NFS status monitor for NFSv2/3 locking....
jul 22 20:49:29 arjanpc sm-notify[1291]: Version 2.1.1 starting
jul 22 20:49:29 arjanpc sm-notify[1291]: Already notifying clients; Exiting!
jul 22 20:49:29 arjanpc systemd[1]: rpc-statd-notify.service: Deactivated successfully.
jul 22 20:49:29 arjanpc systemd[1]: Started Notify NFS peers of a restart.
jul 22 20:49:29 arjanpc systemd[1]: Condition check resulted in Runtime Directory being skipped.
jul 22 20:49:29 arjanpc systemd[1]: Starting RPC Bind...
jul 22 20:49:29 arjanpc rsyslogd[1284]: imuxsock: Acquired UNIX socket '/run/systemd/journal/syslog' (fd 3) from systemd. [v8.2106.0]
jul 22 20:49:29 arjanpc systemd[1]: Started System Logging Service.
jul 22 20:49:29 arjanpc rsyslogd[1284]: [origin software="rsyslogd" swVersion="8.2106.0" x-pid="1284" x-info="https://www.rsyslog.com"] start
jul 22 20:49:29 arjanpc systemd[1]: Started RPC Bind.
jul 22 20:49:29 arjanpc rpc.statd[1298]: Version 2.1.1 starting
jul 22 20:49:29 arjanpc rpc.statd[1298]: Flags: TI-RPC
jul 22 20:49:29 arjanpc systemd[1]: sound-extra.service: Deactivated successfully.
jul 22 20:49:29 arjanpc systemd[1]: Finished Load extra kernel modules for sound stuff.
jul 22 20:49:29 arjanpc systemd[1]: Reached target Sound Card.
jul 22 20:49:29 arjanpc systemd[1]: Started NFS status monitor for NFSv2/3 locking..
jul 22 20:49:29 arjanpc mount[1299]: Created symlink /run/systemd/system/remote-fs.target.wants/rpc-statd.service → /usr/lib/systemd/system/rpc-statd.service.
jul 22 20:49:29 arjanpc systemd[1]: Reloading.
jul 22 20:49:29 arjanpc smartd[794]: Device: /dev/sdb [SAT], is SMART capable. Adding to "monitor" list.
jul 22 20:49:29 arjanpc smartd[794]: Device: /dev/sdb [SAT], state read from /var/lib/smartmontools/smartd.SAMSUNG_HD103SJ-S246JD1ZB13224.ata.state
jul 22 20:49:29 arjanpc smartd[794]: Device: /dev/sdc, type changed from 'scsi' to 'sat'
jul 22 20:49:29 arjanpc smartd[794]: Device: /dev/sdc [SAT], opened
jul 22 20:49:29 arjanpc smartd[794]: Device: /dev/sdc [SAT], WDC WD20EZRX-00D8PB0, S/N:WD-WMC4M0DJW9LL, WWN:5-0014ee-65a8081b9, FW:80.00A80, 2.00 TB
jul 22 20:49:29 arjanpc smartd[794]: Device: /dev/sdc [SAT], found in smartd database: Western Digital Green
jul 22 20:49:29 arjanpc webmin[1275]: Webmin starting
jul 22 20:49:29 arjanpc smartd[794]: Device: /dev/sdc [SAT], is SMART capable. Adding to "monitor" list.
jul 22 20:49:29 arjanpc smartd[794]: Device: /dev/sdc [SAT], state read from /var/lib/smartmontools/smartd.WDC_WD20EZRX_00D8PB0-WD_WMC4M0DJW9LL.ata.state
jul 22 20:49:29 arjanpc smartd[794]: Monitoring 3 ATA/SATA, 0 SCSI/SAS and 0 NVMe devices
jul 22 20:49:29 arjanpc smartd[794]: Device: /dev/sda [SAT], SMART Usage Attribute: 194 Temperature_Celsius changed from 46 to 50
jul 22 20:49:29 arjanpc systemd-sysv-generator[1322]: SysV service '/etc/init.d/webmin' lacks a native systemd unit file. Automatically generating a unit file for compatibility. Please update package to include a native systemd unit file, in order to make it more safe and robust.
jul 22 20:49:29 arjanpc systemd[1]: /usr/lib/systemd/system/plymouth-start.service:15: Unit configured to use KillMode=none. Support for KillMode=none is deprecated and will be eventually removed in future SLE versions. Please see SUSE TID https://www.suse.com/support/kb/doc/?id=000020394 for more details.
jul 22 20:49:29 arjanpc systemd[1]: /usr/lib/systemd/system/rpc-statd.service:14: PIDFile= references a path below legacy directory /var/run/, updating /var/run/rpc.statd.pid → /run/rpc.statd.pid; please update the unit file accordingly.
jul 22 20:49:29 arjanpc systemd[1]: Configuration file /usr/lib/systemd/system/iscsi.service is marked executable. Please remove executable permission bits. Proceeding anyway.
jul 22 20:49:29 arjanpc systemd[1]: Configuration file /usr/lib/systemd/system/iscsi-init.service is marked executable. Please remove executable permission bits. Proceeding anyway.
jul 22 20:49:29 arjanpc systemd[1]: Configuration file /usr/lib/systemd/system/iscsid.socket is marked executable. Please remove executable permission bits. Proceeding anyway.
jul 22 20:49:29 arjanpc systemd[1]: Configuration file /usr/lib/systemd/system/iscsid.service is marked executable. Please remove executable permission bits. Proceeding anyway.
jul 22 20:49:29 arjanpc systemd[1]: Configuration file /usr/lib/systemd/system/iscsiuio.service is marked executable. Please remove executable permission bits. Proceeding anyway.
jul 22 20:49:29 arjanpc mount[1267]: mount.nfs: Network is unreachable
jul 22 20:49:29 arjanpc systemd[1]: MediaNAS.mount: Mount process exited, code=exited, status=32/n/a
jul 22 20:49:29 arjanpc systemd[1]: MediaNAS.mount: Failed with result 'exit-code'.
jul 22 20:49:29 arjanpc systemd[1]: Failed to mount Mount unit for /MediaNAS.
jul 22 20:49:29 arjanpc systemd[1]: klog.service: Deactivated successfully.
jul 22 20:49:29 arjanpc mount[1270]: mount.nfs: Network is unreachable
jul 22 20:49:29 arjanpc systemd[1]: Stopped Early Kernel Boot Messages.
jul 22 20:49:29 arjanpc systemd[1]: Stopped target Local File Systems.
jul 22 20:49:29 arjanpc systemd[1]: Unmounting /Media2...
NetworkManager completed startup but did not have any connection to activate on boot. Which is why I said “some interpretation of “up””. You need to start with explanation how your network is configured.