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

yea i get all that, i just want to get it to work first.

❰greg❙/mnt/nas❱✘≻ sudo systemctl status mnt-nas-TRUENAS.mount
× mnt-nas-TRUENAS.mount - NAS Data mount
     Loaded: bad-setting (Reason: Unit mnt-nas-TRUENAS.mount has a bad unit file setting.)
     Active: failed (Result: exit-code) since Mon 2022-06-06 21:44:46 BST; 1min 0s ago
TriggeredBy: ○ mnt-nas-TRUENAS.automount
      Where: /mnt/nas
       What: //192.168.2.102/main/jackinn
        CPU: 4ms

Jun 06 21:44:46 greg-inspiron5767 systemd[1]: Mounting NAS Data mount...
Jun 06 21:44:46 greg-inspiron5767 mount[5046]: mount error(13): Permission denied
Jun 06 21:44:46 greg-inspiron5767 mount[5046]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Jun 06 21:44:46 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Mount process exited, code=exited, status=32/n/a
Jun 06 21:44:46 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Failed with result 'exit-code'.
Jun 06 21:44:46 greg-inspiron5767 systemd[1]: Failed to mount NAS Data mount.
Jun 06 21:45:12 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Where= setting doesn't match unit name. Refusing.
❰greg❙/mnt/nas❱✘≻ 


❰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
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
❰greg❙/mnt/nas❱✔≻ 

Should i put TRUENAS back in, ??? really bad head now.

Yes.

I didn’t mean literally “do not use TRUENAS”. It was just a suggestion for future reference to use cleaner and more sensible names.


EDIT:

If you want…

/mnt/nas/TRUENAS

…then use…

Where=/mnt/nas/TRUENAS

Which means, the names must be…

mnt-nas-TRUENAS.mount
mnt-nas-TRUENAS.automount


EDIT 2:

If you want…

/mnt/nas/multimedia

…then use…

Where=/mnt/nas/multimedia

Which means, the names must be…

mnt-nas-multimedia.mount
mnt-nas-multimedia.automount


EDIT 3:

What if you want to add a new share to be auto-mounted, and it’s for your downloads maybe?

Everything above will basically be the same, except downloads will replace multimedia.

It will mount to: /mnt/nas/???

The filenames must be mnt-nas-???.mount and mnt-nas-???.automount

The “Where” for both units must be Where=/mnt/nas/???

Can you guess what ??? is supposed to be? :wink:

❰greg❙/mnt/nas❱✔≻ 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:44:46 BST; 8min ago
TriggeredBy: ○ mnt-nas-TRUENAS.automount
      Where: /mnt/nas/TRUENAS
       What: //192.168.2.102/main/jackinn
        CPU: 4ms

Jun 06 21:44:46 greg-inspiron5767 systemd[1]: Mounting NAS Data mount...
Jun 06 21:44:46 greg-inspiron5767 mount[5046]: mount error(13): Permission denied
Jun 06 21:44:46 greg-inspiron5767 mount[5046]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Jun 06 21:44:46 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Mount process exited, code=exited, status=32/n/a
Jun 06 21:44:46 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Failed with result 'exit-code'.
Jun 06 21:44:46 greg-inspiron5767 systemd[1]: Failed to mount NAS Data mount.
Jun 06 21:45:12 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Where= setting doesn't match unit name. Refusing.
❰greg❙/mnt/nas❱✘≻ sudo systemctl stop mnt-nas-TRUENAS.mount
❰greg❙/mnt/nas❱✔≻ sudo systemctl start mnt-nas-TRUENAS.mount
Job failed. See "journalctl -xe" for details.
❰greg❙/mnt/nas❱✘≻ journalctl -xe
Jun 06 21:56:00 greg-inspiron5767 kernel: audit: type=1110 audit(1654548960.382:231): pid=6235 uid=1000 auid=1000 ses=1 subj==unconfined msg='op=PAM:setcred grantors=pam_f>
Jun 06 21:56:00 greg-inspiron5767 sudo[6235]: pam_unix(sudo:session): session opened for user root(uid=0) by greg(uid=1000)
Jun 06 21:56:00 greg-inspiron5767 audit[6235]: USER_START pid=6235 uid=1000 auid=1000 ses=1 subj==unconfined msg='op=PAM:session_open grantors=pam_systemd_home,pam_limits,>
Jun 06 21:56:00 greg-inspiron5767 kernel: audit: type=1105 audit(1654548960.389:232): pid=6235 uid=1000 auid=1000 ses=1 subj==unconfined msg='op=PAM:session_open grantors=>
Jun 06 21:56:00 greg-inspiron5767 systemd[1]: Mounting NAS Data mount...
░░ Subject: A start job for unit mnt-nas-TRUENAS.mount has begun execution
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░ 
░░ A start job for unit mnt-nas-TRUENAS.mount has begun execution.
░░ 
░░ The job identifier is 1644.
Jun 06 21:56:00 greg-inspiron5767 kernel: CIFS: Attempting to mount \\192.168.2.102\main
Jun 06 21:56:00 greg-inspiron5767 mount[6239]: mount error(2): No such file or directory
Jun 06 21:56:00 greg-inspiron5767 mount[6239]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Jun 06 21:56:00 greg-inspiron5767 kernel: CIFS: VFS: cifs_mount failed w/return code = -2
Jun 06 21:56:00 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Mount process exited, code=exited, status=32/n/a
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░ 
░░ An n/a= process belonging to unit mnt-nas-TRUENAS.mount has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 32.
Jun 06 21:56:00 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░ 
░░ The unit mnt-nas-TRUENAS.mount has entered the 'failed' state with result 'exit-code'.
Jun 06 21:56:00 greg-inspiron5767 systemd[1]: Failed to mount NAS Data mount.
░░ Subject: A start job for unit mnt-nas-TRUENAS.mount has failed
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░ 
░░ A start job for unit mnt-nas-TRUENAS.mount has finished with a failure.
░░ 
░░ The job identifier is 1644 and the job result is failed.
Jun 06 21:56:00 greg-inspiron5767 sudo[6235]: pam_unix(sudo:session): session closed for user root
Jun 06 21:56:00 greg-inspiron5767 audit[6235]: USER_END pid=6235 uid=1000 auid=1000 ses=1 subj==unconfined msg='op=PAM:session_close grantors=pam_systemd_home,pam_limits,p>
Jun 06 21:56:00 greg-inspiron5767 audit[6235]: CRED_DISP pid=6235 uid=1000 auid=1000 ses=1 subj==unconfined msg='op=PAM:setcred grantors=pam_faillock,pam_permit,pam_env,pa>
Jun 06 21:56:00 greg-inspiron5767 kernel: audit: type=1106 audit(1654548960.549:233): pid=6235 uid=1000 auid=1000 ses=1 subj==unconfined msg='op=PAM:session_close grantors>
Jun 06 21:56:00 greg-inspiron5767 kernel: audit: type=1104 audit(1654548960.549:234): pid=6235 uid=1000 auid=1000 ses=1 subj==unconfined msg='op=PAM:setcred grantors=pam_f>

❰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,credentials=/home/greg/.smbcredentials-nas,cache=loose
Type=cifs
TimeoutSec=10

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

Can you split your outputs into their own code boxes?

It’s hard to read when it’s just one massive code box.


What was the fstab entry that worked when you manually mounted the share?

This?

//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

I notice that your mount unit has something different for What=

You wrote this: //192.168.2.102/main/jackinn

But your fstab entry has jackdinn instead…

1 Like

Your brilliant and patient :smiley: A god darn typo.

❰greg❙/mnt/nas❱✔≻ 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: active (mounted) since Mon 2022-06-06 22:10:13 BST; 17s ago
      Until: Mon 2022-06-06 22:10:13 BST; 17s ago
TriggeredBy: ○ mnt-nas-TRUENAS.automount
      Where: /mnt/nas/TRUENAS
       What: //192.168.2.102/main/jackdinn
      Tasks: 0 (limit: 18962)
     Memory: 20.0K
        CPU: 7ms
     CGroup: /system.slice/mnt-nas-TRUENAS.mount

Jun 06 22:10:13 greg-inspiron5767 systemd[1]: Mounting NAS Data mount...
Jun 06 22:10:13 greg-inspiron5767 systemd[1]: Mounted NAS Data mount.
❰greg❙/mnt/nas❱✔≻ mount
//192.168.2.102/main/jackdinn on /mnt/nas/TRUENAS type cifs (rw,relatime,vers=3.1.1,cache=loose,username=jackdinn,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.2.102,file_mode=0600,dir_mode=0700,iocharset=utf8,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=60,x-systemd.automount)

First you use my username for your credentials, and then you misspell your own folder name? :laughing:

I suggest doing things slowly and double-checking everything before slamming the gas pedal. :wink:

Of course, you are right, i just dont want the agro of learning stuff i just want to get on and use it. Iv been this way with linux for years since i left windows, it frustrates the hell out of me but i refuse to go back to M$.

So i just need to check the mount at boot, but i assume it’ll be fine.

Thank you very much :smiley:

Not very helpful now, but apparently all you really needed was the _netdev option.

fstab - ArchWiki

Just some things to keep in mind:

  • Make sure there’s no entry in your fstab (you’ll be using systemd mount units for this type of stuff going forwards)

  • Use the start and stop commands to manual mount and umount systemd .mount units

  • Keep in mind the .automount is constantly listening for access

  • You can temporarily stop the .automount unit if necessary

  • Use journalctl and systemctl status if diagnosis is needed

  • Remember to reload the systemd daemon and restart the .automount unit if you make changes

  • You can create as many different mount/automount pairs under /etc/systemd/system/ using the same formats / concepts

  • For any new mount/automount pairs that you create, you need to enable and start the automount unit for the first time use (so it will be immediately available and not require a reboot)

  • I recommend making a copy of at least one pair of mount/automount units in your Documents folder, in case you need to save the template for future use or with new systems:

cp -v /etc/systemd/system/mnt-nas-TRUENAS.mount ~/Documents/

cp -v /etc/systemd/system/mnt-nas-TRUENAS.automount ~/Documents/

was that not already in my OP? i was sure it was

This was already tried.

Absolutely right, I should read better. :man_facepalming:

All great advice, i think this particular one was what was also causing me lots of pain. I shall try to remember what we have done tonight.

Hey, don’t be hard on yourself. At least you didn’t write the wrong username for your credentials or misspell your own folder name…

OH BURNNNNNNNNNNN!!! :fire:

2 Likes

I’m assuming you’re using KDE.

Just a heads up (and this is not specific to systemd mounts), Dolphin or a KIO service might once in a while “leave a file open” which prevents the mount from being unmounted. (Even if you think no such program is running and/or holding onto the file.)

It’s rare, but it does happen.

If you want to find the offending process, you can use something like:

lsof | grep /mnt/nas

Whatever the PID is (process ID), you’ll know to kill that process (using kill or the System Monitor).

This applies to any type of mount, whether fstab, systemd, or even via the file manager itself. It can affect network shares and even external USB drives.

It’s nothing to do with this topic, per se, but I might as well let you know about it ahead of time since you’re using KDE.

1 Like

sorry if you already posted it in this thread but whats the switch/option to mount “on demand” i.e. requested by user browsing or an automated backup program requiring it?

I assume its in the .mount unit in the options, but whats it called?

It’s the .automount unit that takes care of that.

Any request to the path will automatically mount the share (if it’s not already mounted), or just let it continue like normal (if it’s already mounted.)

Doesn’t matter what tries to access it: navigating in the terminal, backup software, file browser, opening files, etc.


automount units are very simple. They need to be named exactly the same as their mount unit counterpart (but with a .automount filename extension, of course), and declare the same Where= to point to the same path as the .mount unit’s Where= declaration.

The TimeoutIdleSec= declares how many seconds of no access/activity before it should be automatically unmounted.

There’s more, of course.


Just remember to keep the names and paths simple: only lowercase letters and numbers, avoid using special characters, spaces, and other symbols. Otherwise, the unit files need to be carefully declared using “escape” sequences, which makes things more confusing.

I think iv also read that you dont actually need the .automount at all for mounting at boot, it says that it should do that with just the .mount unit. Adding the .automount seems to be what allows/controls the mount on demand.

Well thats how im reading it ATM.

Technically, yes, but it’s cleaner and less prone to issues if you leave the mount unit disabled, and let the automount unit take care of everything.

For example, imagine a network issue upon boot. Then you’ll need to manually do sudo systemctl restart mnt-nas-blahblah.mount, which circles back to your original problem.

O dam, iv lost it again. It just stopped being able to mount at boot again, i didnt change anything.

 5.526883] CIFS: Attempting to mount \\192.168.2.102\main
[    5.526912] CIFS: VFS: Error connecting to socket. Aborting operation.
[    5.526918] CIFS: VFS: cifs_mount failed w/return code = -101
❰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.
❰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 00:38:24 BST; 2min 37s ago
TriggeredBy: ● mnt-nas-TRUENAS.automount
      Where: /mnt/nas/TRUENAS
       What: //192.168.2.102/main/jackdinn
        CPU: 4ms

Jun 07 00:38:23 greg-inspiron5767 systemd[1]: Mounting NAS Data mount...
Jun 07 00:38:24 greg-inspiron5767 mount[474]: mount error(101): Network is unreachable
Jun 07 00:38:24 greg-inspiron5767 mount[474]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Jun 07 00:38:24 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Mount process exited, code=exited, status=32/n/a
Jun 07 00:38:24 greg-inspiron5767 systemd[1]: mnt-nas-TRUENAS.mount: Failed with result 'exit-code'.
Jun 07 00:38:24 greg-inspiron5767 systemd[1]: Failed to mount NAS Data mount.
❰greg❙~❱✘≻ 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❙~❱✔≻ 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/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

What have i done this time :frowning: all i did was try to add another smb share but i didn’t touch this one? I have removed the other one now but this still wont mount on boot again.