Thursday, 20 June 2019

permissions - Linux - Mount device with specific user rights


How can I mount a device with specific user rights on start up? I still have some problems figuring it out. I would like to mount the divide with uid=1000 and gid=1000. My current entry to the /etc/fstab/ file looks like this:


dev /var/www vboxsf rw, suid, dev, exec, auto, nouser, async, uid=1000

Answer



To mount a device with certain rights, you can use the -o Option directive while mounting the device. To mount the device you described, run:


 mount -t deviceFileFormat -o umask=filePermissions,gid=ownerGroupID,uid=ownerID /device /mountpoint

For example mounting a VirtualBox shared folder to /var/www with www-data as owner would look like this:


mount -t vboxsf -o umask=0022,gid=33,uid=33 dev /var/www

If you want to mount the device on startup, you can add the following entry to your /etc/fstab file:


 /device /mountpoint deviceFileFormat umask=filePermissions,gid=ownerGroupID,uid=ownerUserID

Again, with the same example the entry to the /etc/fstab file would look like this:


dev /var/www vboxsf umask=0022,gid=33,uid=33

For filesystems that does not support mounting as a specific user (like ext4) the above will give the error


Unrecognized mount option "uid=33" or missing value

to change the owner of an ext4 mount simply run


chown username /mountpoint

after it has been mounted.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...