Automounting fails with mount-start-limit-hit

Hi everyone.

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

[Unit]
Description=serwer

[Mount]
What=//192.168.0.100/Dane
Where=/home/adrian/media/DANE
Type=cifs
Options=_netdev,iocharset=utf8,rw,file_mode=0777,dir_mode=0777,credentials=/etc/smb.cred,uid=1000
TimeoutSec=30

[Install]
WantedBy=multi-user.target

Automount (enabled) filename: home-adrian-media-DANE.automount

[Unit]
Description=DANE automount

[Automount]
Where=/home/adrian/media/DANE

[Install]
WantedBy=multi-user.target

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!

Hi @slepy8,

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:

and

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:

[Unit]
Description=serwer
Requires=network-online.target

[Mount]
What=//192.168.0.100/Dane
Where=/home/adrian/media/DANE
Type=cifs
Options=_netdev,iocharset=utf8,rw,file_mode=0777,dir_mode=0777,credentials=/etc/smb.cred,uid=1000
TimeoutSec=30

[Install]
WantedBy=multi-user.target

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.

Exactly as @slepy8 mentioned.

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?

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
# /etc/systemd/system/home-mirdarthos-Gatekeeper_Downloads.mount
[Unit]
Description=Mount Gatekeeper's Downloads

[Mount]
What=mirdarthos@10.0.0.254:/home/mirdarthos/Downloads
Where=/home/mirdarthos/Gatekeeper_Downloads
Type=fuse.sshfs
Options=_netdev,allow_other,IdentityFile=/home/mirdarthos/.ssh/id_rsa,reconnect,ServerAliveInterval=30,ServerAliveCountMax=5
TimeoutSec=3600

$  systemctl cat home-mirdarthos-Gatekeeper_Downloads.automount
# /etc/systemd/system/home-mirdarthos-Gatekeeper_Downloads.automount
[Unit]
Description=Automount gatekeeper Downloads
ConditionPathExists=/home/mirdarthos/Gatekeeper_Downloads

[Automount]
Where=/home/mirdarthos/Gatekeeper_Downloads
TimeoutIdleSec=30m

[Install]
WantedBy=multi-user.target

Learning something new every day :slight_smile:

A working set of unit files for cifs mount

disabled

 $ cat /etc/systemd/system/home-fh-media-data.mount
[Unit]
Description=nas

[Mount]
What=//nas.net.nix.dk/data
Where=/home/fh/media/data
Type=cifs
Options=_netdev,iocharset=utf8,rw,file_mode=0777,dir_mode=0777,credentials=/etc/samba/.smbcredentials
TimeoutSec=30

[Install]
WantedBy=multi-user.target

enabled

 $ cat /etc/systemd/system/home-fh-media-data.automount 
[Unit]
Description=data on nas

[Automount]
Where=/home/fh/media/data
TimeoutIdleSec=30

[Install]
WantedBy=multi-user.target
 $ ls ~/media/data
 1.mp4
 2.mp4
 3.mp4
 4.mp4
 codeformatting
 conky
 diskstation-rsync-scripts
 download
...

So what is the solution?
Cause it’s not very clear from your post

The diffs from my set of units

mount unit

  • remove uid=1000 from options

automount unit

  • added TimeoutIdleSec=30

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