Page 1 of 1

enabling only one user to mount external HD

PostPosted: Jan 8th, '19, 22:48
by vincentm77
Hi everyone,

I have an external hard-drive, which i want only one user (userA) to be able to mount and to have access (read/write) to.

How can I enable the hard drive to be mounted automatically when it is plugged under a session opened by userA ?
All other users should not be able to mount and/or have any access to the HD.

usually the HD mounts to /externalHD

I have tried to edit fstab but i didn't find a solution yet.

Any help ?

Thanks
Vincent

Re: enabling only one user to mount external HD

PostPosted: Jan 10th, '19, 02:27
by benmc
Not something I have done, but I have certainly done the reverse ;) .

when "user A" has the device plugged in, open your file browser /manager, right click the directory for the external device, edit properties / permissions / ownership to allow only the "user A" to have read / write access.
(un)fortunately, anyone with super user access will be able to access and modify any files on that external device.

Re: enabling only one user to mount external HD

PostPosted: Jan 17th, '19, 17:38
by filip
One workaround is to create a directory with permissions only for userA and to use that directory for all nonshareable files.
Other possible one is to use bind mount in the /home/userA/somewhere.

A part from my RPI USB HDD setup:
Code: Select all
$ cat /etc/fstab
# [Device]               [Mount Point]               [File System Type]   [Options]                     [Dump] [Pass]
# USB HDD /dev/sda1: UUID="your-UUID"
UUID=your_UUID          /mnt/with_only_root_access      ext4            defaults,noatime,nofail    0      2

# and then bind mount:
/mnt/with_only_root_access   /home/me/somewhere         none            bind,nofail                0      0

Please note the nofail option to not stop the boot.