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

Every time i boot i get the splash saying systemd[1]: Failed to mount /run/media/greg/TRUENAS.

I have a fstab with

//192.168.2.102/main/jackdinn /run/media/greg/TRUENAS cifs user,nofail,credentials=/home/greg/.smbcredentials-nas,iocharset=utf8,uid=1000,gid=1000,noperm,_netdev 0 0

The mount does work fine if i mount it manually after login, it just wont mount at boot.

5.950516] CIFS: Attempting to mount \\192.168.2.102\main
[    5.950538] CIFS: VFS: Error connecting to socket. Aborting operation.
[    5.950542] CIFS: VFS: cifs_mount failed w/return code = -101
Jun 06 18:41:33 greg-inspiron5767 systemd[1]: run-media-greg-TRUENAS.mount: Mount process exited, code=exited, status=32/n/a
Jun 06 18:41:33 greg-inspiron5767 systemd[1]: run-media-greg-TRUENAS.mount: Failed with result 'exit-code'.
Jun 06 18:41:33 greg-inspiron5767 systemd[1]: Failed to mount /run/media/greg/TRUENAS.

I found all sorts of suggestions to add to the fstab like _netdev, i have tried them all.
I also found some saying i should not even be using fstab but its taken me long enough to get fstab working at all, i defiantly dont understand systemd or how to use it to mount smb shares.

I also found someone with the exact same problem from 4 years ago on reddit https://www.reddit.com/r/debian/comments/9rvj0j/cifs_shares_not_mounting_at_boot/ but their answer was to “change allow-hotplug by auto” in /etc/network/interfaces but i dont even have that file and im using network-manager.

EDIT:- a little more diagnostic info.

❰greg❙~❱✔≻ systemctl status run-media-greg-TRUENAS.mount
× run-media-greg-TRUENAS.mount - /run/media/greg/TRUENAS
     Loaded: loaded (/etc/fstab; generated)
     Active: failed (Result: exit-code) since Mon 2022-06-06 18:41:33 BST; 55min ago
      Where: /run/media/greg/TRUENAS
       What: //192.168.2.102/main/jackdinn
       Docs: man:fstab(5)
             man:systemd-fstab-generator(8)
        CPU: 3ms

Jun 06 18:41:31 greg-inspiron5767 systemd[1]: Mounting /run/media/greg/TRUENAS...
Jun 06 18:41:33 greg-inspiron5767 mount[503]: mount error(101): Network is unreachable
Jun 06 18:41:33 greg-inspiron5767 mount[503]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Jun 06 18:41:33 greg-inspiron5767 systemd[1]: run-media-greg-TRUENAS.mount: Mount process exited, code=exited, status=32/n/a
Jun 06 18:41:33 greg-inspiron5767 systemd[1]: run-media-greg-TRUENAS.mount: Failed with result 'exit-code'.
Jun 06 18:41:33 greg-inspiron5767 systemd[1]: Failed to mount /run/media/greg/TRUENAS.
❰greg❙~❱✘≻ 

Very confused.

The connection between your client and the NAS server might not be available at the very moment the fstab tries to create the mount.

If you use systemd units, there is a condition that can be met where the network has to be available before the mount can be attempted. Not only that, but by using systemd units, simply accessing the directory will automount it (and you can define a “idle” period where the unit will unmoun automatically after a period of inactivity.


EDIT: Wait, you’re already using systemd mount units? Are you using both systemd-mount and fstab methods?

EDIT 2: Okay, you’re using this: systemd-fstab-generator


Honestly, forgoing the fstab method and using only systemd-mount is the preferable method.

I haven’t got a clue, as i say i dont even understand what im doing or what systemd is or how to use it to mount things.

What is a systemd unit?
Please advise.

Why is it that i spend months reading how to mount stuff and they all talk about fstab , now it looks like that was all a waste of time :frowning:

It’s the “newer and smarter” way of mounting things that are not static devices, like found on your root and home filesystems.


I can share some of my own .mount and .automount units if needed. Once you get a hang of the syntax and format, it’s easy to add more and more units. :slight_smile:

Well sure, please do share an example as i tend to learn best by real world examples, everything else just looks like spaghetti word salad to me. Cheers.

Contents of the file /etc/systemd/system/mnt-nas-data.mount

[Unit]
Description=NAS Data mount
After=network-online.target
Wants=network-online.target

[Mount]
What=//192.168.1.101/data
Where=/mnt/nas/data
Options=iocharset=utf8,rw,actimeo=60,x-systemd.automount,uid=1000,gid=1000,forceuid,forcegid,file_mode=0600,dir_mode=0700,user=winnie,credentials=/home/winnie/.nas-creds,cache=loose
Type=cifs
TimeoutSec=10

[Install]
WantedBy=multi-user.target

The filename format must match the path for the mount, whereas “hyphens” in the filename represent “slashes” of the mount’s path.

The above unit will mount at the location /mnt/nas/data, which is why the filename is mnt-nas-data.mount

You needn’t “start” or “enable” the above .mount unit, since the corresponding .automount unit will take care of it.


Contents of the file /etc/systemd/system/mnt-nas-data.automount

[Unit]
Description=Automount for NAS Data mount

[Automount]
Where=/mnt/nas/data
TimeoutIdleSec=120

[Install]
WantedBy=multi-user.target

In order for the above .automount unit to “partner with” and “activate” the .mount unit, the following two things are mandatory:

  1. The filename needs to be exactly the same, with the exception of the .automount extension.
  2. The Where= entry must be exactly the same as the .mount unit’s.

Once these two files are created, you can enable and start the .automount unit, and you should be good to go.

sudo systemctl daemon-reload

sudo systemctl enable mnt-nas-data.automount

sudo systemctl start mnt-nas-data.automount

UPDATE: Make sure to remove or comment out the entry in your fstab to avoid conflicts.

1 Like

Ok, im reading & reading :slight_smile: Its going to be a long night, but i appreciate the pointer and links.

It says

Mount units may either be configured via unit files, or via /etc/fstab (see fstab(5) 43 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.

So why is it having trouble with waiting for my network to become active before trying to mount, it sounds like it should be able to do this fine by converting from fstab?

You need to add systemd parameters/options then. NFS - ArchWiki

  • What permissions are these units supposed to have?
  • Also, i believe i have the naming convention correct so far for /run/media/greg/TRUENAS ?

-rw-r–r-- 1 root root 0 Jun 6 20:37 run-media-greg-TRUENAS.automount
-rw-r–r-- 1 root root 0 Jun 6 20:42 run-media-greg-TRUENAS.mount

Do not use /run for anything. It is a temporary filesystem. Do not use it for mounts. It should be only used for temporary mounts done by your file manager.

2 Likes

ok, where shall i stick them then ?

Readable by the root user, since they’re system (not user) units. Nothing special.

Yes, it’s the correct naming convention, but I’m not sure if using the /run/ path might cause issues. I like to stay “out of the way” and only use /mnt, and in fact made the custom path /mnt/nas/ to exclusively hold my NAS shares.

Such as,
/mnt/nas/data
/mnt/nas/downloads
/mnt/nas/plex
And so on…


EDIT: Remember to change all the relevant entries and names when switching to a different mount location.

  • The filenames for both units
  • The Where= in both units (mount and automount units)

EDIT 2: For ease-of-use, just create a “favorite” or “shortcut” for your launcher, side pane, file browser, etc, so you don’t have to always navigate to /mnt/nas/blahblah

If there are any issues, you can always “stop” the mount unit, which effectively “unmounts” the share.

(You’ll get a warning that since the automount unit is still active, even though the mount has been “stopped”, it can re-mount on its own because the automount unit is still listening.)

sudo systemctl stop mnt-nas-blahblah.mount

This is the equivalent of sudo umount /mnt/nas/blahblah

Don’t use “umount” if you’re using the systemd-mount method.


To check the logs, what triggered the mount, etc, use journalctl as you would any service:

journalctl -u mnt-nas-blahblah.mount

journalctl -u mnt-nas-blahblah.automount

systemctl status mnt-nas-blahblah.mount

systemctl status mnt-nas-blahblah.automount

EDIT 3: I’d suggest you use a more meaningful name, rather than “TRUENAS”, since you might end up making more shares later on, and you need something that differentiates them.

3 Likes

i seem to have got in a bit of a muddle, somewhere?

❰greg❙/mnt/nas/TRUENAS❱✔≻ 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: failed (Result: mount-start-limit-hit) since Mon 2022-06-06 21:18:40 BST; 45s ago
   Triggers: ● mnt-nas-TRUENAS.mount
      Where: /mnt/nas/TRUENAS

Jun 06 21:14:32 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.automount: Got automount request for /mnt/nas/TRUENAS, triggered by 1741 (kioslave5)
Jun 06 21:14:54 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.automount: Got automount request for /mnt/nas/TRUENAS, triggered by 1741 (kioslave5)
Jun 06 21:18:39 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.automount: Got automount request for /mnt/nas/TRUENAS, triggered by 2226 (fish)
Jun 06 21:18:39 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.automount: Got automount request for /mnt/nas/TRUENAS, triggered by 2226 (fish)
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.automount: Got automount request for /mnt/nas/TRUENAS, triggered by 2236 (fish)
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.automount: Got automount request for /mnt/nas/TRUENAS, triggered by 2236 (fish)
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.automount: Got automount request for /mnt/nas/TRUENAS, triggered by 2236 (fish)
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.automount: Got automount request for /mnt/nas/TRUENAS, triggered by 2236 (fish)
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.automount: Failed with result 'mount-start-limit-hit'.
Notice: journal has been rotated since unit was started, output may be incomplete.
❰greg❙/mnt/nas/TRUENAS❱✘≻ 
❰greg❙/mnt/nas/TRUENAS❱✘≻ 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: failed (Result: exit-code) since Mon 2022-06-06 21:18:40 BST; 3min 15s ago
TriggeredBy: × mnt-nas-TRUENAS.automount
      Where: /mnt/nas/TRUENAS
       What: //192.168.2.102/main/jackinn
        CPU: 10ms

Jun 06 21:18:40 greg-inspiron5767 systemd[1]: Mounting NAS Data mount...
Jun 06 21:18:40 greg-inspiron5767 mount[2246]: mount error(13): Permission denied
Jun 06 21:18:40 greg-inspiron5767 mount[2246]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Mount process exited, code=exited, status=32/n/a
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Failed with result 'exit-code'.
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: Failed to mount NAS Data mount.
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Start request repeated too quickly.
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Failed with result 'exit-code'.
Jun 06 21:18:40 greg-inspiron5767 systemd[1]: Failed to mount NAS Data mount.
❰greg❙/mnt/nas/TRUENAS❱✘≻ 

hmm permission denied.

❰greg❙/mnt/nas❱:heavy_check_mark:≻ ls -la
total 12
drwxr-xr-x 3 root root 4096 Jun 6 21:11 ./
drwxr-xr-x 3 root root 4096 Jun 6 21:11 …/
drwxr-xr-x 2 root root 4096 Jun 6 21:11 TRUENAS/

Is this not run by root? bit lost agin.

O , also how do i do a quick check to see if its mounting properly via command? Rather than having to reboot comp to see what happens

O so systemctl start run-media-greg-TRUENAS.mount should mount it?

❰greg❙/mnt/nas❱✘≻ sudo systemctl start run-media-greg-TRUENAS.mount
[sudo] password for greg:
Failed to start run-media-greg-TRUENAS.mount: Unit run-media-greg-TRUENAS.mount not found.
❰greg❙/mnt/nas❱✘≻ cat /etc/systemd/system/mnt-nas-TRUENAS.mount
[Unit]
Description=NAS Data mount
After=network-online.target
Wants=network-online.target

[Mount]
What=//192.168.2.102/main/jackinn
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,user=winnie,credentials=/home/greg/.smbcredentials-nas,cache=loose
Type=cifs
TimeoutSec=10

[Install]
WantedBy=multi-user.target
❰greg❙/mnt/nas❱:heavy_check_mark:

That’s because…


I didn’t explicitly say it, but you need to reload the daemon and restart the automount unit after making changes.

sudo systemctl daemon-reload

sudo systemctl restart mnt-nas-blahblah.automount

Also, do not manually create any directories under /mnt/nas, since the mount units will do that for you automatically.

I was sure i did.

❰greg❙/mnt/nas❱✔≻ cat /etc/systemd/system/mnt-nas-TRUENAS.mount
[Unit]
Description=NAS Data mount
After=network-online.target
Wants=network-online.target

[Mount]
What=//192.168.2.102/main/jackinn
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,user=winnie,credentials=/home/greg/.smbcredentials-nas,cache=loose
Type=cifs
TimeoutSec=10

[Install]
WantedBy=multi-user.target
❰greg❙/mnt/nas❱✔≻ cat /etc/systemd/system/mnt-nas-TRUENAS.automount
[Unit]
Description=Automount for NAS Data mount

[Automount]
Where=/mnt/nas/TRUENAS
TimeoutIdleSec=120

[Install]
WantedBy=multi-user.target
❰greg❙/mnt/nas❱✔≻ 

Why are you using my username to login to your SMB share?

:rofl:

haha, nice spot, im getting a headache already :grinning:

So i should remove the “TRUENAS” from the units?

Use whatever location / name you want.

I’m just letting you know that “TRUENAS” is not a good name to use, since you might create new shares later on, and you’ll need something unique to name them with, as you nest them under /mnt/nas/

Otherwise, you’ll end up creating ambiguous shares named “TRUENAS”, and “TRUENAS2”, and “TRUENAS3”.

I use names like “plex” and “downloads” and “data”, and so on. I like to keep it simple, all lowercase, no spaces, no special characters, only lowercase letters (and numbers, if needed).

What I wrote earlier, I was reminding you not to manually create the folders that will be used as mount points, since the mount units will do that for you.

In other words,
Where=/mnt/nas/blahblah

Do not manually create the folder blahblah. Let the systemd mount unit handle creating the directory on its own.