I have a rather odd issue with my SMB share that’s hosted off of a computer in my living room (running latest Mint currently). I’ve attempted to add the Samba share to the fstab entry on my Manjaro laptop as follows:
When I either boot up or boot down the machine, I get a message in my terminal after the X session closes that there was a “Failure to mount /run/media/userSambaShare” and that a “Dependency fail for remote file system”.
What’s odd though is that as soon as I’m booted into the system, if I just run sudo mount -a, it mounts the drive without any complaints, and I have proper read and write access.
Here is the drive configuration on smb.conf on the Mint/Samba host machine:
path = /media/user/SambaShare
writeable = yes
read only = no
guest ok = yes
create mode = 0777
directory mode = 0777
valid user = @user @sambashare
Please let me know if there are any other outputs, information, or configurations you would like to see - I was unsure what else would be useful for this.
Do not use this folder. It should only be used for automatic temporary mounts done by programs like your file manager. Also the /run/media/$user folder is not available at startup. It is dynamically created after you log in.
Use a mount point in /media/ or a similar folder, but not in /run
Thank you, I attempted to create a mount point both in /mnt/Media as well as /media/user/Media to point the fstab mount to that folder, but the same error persists. I also attempted editing fstab to include username= and password= instead of using the credentials file, but that did not have an impact either.
‘sudo amount -a’ still works if I run it in terminal right after I log in, and is now mounting to /media/user/Media. I don’t know what fstab is trying to do on boot that isn’t jiving with the way this is set up.
You should add the _netdev Option. Also are you connected via a Ethernet Cable or via WiFi. If you use WiFi make sure it connects before you log in. Also make sure your network-online.target works correctly (Is started by an appropriate service).
So far no change on behavior. I’m not sure if you think I should alter something with the networking services (or I guess how to do it). I agree with you that based on the behavior, it seems like cifs is trying to mount the network drive before the network is actually up.
That is often a problem. In NM, make sure you store your Wifi password unencrypted (for all users). Otherwise you need to login before your Keyring is open and the password can be used.
Check the status
systemctl status network-online.target
It should show if it is active and since when. The time can be compared to the failed mount.
Sometimes it is easier to cerate a mount unit and don’t use the fstab at all. With a mount unit, you can use the automount feature. And even if you don’t want to use the automount, you can easily delay the mount with a mount unit a few seconds, so it always works.
If you connect your system to different Wifis, a NM dispatcher Script can also help you, to only try to mount if you conned to your Home network.
Thank you, this took me a little bit to figure out as it’s my first time mounting drives in this fashion. It does seem to work appropriately now, I get no errors on boot up or shutdown, but it does seem that mounting the drive in this manner adds quite a lot of time to boot up. I’m not sure why it’s slower than the fstab method, but oh well.
For future reference if anyone has similar issues and reads this in the future, these links were also useful to me and include more examples and info on systemd unit mounting:
(I cannot post URLs, please search Github for Akiross post on " Automount of CIFS (smbfs) folders w/ systemd")
Another blog post is located on michlstechblog under the title " Systemd: (Auto-) Mount cifs shares"
And this is what my /etc/systemd/system mount and automount files looked like at the end: