I have a NAS with SMB share and want to automount it via systemd automount when I turn on this NAS.
Mount (disabled) filename: home-adrian-media-DANE.mount
Automount (enabled) filename: home-adrian-media-DANE.automount
After daemon-reload and reboot,
status for automount unit is:
"Failed with result ‘mount-start-limit-hit’.
status for mount unit is:
“home-adrian-media-DANE.mount: Failed with result ‘exit-code’.
Failed to mount serwer.
Start request repeated too quickly.
Failed with result ‘exit-code’.
Failed to mount serwer.”
What can I do about it?
Thanks in advance!
I have, myself, quite a few systemd mounts, and a few automounts as well. Granted, they’re SSH and not SMB, but they’re networked and works really well. I followed these tutorials, they ought to help you:
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…
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 writing for copy-paste but as examples. (comments is text beginning with a #)
[root tip] [How To] 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.
Hope these helps!
I know these threads.
And they don’t solve my issues.
At least I don’t find the answear there…
Does the mount work if you manually start it?
sudo sysstemctl start home-adrian-media-DANE.mount
I think the problem is that systemd-automout works on your machine: it’s mounted on access (or on boot, depending on your setup). But it assumes that the NAS is always available. If it’s not available, it will retry a few times and fail.
How should your system know that the remote endpoint is available?
Yes, it mounts without a problem
This might be the point.
What I aimed for is a behaviour seen when mounting a USB drive.
Whenever it becomes accesible it should be mounted.
I just have no idea what Options should I use to make it happen. (if it’s Options case)
Dependance on availability of the NAS is not options based…
You should create a script that checks the NAS and if available start the mount unit, and when it dissapears stop the mount unit.
Automounts work in the way that it gets mounted when it’s
accessed, not when it’s available, IIRC. For that a normal systemd mount would suffice. And if, as you said,
…you should just enable it:
sudo systemd enable --now home-adrian-media-DANE.mount
This will result in the error message from the first post when the NAS is not running: failed too quickly too often.
(You have an error in your command, it should be
sudo systemctl enable --now ... )
This soundslike a reasonable solution.
But is there no other way?
If it can work with USB dongle why can’t it work with SMB share?
You can always edit the unit to make a network connection the deependency:
And after you’ve edited the file, remember to reload the daemon:
sudo systemctl daemon-reload
I read somewhere that ‘_netdev’ should satisfy this and they should not be used simultaneusly.
Or maybe “Requires=network-online.target” should be added to automount unit?
Don’t add this - it will create weird messages in log.
_netdev option makes systemd infer that network-online.target is needed
When you specify a mountpoint inside your home - I will have to verify - but as I recall it - it will fail.
Test by duplicating your units using e.g. /a/DANE as mountpoint - start and stop the mount unit once to create the mountpoint - then set permissions -
remove the uid=1000 from options in your mount unit
add TimeoutIdleSec=30 to automount - just below the Where=
chmod o+rwx /a/DANE
then enable the automount
I have three that works perfectly, so maybe it’s not that.
can you cat them for me?
just one mount and the corresponding automount
But I think there may be a difference with cifs - yours is using sshfs - as I recall?
yours is using sshfs
Correct. Because I didn’t see the use or need to setup SMB for the server since I’m the
only one that uses it.
$ systemctl cat home-mirdarthos-Gatekeeper_Downloads.mount
Description=Mount Gatekeeper's Downloads
$ systemctl cat home-mirdarthos-Gatekeeper_Downloads.automount
Description=Automount gatekeeper Downloads
Learning something new every day
A working set of unit files for
$ cat /etc/systemd/system/home-fh-media-data.mount
$ cat /etc/systemd/system/home-fh-media-data.automount
Description=data on nas
$ ls ~/media/data
So what is the solution?
Cause it’s not very clear from your post
The diffs from my set of units
remove uid=1000 from options
my credentials file is accessible only by root and stored in /etc/samba under another name (the name doesn’t matter)
chmod 600 /etc/smb.cred