I've attached a SSD disk though USB. Then:
sudo su -
mkdir /mnt/hx
chown ondra /mnt/hx
mount /dev/sdb1 /mnt/hx # It's FAT32 now, but was the same with EXT4
The last command changes dir owner to root. Whenever I create a file in the root dir, I need to be root and root is the owner.
Can I set different user as owner of the mounted dir? Or, simply said, ensure that user XY can freely read/write on the drive.
Gnome-based GUI environment
Easy as that.
For older versions of Gnome you may need to use
gvfs-mount
instead:Headless (no GUI) machine
Add an entry in
/etc/fstab
and specify options for it.From the manpage of
fstab
:Now you'll need to make sure the device is owned by the correct owner. Specify that in an
udev
rule. Put a file in/etc/udev/rules.d/50-myhdd-ownerchange.rules
:Replace the vendor and product ids with the USB device you want to get triggered by it. Find them using the command
lsusb
. Also change theMODE
if you like.Alternatively, use
pmount
. I don't like it, personally.