Can I mount a device accessible for all users?

I have a PC with multiple users. The PC also has an extra HDD besides the boot/root drive.

How would I go about mounting this drive at boot (or rather at login, I guess…) to /home/$user/extradrive and making the content of the drive readable+writable for each $user?

Hi @muvvenby,

For that uou’d have to put an entry in /etc/fstab similar to the following:

UUID=c47c5a52-db30-4aef-bcbc-af35b7b021fd       /mnt/4TB        ext4    defaults,noauto 0 1

Obviously the UUID= is unique to your harrdrive and can be obtained with the blkid command. Also use your own custom mount point (/mnt/4TB i this case.)

Ah, mounting it under /mnt kinda works. The drive shows up for all users, but it doesn’t show up like a drive or a (home)folder in the filemanager. In the filemanager I have to dig down from the root into mnt and then the directory where the drive is mounted.

Also, all the files are still owned by one of the users, so other users can not rename files, for example.

OK, I have never done multiple users or NFS (have done a few SAMBA shares, though.)

What I would have done in that case is either

  1. make a symlink for the user to the directory after it’s mounted; or (and I’ve only recently learnt about this, never done it)
  2. create a bind mount for the user to the drive. This might actually be a better option, but as I’ve said, I’ve never done this before. This can and should also be done in the /etc/fstab file.

Now that I’ve thought about it, for longer than a minute, #1 there is actually how my home directory is configured. My root is a 250GB SSD and I store all my data on a separate 5TB (The 4TB isn’t in use at the moment. Don’t think It’ll ever be again, because it’s got bad sectors, hence the 5TB one.)

In the mount unit Options - add the option x-gvfs-show

1 Like

@muvvenby well easy method is just mount it with defaults and change the permissions:

sudo chmod -R 777 /path/to/mountpoint

Then everyone can read and write.

On top of what @linux-aarhus said,

As I mentioned in a similar topic in past, to enable any user to be able to modify files/dirs created by other users you should use:
setfacl -R -m g:users:rwX,g:1000:rwX,d:g:users:rwX,d:g:1000:rwX /path/to/mountpoint

This will make sure new files/dirs created will be modifiable by all users inclusive the first one which is not in the users group by default…

Thanks @linux-aarhus! Finally found/made the time to really use and understand systemd mounts. Indeed, a very nice solution and it would have taken a long time for me to discover x-gvfs-show on my own, but it does what it says on the box! :smiley:

I’m almost there… I tried @TriMoon’s suggestion to set the ACL, but that does not appear to work. It doesn’t reset the current ownership of existing files and doesn’t change the ownership of newly created files. I tried running it without and with sudo.

I read the manpage for setfacl and I see what it tries to do and I can’t see any immediate problems with it.

The one thing that I can think about, is that I don’t seem to have a group named users on my system:

$ groups
sys network power autologin video storage lp input audio wheel $username

$ groups $username
wheel audio input lp storage video sys network power autologin $username

(note: $username obviously is my system username; same results apply for the other users on this PC)

So, if setfacl is working on the system groups, that would explain why it fails. I don’t know enough about how it functions to know if there should be a group users on my system or if g:users is some sort of shorthand for referencing all users.

I am on a PC with Manjaro installed through Architect with a full Cinnamon DE install (from quite a while back).

That command is not meant to change ownerships, it is meant to make them r/w for all users…

Besides groups and groups $username will output same groups if you execute them as $username :wink:
About the users group: I thought that was a default group added by Manjaro? :thinking:

>  grep -w "users" /etc/group                                                                                                  

Ah, but that does not work either. Files on the drive owned by User_A are r/w for User_A but not for User_B and vice versa.

That’s because as you said you are lacking the users group…
What group are your users created when you create a new user account?

When I create a new standard user, it has groups autologin,$username. That’s all.

Well in that case your system is configured to create per-user groups with same name as account name.
You could change every users into autologin in this case…

1 Like

Thanks for spelling it out! I figured as much when I noticed I didn’t have the users group. Now it works.

Marking @TriMoon’s post as solution, but couldn’t have done it without @linux-aarhus’s help, so thanks Frede!

1 Like

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