I’ve created a shared folder like the following:
server ❯ sudo cat /etc/fstab
/run/media/user/X /srv/nfs/X none bind 0 0
server ❯ sudo mount -a
client ❯ sudo mkdir -p /data/nfs/X
client ❯ sudo cat /etc/systemd/system/data-nfs-X.mount
[Unit]
Description=Shared partition X
After=network.target
[Mount]
What=192.168.1.122:/nfs/X
Where=/data/nfs/X
Type=nfs
Options=_netdev,auto
[Install]
WantedBy=multi-user.target
client ❯ sudo systemctl enable data-nfs-X.mount
client ❯ sudo cat /etc/systemd/system/data-nfs-X.automount
[Unit]
Description=Automount shared partition X
ConditionPathExists=/data/nfs/X
[Automount]
Where=/data/nfs/X
TimeoutIdleSec=10
[Install]
WantedBy=multi-user.target
client ❯ sudo systemctl enable --now data-nfs-X.automount
client ❯ ls /data/nfs/X
ls: no se puede abrir el directorio '/data/nfs/X': No existe el dispositivo
client ❯ sudo mount -t nfs 192.168.1.122:/X /data/nfs/X
Why can I mount the folder manually but I can’t do it with systemd units?
Hi @Individual-Heart-719 ,
I’ve never done anything with NFS, always had to use SAMBA, but I know you should:
Not have anything mounted in /run
, as /run
is volatile and not for permanent mounts. Rather use /mnt
, that’s what it’s there for.
Don’t have any entries for the drive both in /etc/fstab
and a systemd unit for it. Choose 1 option only. I recommend systemd units. Mine works like an absolute charm.
Rather use the IP address for the NFS share.
See:
Difficulty: ★☆☆☆☆
Disk device recognition
Manjaro uses udev (see Arch Wiki ) to load devices at boot time. The loading of devices is arbitrary and therefore you cannot predict which device will be available at a given path.
But static device names do exist and you can assign specific locations to your device and thus ensure e.g. scripts will work as expected.
What to learn
Overview of system mount units
Structure and Content of a mount unit
Mount at boot (immediate mount)
Mount on demand (m…
and
Difficulty: ★★☆☆☆
Example mount units for systemd
The examples here are a supplement to the guide on systemd mount units
Remember to remove the comments placed in the units - they are not writting for copy-paste but as examples. (comments is text beginning with a #)
[root tip] Use systemd to mount ANY device
Only use an automount unit if the device is not readily available at boot like removable devices and network locations.
Important rule
Fo…
Hope it helps!
xabbu
17 July 2022 11:02
3
Do not do this. It will not always work as expected. Do not use /run/
for anything expect USB thumb-drive you mount with via a GUI program.
Individual-Heart-719:
192.168.1.122:/X
Does not look like the same.
Do not enable it, if you want to use automount. Disable it, just enable the automount.
2 Likes
system
Closed
5 November 2022 13:01
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.