Mounting disk drives among different users

9,499
  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!

Share:
9,499

Related videos on Youtube

ike
Author by

ike

*Insert illuminating and entertaining about me here *

Updated on September 18, 2022

Comments

  • ike
    ike over 1 year

    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?
  • benjamin10
    benjamin10 about 6 years
    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!
  • Admin
    Admin about 2 years
    I don't know why, but for me sudo chgrp -hR /media/<mountpoint> <group name> did not work. However, using the GUI did. That means right click on /media/<mountpoint>, select properties and adjust the entries for group and access.