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?
- The drive must be named "Drive2"
- 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).
- All users would have access to it.
- Each user would get a folder with their username (there are more than 30 users, so I hope this can be done automatically).
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:
- non-sudo and sudo users can only view their own content.
- 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.
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
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.
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.