Wednesday, September 2, 2009

Manually Changing FAT permission on USB

FAT32 does not support file permission and ownerships. In order to support permission and ownership, you have to use umask for permission and uid/gid for user and group permission. Basically umask=000 will results in rwxrwxrwx.

# mkdir -p /media/usb
# mount -t vfat -o umask=000,uid=youruserid,gid=users /dev/sdb1 /media/usb

The results will be
drwxrwxr-x 3 youruserid users 12288 1970-01-01 07:30 usb

If you want to mount the usb and only allows yourself and users in the group to view it, you can use umask=007

# mount -t vfat -o umask=007,uid=youruserid,gid=users /dev/sdb1 /media/usb

Notes on umask:

To calculate permissions which will result from specific UMASK values, subtract the UMASK from 666 for files and from 777 for directories.

If you want all files created with permissions of 666, set your UMASK to 000. Alternatively, if you want all files created with permissions of 000, set your UMASK to 666.

No comments: