CIFS mount in /etc/fstab will not auto-mount upon restart

scurrier

Active Member
Sep 9, 2017
15
2
43
72
Hello all,

New to proxmox and loving it on my Supermicro server with Xeon D-1541.

I am having trouble with auto-mounting a CIFS share from my NAS, though. I have the following line in the node's /etc/fstab:

//mynas/media /mnt/bindmounts/media cifs rw,credentials=/home/.smbcredentials-mynas,vers=3.0,noperm,auto 0 0

When running mount -a manually, it mounts no problem and stays mounted. But upon restart, it does not automatically mount. Suspecting some kind of issue with the network interface not being up when attempting to mount, I have tried adding the _netdev option to remedy this, but to no avail.

It's not an issue if the mount is delayed by a few minutes, but I really want it to come up automatically so I don't have to manually mount it when restarting.

Any ideas why it is not automatically mounting or what to look at to troubleshoot it? Or some way to delay the mount by a small amount of time to give the rest of the system time to come up?

Thanks for this great software product.
 
As fast workaround you can use a extra sleep in rc.local.
Code:
cat /etc/rc.local

sleep 8
mount -a
 
  • Like
Reactions: scurrier
Thanks. I do not actually se an rc.local in the /etc directory. Should I just create it and it will run?

Any insight into what the actual problem with the /etc/fstab entry might be?
 
Hi scurrier!

Since systemd made it into debian, a few things have changed and not everything is working 100% correct in my opinion. Probably it is loading your mount too early with your network not even ready mounting it correctly.

Give it a try and look in your syslog for an error.

Edit: Try this in your parameter: x-systemd.automount,x-systemd.requires=network-online.target

It's German but can translate it: https://www.elektronik-kompendium.de/sites/raspberry-pi/2102201.htm
 
Last edited:
Hi all,

Thanks for your replies. I have not yet implemented the workaround rc.local solution yet. Although I appreciate it and may have to resort to it, I feel it is a hack. I'm not trying to do anything exotic here, just a vanilla cifs mount. And now an nfs mount, which is also failing...

I have added an nfs mount to the fstab and found that it actually prevents the system from booting normally because it fails to mount. I searched and found this comment thread (http://thenubbyadmin.com/2013/04/10/solving-nfs-mounts-at-boot-time/) which contains this command (systemctl enable systemd-networkd-wait-online.service) which runs on proxmox. It seemed to extend the timeout on mounting the nfs share, but sadly this did not help and it still prevents the system from booting normally.

With both the nfs and cifs shares, after they fail to mount at boot, running mount -a immediate mounts them both easily.

I tried Oliver R's suggestion of adding the following options to the cifs mount, and it does indeed seem to mount after booting. The exact timing is not critical in this case, so I am keeping it, but recognize that it may not be truly mounted before other apps are auto-started.
x-systemd.automount,x-systemd.requires=network-online.target

The same options don't work for the nfs mount and keeps the system from booting normally.

Who knew that booting with network shares mounted was so hard?
 
Use service and not fstab.

Create the unit file in /etc/systemd/system/
with the name format: mnt-path.mount

then systemctl enable mnt-path.mount
and systemctl start mnt-path.mount

Fstab is horrible.

[Unit]
Description=CIFS Mount
Requires=network-online.target
After=network-online.service
Before=nginx.service

[Mount]
What=//xxx.xxx.xxx.xxx/path/anotherpath
Where=/mnt/path
Options=username=yourusername,pass=yourpassword
Type=cifs

[Install]
WantedBy=multi-user.target
 
Hec,

That's a new and interesting option to me. I'd like to learn systemd better so I can understand it. Thanks for raising this possibility.

All,

Can anyone point to evidence of what the Debian devs think the proper solution is? I'd hope there is one endorsed method that if it doesn't work then something is wrong.
 
Welp. For my NFS problems, it seems to have been caused by bad options in the fstab file (my fault). I had a username and password in there and apparently NFS authenticates by IP, not credentials. I'm a newb and I didn't expect that. Shame on me. Some extensive reading of the debian nfs mount docs led to the interesting observation that there were no username and password options, which put me on the right path.

Thanks to Oliver R and his suggestion of using the x-systemd.automount,x-systemd.requires=network-online.target options for CIFS in the fstab, it's not working great in my application. Still don't know why it didn't work without these options.
 
Hello all,

In 2022 im new to Proxmox but not that new to linux. So after some googling and typing my Backup Server 2.1-1 is mounting my network shared folder with the following line in /etc/fstab
//20.0.0.54/Backups /mnt/ZFSSat cifs rw,soft,uid=34,gid=34,file_mode=0775,dir_mode=0775,credentials=/root/.smb 0 0

Notice that you need to create a /root/.smb file with the following two lines:
username=usernameofthecifsshare
password=passwordofthecifsshare

mount -a and also reboot results in the share mounted Succesfuly.

Hope it helps anyone.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!