I have a Fat32 external hard drive plugged into my server at home and since upgrading to Ubuntu 10.04 (from 8.10 - it was a bug jump!) I've been having permissions trouble with it.
It used to be mounted as root automatically and I think the permissions were pretty much 'ignored'. Since the upgrade, it is being mounted with the group and owner being my user. Obviously, I need access as my user and this is no problem still. However, I am also running a PHP script (via apache) that serves certain files to authenticated users. This is now no longer working.
If I run PHP as my user there is no problem (obviously). However, when running under www-data it cannot access the drive so my script is now failing.
The permissions on the drive look like this at the moment:
drwx------ 1 adamnfish adamnfish
-rwxrwxrwx 1 adamnfish adamnfish
for folders and files respectively.
It's very clear what the problem is (only adamnfish can access the drive!) but I have no idea how to fix the problem. I've tried mounting the drive every which way and even using GUI tools to try and set the bitmask properly!
The hard drive is always plugged in, but sometimes I kick its power cord while tidying up (so the solution needs to be resilient to plugging / unplugging the drive) and I reboot the machine from time to time (so ideally it'll be an fstab entry or something so I don't need to manually unmount and remount with the correct permissions every time).
Thanks in advance, I know this will be obvious to a lot of people but I've been pulling my hair out!
Please read this Ubuntu wiki entry, especially the part about fstab and its options: https://help.ubuntu.com/community/AutomaticallyMountPartitions
The important thing to understand is that you actually specify the permissions on the mount location, for example /mnt, and the device that will be mounted to that mount location will have those permissions. So just add an entry to fstab that mounts your fat32 disk to /mnt for example end set the correct permissions on that folder.
There is also a handy tool for managing storage devices that you might like, called pysdm: http://pysdm.sourceforge.net/