this post was submitted on 02 Jul 2025
10 points (100.0% liked)

Linux

11774 readers
67 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 2 years ago
MODERATORS
 

Hi! Got an issue I couldn't figure out

When I use /etc/fstab to automount an SMB share using CIFS, I cannot unmount it without root privileges. If I mount it manually (as a non-privileged user), everything works just fine.

Also, an application I mount the share for (Pika Backup, based on borg) cannot access backups unless I unmount the share with root privileges and then mount it back manually.

A respective line in /etc/fstab is: //address/directory /mnt/backup cifs credentials=...,user,auto,iocharset=utf8 0 2

Highlighted user option to make it clear I didn't forget it.

Any advice?

top 7 comments
sorted by: hot top controversial new old
[–] MentalEdge@sopuli.xyz 5 points 5 days ago* (last edited 5 days ago) (1 children)

The option you're looking for is users, not user.

user makes it so that any user can mount, but only the same user can unmount. Meaning, since root is mounting it on boot, root has to be the one to unmount it, too.

users allows any user to mount, and any user to unmount.

Not sure what's on going with Pika. Who mounts the share shouldn't matter, as the folder permissions should be the same regardless.

Do you have a uid option set?

[–] Allero@lemmy.today 2 points 5 days ago (1 children)

It worked, you nailed it! So, the problem was that with automount it was root that was mounting, which ended up breaking permissions. As a result, I could not unmount the drive, and Pika couldn't do backups. After setting the uid, it started to work properly as it began mounting under my name. As such, changing user to users was not required. But now I know the difference, so thank you anyway!

Case closed, and thank you again.

[–] MentalEdge@sopuli.xyz 1 points 5 days ago* (last edited 4 days ago) (1 children)

Ah. That's right. You need to use the uid as the network share doesn't have permissions the way a local partition would. Normally it's unneeded, as the drive, folder and file permissions are set on the drive, and those are the ones that matter once it is mounted.

Note that the uid only sets access permissions. It does not actually mount the share as you, so you'll still need to be root to unmount it, unless you change user to users.

[–] Allero@lemmy.today 1 points 4 days ago

Aha, caught that one, and indeed, you are right. Unmounts correctly now!

[–] who@feddit.org 1 points 5 days ago* (last edited 5 days ago) (1 children)

Have you considered replacing auto with noauto, and creating a .desktop file in ~/.config/autostart/ to run the mount command when you log in?

I do this, and it allows me to unmount (and mount again later) as myself rather than as root.

[–] Allero@lemmy.today 1 points 5 days ago (1 children)

Should work, though MentalEdge proposed a more elegant solution. All it took was setting uid in /etc/fstab.

Maybe it could help you, too?

Thanks anyway for your response!

[–] who@feddit.org 2 points 5 days ago

I have a more complex setup than I described, making that approach a poor fit, but thanks for thinking of me. Glad you found a solution. :)