1

My computer has two hard drives. Ubuntu is installed on the first drive and the second drive (i.e. /dev/sda1) will be used by many users to store data. What is a proper way to mount this drive? That is, how can I mount this drive so it would satisfy all the following criteria?

  1. The drive must be named "Drive2"
  2. It would appear under the main drive as indicated in the figure below (and if possible, not as a mounted drive on a folder in the root directory, e.g. /Drive2).
  3. All users would have access to it.
  4. Each user would get a folder with their username (there are more than 30 users, so I hope this can be done automatically).

Shows a folder view highlighing the "turtle" folder

The following is not a requirement and I don't know if it is possible. If it is, I am very curious to know how would one set up this drive for the following two separate cases:

  1. non-sudo and sudo users can only view their own content.
  2. sudo users can view everyone's content but non-sudo users can only view their own content.

To clarify, I am not just asking how to mount a drive, but I am also looking for insights for systematic and secure file management system for secondary or external hard drives.

11
  • What does this non-sudo and sudo users can only view their own content mean exactly? Commented Nov 1, 2017 at 5:24
  • I can give a setup that satisfies all, except #2... an auto mount drive doesn't show in the locations list, because it is in the file system. Or if in the locations list, clicking it would take all users to the top directory of the disk. It however can be mounted anywhere we want.
    – ravery
    Commented Nov 1, 2017 at 5:30
  • And where will this be mounted as you said it should be in / will somewhere in /home/$USER be ok? Commented Nov 1, 2017 at 5:36
  • @George, for instance, if you are a non-sudo user, you cannot view the content of ~/ for there users. But a sudo user can check and change the content of, let's say, other users Desktops.
    – Miladiouss
    Commented Nov 1, 2017 at 5:43
  • @George, I'm not very familiar with file management on Linux. Can you explain what happens if I mount it in /home/$USER? How does this affect all users? Does this automatically take care of criteria #4?
    – Miladiouss
    Commented Nov 1, 2017 at 5:47

1 Answer 1

-1

Step 1 -- Setup Drive

Use gparted to partition the drive. Make one partition covering the entire drive with the label "Drive2" and formated to ext4. Make note of the UUID for the partition.
Next, setup auto-mount. Make a folder for a mount point: sudo mkdir /mnt/drive2
Then add the following lines to /etc/fstab

#Drive2 automount
UUID=<UUID from above> /mnt/drive2 ext4 defaults 0 2

Reboot to test the auto-mount.

Step 2 -- Setup Folders

If auto-mounts works, open a terminal and type cd /mnt/drive2
I chose to set normal users with access to only their folder, and give sudoers access to all folders. I do not know a way to do this automatically; perhaps someone could make a script.
Repeat the following commands for each user. Replace "user1" with the actual user name.

 mkdir user1 #sudo might be needed.
 sudo chown user1:sudoers user1
 sudo chmod 770 user1  #user and sudoers full access, other no access
 ln user1 Drive2 #sudo might be needed again
 sudo chown user1:user1 Drive2
 sudo mv Drive2 /home/user1

Your users should now have a folder named "Drive2" in their home directory that links to their folder on Drive2. For ease of access, a link for /mnt/drive2 can be made and copied to all the sudoers.

Notes:

With this setup, sudoers will be able to add files to user's folder, and delete files they created. But may only be able to view files created by others because default file settings are user:user 755 (maybe 754). And vis-a-versa. Though sudoers should be able to change permissions and owner.

7
  • what flag should I choose on gparted?
    – Miladiouss
    Commented Nov 1, 2017 at 23:22
  • no flags are needed
    – ravery
    Commented Nov 1, 2017 at 23:24
  • UUID=<UUID from above> /mnt/drive2 ext4 defaults 0 2 messed up my computer. I had to boot as root to fix it. I think what you intended to say was: /dev/sdXX /cmnt/Drive2 ext4 defaults 0
    – Miladiouss
    Commented Nov 2, 2017 at 0:11
  • no, use the UUID that you recorded from the partition you made. if it crashed the boot then you incorrectly copied the UUID
    – ravery
    Commented Nov 2, 2017 at 0:25
  • 3
    So many things bad with this I don't know where to start...
    – fkraiem
    Commented Nov 2, 2017 at 1:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .