2

I had this idea about mounting disk drives among different users. I would create a folder called say /media/diskXYZ . Then I would make a softlink from /media/user1/diskXYZ to /media/diskXYZ , and from /media/user2/diskXYZ to /media/diskXYZ . The intention is that two users can have the disk mounted at the same time, and programs that have a folder name hardwired in will work whichever user mounted it. I didn't want to do it because I wasn't sure if it was safe.

  1. Will it work?
  2. Is this safe?
3
  1. Will it work? The answer depends on how the permissions are set on the folder. No matter if it's linked or not, if the user is not privileged to access the directory, the user will not be able to.
  2. Is this safe? It's safe if it does work, but you probably want to do this the correct way.......

How to mount a device so that other users have access to it:

First, with the device unmounted, make an entry for the device on a new line in /etc/fstab, making sure that there is still a final new line at the end of the file. It should look something like:

UUID=<uuid> /media/<mountpoint> ext4 user,defaults 0 1

Or:

/dev/XYZ /media/<mountpoint> ext4 user,defaults 0 1

Replace <uuid> with the UUID of the drive, <mountpoint> with the directory under /media that you want it to mount in, and /dev/XYZ to the device's name.

Second, make a new group and add the two users to it with:

sudo groupadd <group name>
sudo adduser <user1> <group name>
sudo adduser <user2> <group name>

Then make sure the mountpoint is owned by the group:

sudo chgrp -hR /media/<mountpoint> <group name>

Mount the drive with sudo mount /dev/XYZ or reboot.

This method will avoid messing around with symbolic links!

  • Perfect answer! Just one small correction: In my case it is not: sudo chgrp -hR /media/<mountpoint> <group name> But: sudo chgrp -hR <group name> /media/<mountpoint> Thanks for the cool description! – benjamin10 Apr 16 '18 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.