Page 1 of 2

USB Drive Permissions

Posted: 6. Sep 2010, 14:56
by laprjns
Why are USB drives formatted with different file systems mounted with different permissions? Take for instance the below screen-shot. The USB drive who's file permission are shown on the left is formatted to ext2, while the drive shown on the right is formatted as FAT. The results is that a normal user cannot write to the USB drive on the left while they can write to a FAT formatted drive on the right.

Image


I realize that this is the result of the udev rules, but I would have expected that all USB drives, no matter what file systems they are formatted with, would mount the same way, i.e. with the same permissions. Also,I would expect those permission would allow a normal user to write to the USB drive.

Code: Select all

/dev/sdb1 on /media/Blue_PECC_1M type ext2 (rw,nosuid,nodev,uhelper=hal)
/dev/sdc1 on /media/disk type ext2 (rw,nosuid,nodev,uhelper=hal)
/dev/sdd1 on /media/disk-1 type vfat (rw,nosuid,nodev,uhelper=hal,uid=1000,shortname=winnt)
Regards
Rich

Re: USB Drive Permissions

Posted: 6. Sep 2010, 16:02
by gapan
Linux filesystems are aware of user permissions and will transfer those permissions to any pc the mediums are attached to. If the filesystem belongs to root, nobody else can mount it. If the filesystem belongs to a user "foo", plugging the device to another PC that has no user "foo", you won't be able to write to it. FAT* partitions are not aware of user permissions. As a workaround ownerships are being set when mounting. So wherever you plug them in, they give write permission to the currently running user.

Re: USB Drive Permissions

Posted: 11. Sep 2010, 11:49
by laprjns
Ok, i understand that, but I still don't understand why. On Linux, administrative privileges are required to partition and format a USB drive, so unless specific action is taken to change the owner and/or group it will be formatted with root:root privileges. This makes any disk formatted with non FAT fs useless for normal user. Further more, if the normal users doesn't have access to root privileges he can't even format disks. This in my opinion leaves only FAT as a viable fs for USB drives used as portable media.
So I guess my question is why not allow normal users to mount USB drives with read/write privileges.
Thanks
Rich
ps. where floppy disks also handle this way?

Re: USB Drive Permissions

Posted: 11. Sep 2010, 11:55
by thenktor
AFAIK normal users are not allowed to format anything.

Re: USB Drive Permissions

Posted: 11. Sep 2010, 12:06
by Shador
I think it's not a question whether normal users are allowed to format anything, I think the reason why you can't format as a normal user is because you don't have direct access to the underlying block device. I just checked with a removable drive which gets rw permission for the group plugdev and as normal Salix users are in that group, I guess you can even format removable drives.
laprjns wrote:So I guess my question is why not allow normal users to mount USB drives with read/write privileges.
I don't see your problem here, they can mount USB drives. I got no stick with formatted with a linux fs for practical reasons. But if you've got the permission to write to the directory the stick is mounted on, you can put any file on it. There's one problem though. It won't store your username on the drive, it stores your uid. So if you mount the stick on another computer and try to access it as a user with the same username but a different uid, you don't own those files anymore.
The only way around such an issue would be globally standardized users/groups but this is unrealistic.

Re: USB Drive Permissions

Posted: 12. Sep 2010, 09:48
by mimosa
I have an 8 GB memory stick formatted with fat that will not allow me to save anything over 4 GB - something to do with maximum address space under fat? Looking through previous posts, several people seem to have come across similar permissions problems when using native linux filesystems on USB drives. Given that the point of USBs is to facilitate the access and transfer of dara, this way of doing things seems less than ideal. I've had similar problems in other distros, but not all.

Re: USB Drive Permissions

Posted: 12. Sep 2010, 09:56
by Shador
mimosa wrote:something to do with maximum address space under fat?
http://en.wikipedia.org/wiki/Fat32
mimosa wrote:Given that the point of USBs is to facilitate the access and transfer of dara, this way of doing things seems less than ideal.
Which way of doing things?

Re: USB Drive Permissions

Posted: 12. Sep 2010, 11:17
by mimosa
Which way of doing things?
Well, it would be great if all filesystem types were treated like fat, i.e.
wherever you plug them in, they give write permission to the currently running user
then you could just use USB drives without having to worry about permissions. It does seem to be something that causes a few headaches, perhaps more for inexperienced users, judging from the posts in the forum on similar topics. I have read through these but they didn't leave me with a clear idea of how to deal with such issues better. Probably I need to go away and mug up on permissions - but it would be nice if it "just worked". For instance, that is the case in Puppy, but only because Puppy runs as root, and I know that's a sledgehammer to crack a nut.

Re: USB Drive Permissions

Posted: 12. Sep 2010, 12:38
by laprjns
First of all, I apologies for posting this in the "Problem" forum. Although I do view it as a problem, since it's more of a result of a Linux philosophy ( and i guess Unix) in general, I was really seeking out the reasoning behind this, not a solution. I have no problems if a moderator wishes to move it to another, more appropriate forum.

It's seems that both mimosa and I agree that we would expect, as "users" to plug in a USB stick or floppy disk and regardless of it's file system be able to save a file. Right now, this can only be done with a FAT formatted disk, which from the explanation provided seems like its a unavoidable "necessary evil". So, if there were no FAT fs, then Linux users could not use removable media at all without su'ing or sudo'ing to root privileges; which I thought was something that was to be avoided.
Regards
Rich

Re: USB Drive Permissions

Posted: 12. Sep 2010, 13:18
by mimosa
Thinking about it, permissions issues in general - for instance, involving hard disk partitions - are something I have never really managed to get on top of. The question is, is this something that every new Linux user needs to make a considerable effort to learn to manage effectively - i.e. there is no easy way and no way to make it easy - or would it be desirable to make it more user-friendly for newcomers to Linux, and indeed general everday use, as in "I just want to copy my files"? It's something that seems to cause a lot of frustration and must put many people off completely at an early stage. Is there a deep intrinsic reason why it's so hard? Or is it actually not as hard as some of us think?