(The following is from the MailingList. It’s a description of how to mount USB devices that use the vfat filesystem. So this will typically include USB-keypens, MP3 players, digital cameras, etc.)
It’s probably a FAT-based filesystem on the USB device (it is on most USB devices). FAT doesn’t have the concept of file ownership, and the few (4) permissions bits that FAT knows about don’t map on to the (at least 9) bits that UNIX filesystems expect. As a result, FAT filesystems mounted in Linux assume a fairly restrictive set of file permissions.
You need to use the uid, gid, umask, dmask and fmask options to “mount” to change the default set of permissions. You can put those options in the fstab for the device, or supply them manually if you mount it as root:
# mount /dev/sda1 /usbkey -o uid=lisi,gid=users,fmask=117,dmask=007
uid= and gid= should be self-explanatory. fmask is the set of permissions bits not set for files (so should give you rw-rw
). dmask is the set of permissions bits not set for directories (so should give you rwxrwx—).
But I would recommend making a new group called “usbreader” or somesuch, and putting yourself in it, and then adding
gid=usbreader,fmask=117,dmask=007
to the options field in /etc/fstab
Note that changing the permissions on the device node has nothing to do with changing the permissions (or apparent permissions) on the filesystem stored on the device represented by that device node. A device node (/dev/sda1) represents the basic raw storage of a device, and permissions on that are used to control who can (for example) use that device as a parameter to “mount”. The permissions you see after mounting are the permissions implemented by the _filesystem_, which is a complex data structure stored in the device.
It can be rather confusing, particularly when people (as they usually do) conjoin the concepts of the filesystem and the device. When you say “I mounted /dev/sda1 on /usbkey”, you really mean “I mounted the filesystem stored on /dev/sda1 on /usbkey”. If you have the relevant permissions on /dev/sda1, you can mount the filesystem; that doesn’t necessarily give you the ability to *read* what you’ve just mounted, as the filesystem then implements its *own* set of permissions for access to its contents.
Hugo.
(edited)
Leave a Reply
You must be logged in to post a comment.