System will not mount NAS at boot, although the mount does work fine after its finished booting

The mount unit should not but enabled. Did you enable it?

You’re only supposed to enable the automount unit. It is the automount unit that takes care of mounting/unmounting.

If you enable the mount unit as well, then you’re going to bump into the same “not ready network” issues.

Disable the mount unit and reload the daemon, then try to reboot again.

sudo systemctl stop mnt-nas-TRUENAS.mount

sudo systemctl disable mnt-nas-TRUENAS.mount

sudo systemctl daemon-reload

To word it another way:

You only want the automount unit “enabled” which activates and starts it upon system boot. This is fine. Because it doesn’t do anything until you try to access the share.

You do not want to “enable” the mount unit, because it will try to activate and start upon system boot, in which your network (for one reason or another) might not be fully ready in time during the boot process.

The automount method is more “graceful” and forgiving, since it’s “in play” 24/7. Whereas trying to enable a mount unit immediately at bootup is a “one time attempt” during system boot. If it fails, then you need to manually intervene.

it still the same, nothing mounted afetr a reboot. No errors this time though, it just did not even try by the looks of it.

❰greg❙~❱✔≻ mount
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
dev on /dev type devtmpfs (rw,nosuid,relatime,size=8090572k,nr_inodes=2022643,mode=755,inode64)
run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755,inode64)
/dev/sda2 on / type ext4 (rw,noatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=12665)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
systemd-1 on /mnt/nas/TRUENAS type autofs (rw,relatime,fd=49,pgrp=1,timeout=120,minproto=5,maxproto=5,direct,pipe_ino=1401)
tmpfs on /tmp type tmpfs (rw,noatime,inode64)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=1620204k,nr_inodes=405051,mode=700,uid=1000,gid=1001,inode64)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1001)
portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=1001)
❰greg❙~❱✔≻ 
❰greg❙~❱✔≻ sudo systemctl status mnt-nas-TRUENAS.mount
○ mnt-nas-TRUENAS.mount - NAS Data mount
     Loaded: loaded (/etc/systemd/system/mnt-nas-TRUENAS.mount; disabled; vendor preset: disabled)
     Active: inactive (dead)
TriggeredBy: ● mnt-nas-TRUENAS.automount
      Where: /mnt/nas/TRUENAS
       What: //192.168.2.102/main/jackdinn
❰greg❙~❱✘≻ sudo systemctl status mnt-nas-TRUENAS.automount
● mnt-nas-TRUENAS.automount - Automount for NAS Data mount
     Loaded: loaded (/etc/systemd/system/mnt-nas-TRUENAS.automount; enabled; vendor preset: disabled)
     Active: active (waiting) since Tue 2022-06-07 00:52:14 BST; 2min 27s ago
      Until: Tue 2022-06-07 00:52:14 BST; 2min 27s ago
   Triggers: ● mnt-nas-TRUENAS.mount
      Where: /mnt/nas/TRUENAS

Notice: journal has been rotated since unit was started, output may be incomplete.
❰greg❙~❱✔≻ 
❰greg❙~❱✔≻ sudo systemctl status mnt-nas-TRUENAS.automount 
● mnt-nas-TRUENAS.automount - Automount for NAS Data mount
     Loaded: loaded (/etc/systemd/system/mnt-nas-TRUENAS.automount; enabled; vendor preset: disabled)
     Active: active (waiting) since Tue 2022-06-07 00:38:21 BST; 2min 32s ago
      Until: Tue 2022-06-07 00:38:21 BST; 2min 32s ago
   Triggers: ● mnt-nas-TRUENAS.mount
      Where: /mnt/nas/TRUENAS

Notice: journal has been rotated since unit was started, output may be incomplete.

Did you try to access it…?

o, it is there, but it did not show up in terminal “mount” output nor was it on my file browser sidebar, not until i when directly to it. Its never done this like that before?

It won’t mount until there’s a reason to. So if you have a backup software for example, it’ll seamlessly mount on-demand, and the backup software won’t even know. It’ll be treated like a normal mount.


Because you’re looking at Dolphin’s “Remote” section. I actually right-click → Hide Section ‘Remote’, since I use my own shortcuts with custom icons.

It’s really simple. Go to /mnt/nas, then click and drag the TRUENAS folder to your sidebar to make a custom shortcut. Now you can rename it to something more “human” and even change the icon to something cool. :wink:

I suspect this is why i might have enabled the .mount unit, because i could not see it anywhere at boot. I just start trying random crap after a while ^^

bit wearied how it always been there on display since it started working (and for ages by the old way i used to mount it)

hmm, but you dont get the little capacity line and the little triangle to dismount stuff the way you have it
ksnip_20220607-010332

True. I never really noticed since chances are the “free space” is what ZFS is reporting from the dataset, and being translated to the SMB share. But good catch.


No need to worry about mounting and dismounting, since automount takes care of it. (You can change the TimeoutIdle to whatever you wish. Shutting down, rebooting, and suspending are also handled gracefully with systemd-mount behind-the-scenes.


There is another alternative, of which you get less control (but a nice GUI interface), which is Smb4k for KDE. However, it lacks granularity, and its tray-icon still contains longstanding bugs.

Yea, i never liked smb4k (is it even still in development) , i would miss that i have a whole load of network folders that are not shown atm, but its nice to look down that list to see whats mounted and whats not. If im going to switch everything over to systemd (which i suspect i will) that will be a pity :frowning:

If you want, you can try to add another declaration under the [Unit] section in your .mount file:

Requires=network-online.target

Then add this under the [Install] section:

WantedBy=remote-fs.target

Then reload the daemon,

sudo systemctl daemon-reload

Then enable the .mount unit.

And disable the .automount unit.

sudo systemctl enable mnt-nas-TRUENAS.mount

sudo systemctl disable mnt-nas-TRUENAS.automount

Then reboot.

As a test…

ops, i tested it before you edited and added “WantedBy=remote-fs.target”

It did not work without it,

❰greg❙~❱✔≻ sudo systemctl status mnt-nas-TRUENAS.mount
[sudo] password for greg: 
× mnt-nas-TRUENAS.mount - NAS Data mount
     Loaded: loaded (/etc/systemd/system/mnt-nas-TRUENAS.mount; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Tue 2022-06-07 01:28:57 BST; 1min 1s ago
      Where: /mnt/nas/TRUENAS
       What: //192.168.2.102/main/jackdinn
        CPU: 6ms

Jun 07 01:28:57 greg-inspiron5767 systemd[1]: Mounting NAS Data mount...
Jun 07 01:28:57 greg-inspiron5767 mount[731]: mount error(101): Network is unreachable
Jun 07 01:28:57 greg-inspiron5767 mount[731]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Jun 07 01:28:57 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Mount process exited, code=exited, status=32/n/a
Jun 07 01:28:57 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Failed with result 'exit-code'.
Jun 07 01:28:57 greg-inspiron5767 systemd[1]: Failed to mount NAS Data mount.
❰greg❙~❱✘≻ 

im exhausted though, been at this all day, must sleep.

I shall get back at it tomorrow,

Thank you for all the help :slight_smile:

1 Like

It didn’t work

❰greg❙~❱✔≻ sudo systemctl status mnt-nas-TRUENAS.automount
[sudo] password for greg: 
○ mnt-nas-TRUENAS.automount - Automount for NAS Data mount
     Loaded: loaded (/etc/systemd/system/mnt-nas-TRUENAS.automount; disabled; vendor preset: disabled)
     Active: inactive (dead)
   Triggers: ● mnt-nas-TRUENAS.mount
      Where: /mnt/nas/TRUENAS
❰greg❙~❱✘≻ sudo systemctl status mnt-nas-TRUENAS.mount
× mnt-nas-TRUENAS.mount - NAS Data mount
     Loaded: loaded (/etc/systemd/system/mnt-nas-TRUENAS.mount; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Tue 2022-06-07 04:48:53 BST; 2min 38s ago
      Where: /mnt/nas/TRUENAS
       What: //192.168.2.102/main/jackdinn
        CPU: 3ms

Jun 07 04:48:52 greg-inspiron5767 systemd[1]: Mounting NAS Data mount...
Jun 07 04:48:53 greg-inspiron5767 mount[488]: mount error(101): Network is unreachable
Jun 07 04:48:53 greg-inspiron5767 mount[488]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Jun 07 04:48:53 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Mount process exited, code=exited, status=32/n/a
Jun 07 04:48:53 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Failed with result 'exit-code'.
Jun 07 04:48:53 greg-inspiron5767 systemd[1]: Failed to mount NAS Data mount.
❰greg❙~❱✘≻ cat /etc/systemd/system/mnt-nas-TRUENAS.mount
[Unit]
Description=NAS Data mount
After=network-online.target
Wants=network-online.target
Requires=network-online.target

[Mount]
What=//192.168.2.102/main/jackdinn
Where=/mnt/nas/TRUENAS
Options=iocharset=utf8,rw,actimeo=60,x-systemd.automount,uid=1000,gid=1000,forceuid,forcegid,file_mode=0600,dir_mode=0700,credentials=/home/greg/.smbcredentials-nas,cache=loose
Type=cifs
TimeoutSec=10

[Install]
WantedBy=multi-user.target
WantedBy=remote-fs.target
❰greg❙~❱✔≻ 

The more i think about it the more i definitely need some of my shares actually mounted and visible in the remote side bar at boot.
I shall put it back how it was but there must be a way to mount the darn things on boot!

I had this very same problem where a network being “up” isn’t really ready. Issue was with an automated rsync task, and no amount of fiddling around with WantedBy or After or Requires resolved it. I actually had to embed in my script a mini-task that keeps trying to ping the NAS server’s local IP address, and only after it receives a successful ping from the NAS server will it continue with the service.

I’m not sure how to apply that to mounts; only services and scripts.

I’ll see what I can find.

In the meantime, everything “works” more-or-less when you use the mount/automount combo, and disable the mount unit, while only letting automount dictate mounting/unmounting. Yes, you do lose out on the “remaining space” under the shortcut, but you can still right-click the shortcut and view the share’s properties. :slight_smile:

I’ll see what I can find.

If anything, you might have to create your own “custom” automount-at-boot service that will try to ping the NAS server’s IP address, and then start the mount unit. Otherwise, you’ll keep facing this issue of “server is unreachable” during bootup.


EDIT: In the meantime, try one more thing. With the automount unit disabled (and the mount unit enabled), change this in mnt-nas-TRUENAS.mount:

TimeoutSec=60

Maybe setting the TimeoutSec to 60 seconds will allow the enabled mount until to wait at least a minute after bootup before giving up…


EDIT 2: I’ve had this discussion before where Linux distros that use systemd aren’t very clear what “network is available” really means, and I think it’s poorly implemented with systemd.

What does it mean to have an available network?

:question: The network card / interface is activated?

:question: The client has a local IP address assigned?

:question: A remote address (WAN / internet) is reachable?

:question: A server on the local client is reachable?

The reason why I believe the developers should have more “checks” and “nuance” with the “network is available” logic is because there are different requirement and definitions.

For example:

  • If your internet is unavailable or you have DNS issues, shouldn’t services and mounts that only use a local network connection still work? Why do you care if google.com is unreachable when all you want to do is rsync to your local NAS server?

  • If your local router is pingable, but you have a service that uses cloud storage over the internet, shouldn’t it make more sense that you have a legitimate internet connection? Just because you can ping your own router/gateway, it doesn’t assure that your Google Drive is reachable.

  • Who cares if a network interface is “up”? It doesn’t mean that a local NAS server is reachable (might need more time, or the server is down), nor does it mean that a remote internet address is reachable (your internet connection might not be ready or is currently down.)


EDIT 3: Believe it or not, I faced a similar issue with Windows 10. The “hack” I used was to add in my script:

TIMEOUT /T 15 /NOBREAK > NUL

This waits 15 seconds (such as after resuming from suspend or when the script is called after bootup) before continuing with the “sync to NAS” task.

Otherwise, viewing the Windows Tasks log shows that the server at 192.168.1.101 was unreachable. :laughing:

Thx for your time :slight_smile:

I have had others who are stumped also https://www.reddit.com/r/linuxquestions/comments/v6tj2s/cant_mount_smb_shares_at_boot_rather_than_on/

Although he says that i should really be using fstab not systemd units but in the end it all comes down to the same problem with systemd and services that are supposed to check for network connection at boot.

The chap on redit says there is nothing wrong with either my fstab or my .mount .automount.

I might even reinstall linux (yet again, it gets monotonous but this is just 1 of many similar problems (not network problems but other things that no one can help with)).

I just spent a load of cash on a nas and i cant mount it properly, all very funny ^^

I have read through all your posts carefully. I shall try for a while longer. I can script with python and bash so i might do something at boot. (just a pity systemd completely escapes me).

I don’t think that will solve it.

Did you try with the TimeoutSec=60 option?

im getting there :stuck_out_tongue:

Here is the logic I use to make sure that my “network” is ready, but more importantly, that my NAS server is reachable.

# Wait 30 seconds for "network" to activate
if nm-online -q --timeout 30;
        
    # Continue since network is active.
    then
 
        # Since the "network" is ready, do not continue until NAS server is reachble. (Attempt for 20 seconds to get a response from NAS server.)
        if timeout 21s bash -c 'until ping -c1 -q 192.168.1.101 > /dev/null 2>&1 ; do echo "NAS unreachable! Retrying!" ; sleep 2s ; done'

            # Since NAS server responds, continue the task.
            then
            ### DO STUFF THAT REQUIRES NAS SERVER IN HERE ###

            # But since NAS server doesn't respond after 20 seconds, abort task.
            else
            echo "NAS server is not reachable. Task has been aborted!"
            
        fi

    # If network cannot activate after 30 seconds, abort everything and don't bother trying to reach the NAS server.        
    else
    echo "No network connection available. Task has been aborted!"

fi

was worth a try but no it didnt work. With just .mount enabled and the timout set to 60:-

CIFS: VFS: cifs_mount failed w/return code = -101
mount error(101): Network is unreachable

ok, yea i can use that. Thx for sharing.