Systemd mount unit error

Similar issue though naming is fine.

● data-smb-qnap_download.mount - QNAP SMB download share
Loaded: bad-setting (Reason: Unit data-smb-qnap_download.mount has a bad unit file setting.)
Active: inactive (dead)
Where: /data/smb/qnap_download/ # unit file name data-smb-video.mount
What: //xxxx/Download
Mär 20 14:35:04 xxxx systemd[1]: data-smb-qnap_download.mount: Where= setting doesn’t match unit name. Refusing.

(tried with and without trailing slash on the where path)

No settings is not fine

The rule is The Where equals the filename

e.g. the Where is /data/backup

/data/backup must be data-backup.mount (no trailing slashes)

If you change the unit file on-the-fly you need to reload

# systemctl daemon-reload

In your case

create the failure - it should be

/data/smb/qnap_download

Example with underscore

➜  system cat data-smb-qnap_download.mount 
[Unit]
Description=Mount test qnap download storage partition

[Mount]
What=/dev/disk/by-uuid/4c580110-ba45-47a9-9578-04ab95ad9ec3
Where=/data/smb/qnap_download
Type=ext4
Options=defaults,rw,noatime

[Install]
WantedBy=multi-user.target

➜  system sudo systemctl start data-smb-qnap_download.mount
➜  system sudo systemctl status data-smb-qnap_download.mount 
● data-smb-qnap_download.mount - Mount test qnap download storage partition
     Loaded: loaded (/etc/systemd/system/data-smb-qnap_download.mount; disabled; vendor preset: disabled)
     Active: active (mounted) since Sat 2021-03-20 15:21:11 CET; 1min 6s ago
      Where: /data/smb/qnap_download
       What: /dev/sdb2
      Tasks: 0 (limit: 77017)
     Memory: 4.0K
     CGroup: /system.slice/data-smb-qnap_download.mount

Mar 20 15:21:11 ts systemd[1]: Mounting Mount test qnap download storage partition...
Mar 20 15:21:11 ts systemd[1]: Mounted Mount test qnap download storage partition.

Thx for your fast reply. But I don’t see the failure. As mentioned I had the where path initially without the trailing slash. With same result. I added the first line with cat... (thougH I don’t know what this does as in your guides template it’s not in there). Did a restart of systemctl daemon, too.

My file named data-smb-qnap_download.mount content:

$ cat /etc/systemd/system/data-smb-qnap_download.mount

sample smb share mount unit

[Unit]
Description=QNAP SMB download share
After=network-online.target
Wants=network-online.target

[Mount]
What=//xxxxx/Download
Where=/data/smb/qnap_download # unit file name data-smb-video.mount
Type=cifs
Options=_netdev,iocharset=utf8,rw,file_mode=0777,dir_mode=0777,user=xxx,password=xxx
TimeoutSec=30

[Install]
WantedBy=remote-fs.target
WantedBy=multi-user.target

resulting in

● data-smb-qnap_download.mount - QNAP SMB download share
Loaded: bad-setting (Reason: Unit data-smb-qnap_download.mount has a bad unit file setting.)
Active: inactive (dead)
Where: /data/smb/qnap_download # unit file name data-smb-video.mount
What: //xxxxx/Download

Mär 20 15:44:01 xxxxx systemd[1]: /etc/systemd/system/data-smb-qnap_download.mount:1: Assignment outside of section. Ignoring.
Mär 20 15:44:01 xxxx systemd[1]: data-smb-qnap_download.mount: Where= setting doesn’t match unit name. Refusing.

“New” error in first line is due to the newly added first cat… line I guess.

Oh wow. I needed to remove the comment in the where line… :roll_eyes:
Now the assignment error is still present but it mounts. Commented the first cat… line removes that “yellow error”. But my mount is empty. :-/

cat is a terminal command to list the content of a file - it should not be present in your mount unit

Also remove the comments - text starting with #

1 Like

Makes sense. As you mention it I remember it. But maybe I’m not the only “beginner”/mainly gui user who is not aware of this?! Copyying it from a template not knowing this.

EDIT: Nvm. It works now =)

Is it possible that mounting this way could delete data ony my NAS???

I’m quite sure not, but that’s the only thing I did and I am sure that there has been files before in that network folder!! :dizzy_face:

You are actually the first …

The mount itself will not change anything - only users with access will do that.

And your mount being empty

  • remember to start the mount unit once (to create the folder) then stop it
  • then enable the automount unit - and when you access the folder it mounts - not before.
1 Like

I did a rm -r earlier on a test mount to /mnt/QNAP-Download. I guess that deleted the files?!
I just wanted to delete the folder - not the (my guess) already mounted content. :-/

So with automount it will not be visible in programs unless they access it? Goal for me is to have this path available so that whenever I need to access it from within a program it is there.

That is correct

That is what the automount does - suffice the network service is available.

The whole idea behind automount is the system does not use resources on boot or hang due to missing network or server issues.

And when/from what does that automount get triggered?
I’ve set up everything now. Started .mount once. Stopped. Started .automount. After this I saw the mount in Dolphin appearing. I then started my application (lbry client) selecting the mount point as the download path. Worked. Did a system restart → lbry doesn’t start anymore; mount appears not inside Dolphin. systemctl status show both .mount/.automount inactive.

It gets triggered by systemd

And for it to work after reboot you will have to enable the automount - named the same way as the mount unit - taking your filename

sudo systemctl enable --now data-smb-qnap_download.automount

Then you can forget about it - systemd will do it’s job in the background

I have completely dropped fstab editing - mount/automount units is much more pleasant to work with.

1 Like

Did the trick. I did just start it before and thought because I “start an automount file” this will enable the autostart… :-/

Hopefully I will never have to reconfigure this again. I will not remember for sure ^^

Is it normal that now the mount appears/disappears for a split second in Dolphin every ~10 seconds? o.O

It’s a bad practice manually configuring/editing (auto)mount entries, the only thing you’ll need to do is creating a new entry in /etc/fstab with the x-systemd.automount parameter ;and afterwards test it if it mounts correctly.
Every (re)boot the corresponding .automount services will startup automatically by systemd checking your /etc/fstab .

So for the topic starter,
for example in /etc/fstab create an entry like:

//xxxxx/Download  /data/smb/qnap_download  cifs  _netdev,iocharset=utf8,rw,file_mode=0777,dir_mode=0777,user=xxx,password=xxx,nofail,x-systemd.automount,x-systemd.device-timeout=1,timeo=14,x-systemd.idle-timeout=1min 0 0

check if it mounts correctly:

sudo mount /data/smb/qnap_download

to unmount

sudo umount /data/smb/qnap_download

If the mounting woks welll, try to reboot, you will see the .automount service is generated and started by systemd

systemctl list-unit-files |grep automount

Please explain - why this - in your opinion is considered bad practice?

1 Like

Would be interested, too @flipper @linux-aarhus

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.