Mount USB drive with write permissions for everyone or specific user

Solution 1:

Your problem seems to be about the permissions you have set. FAT / FAT32 formatted drives don't support file permissions. The permissions for everything are determined by how the drive is mounted. When you set the permission open it worked when you

server# sudo mount /dev/sdb2 /home/storage -o umask=000

As for it not auto mounting on reboot

UUID=8C52-C1CD /home/storage auto user,umask=000,utf8, -->noauto<-- 0 0

The "noauto" makes this NOT automatically mount when the system starts and parses the /etc/fstab file. Remove that option and it will mount on startup. You can set the permissions on the mount point once it's mounted with chmod or specify them in /etc/fstab.

If you need the media user to access it, you can set the permissions to 764, and add them to the security group. Root always has access to everything.

see http://www.linux.org/threads/file-permissions-chmod.4094/ for some examples of propper file permissions

On a side note, bodhi.zazen made a good point Is there some reason you need to use FAT ? If not, I would back up the data and use a linux native file system. You can then set ownership and permissions.

Solution 2:

Note: as mentioned in the comments below, be careful using 0777 permissions: it means anyone, or any script, on the machine can write to the drive. With that caveat in mind, this can sometimes be a useful fix in a pinch:

You can also run

sudo chmod 0777 /home/storage

Since FAT drives don't have permissions, linux applies the permission of the mount point to the entire drive.

Solution 3:

Unless overridden by mount options GID= or UID= the owner and permissions of the mount point upon mounting become those of the filesystem tree being mounted.

So if /dev/sdb1 contains an ext4 filesystem (say a backup) owned by user then user will become the owner of the mount point upon successful mount.

Starting off we have an empty folder 'backup' to serve as the mount point, and is owned by root.

# ls -alR /mnt
/mnt/:
drwxr-x---  5 root root 4096 May 30 20:59 ./
drwxr-xr-x  3 root root 4096 Dec  5  2015 ../
drwx------  2 root root 4096 Jan  1 07:45 backup/

/mnt/backup:
drwx------  2 root root 4096 Jan  1 07:45 .
drwxr-x---  5 root root 4096 May 30 20:59 ..

now we mount /dev/sdb1 (read-only)

# mount -o ro /dev/sdb1 /mnt/backup

and lets see...

# ls -alR
/mnt/:
drwxr-x---  5 root root 4096 May 30 20:59 ./
drwxr-xr-x  3 root root 4096 Dec  5  2015 ../
drwx------  2 user user 4096 Jan  1 07:45 backup/

/mnt/backup:
drwx------  2 user user 4096 Jan  1 07:45 .
drwxr-x---  5 root root 4096 May 30 20:59 ..
-rw-------  1 user user 252076021760 Jun  9 21:11 backup.tar

Now if you've got an empty drive and you want to mount it for 'user' as an extension of 'user's disk space, mount the drive as root, chown the root of the mount to 'user' and unmount.

The next time the filesystem is mounted (by root or anyone as per fstab) the owner of the mount will be 'user'.