The Fat32 filesystem does not contain linux permissions, so you can't use the chmod command. You need to set the user, group and permissions in the /etc/fstab file.
Use the umask option to allow all users full access. "umask=000" for example.
To mount the partition giving user "locke" exclusive access use the "uid=locke" option with "umask=077"
To demonstrate, let's create a 1/2 Mb file and create a vfat file system on it:
> dd if=/dev/zero of=testfile count=1024 bs=512
> /sbin/mkfs.vfat testfile
Now let's create a place to mount it:
mkdir testdir
Mounting it with umask=000 option:
sudo mount -t vfat testfile testdir/ -o loop,umask=000
mount | grep testdir
/home/username/testfile on /home/username/testdir type vfat (rw,loop=/dev/loop5,umask=000)
ls -ld testdir/
drwxrwxrwx 2 root root 16384 1969-12-31 17:00 testdir/
Notice that user, group and other have full access.
sudo umount testdir
:~> sudo mount -t vfat testfile testdir/ -o loop,uid=jschiwal,gid=jschiwal,umask=007
:~> ls -ld testdir
drwxrwx--- 2 jschiwal jschiwal 16384 1969-12-31 17:00 testdir
:~> sudo touch testdir/file
:~> ls -l testdir/file
-rwxrwx--- 1 jschiwal jschiwal 0 2006-04-22 00:20 testdir/file
Notice that even though root created the testdir/file, that the permissions of the file are inherited from the way the drive was mounted.
You can also use separate fmask and dmask options instead of umask. They allow separate permissions for files and directories. This allows you to use rw- permissions for files and rwx permissions on directories. The "x" permission bit on directories allows someone to enter that directory.
:~> sudo umount testdir
:~> sudo mount -t vfat testfile testdir/ -o loop,fmask=111,dmask=000
:~> mkdir testdir/subdir
:~> touch testdir/subdir/second_file
:~> ls -lR testdir
testdir:
total 2
-rw-rw-rw- 1 root root 0 2006-04-22 00:20 file
-rw-rw-rw- 1 root root 0 2006-04-22 00:19 sample
drwxrwxrwx 2 root root 2048 2006-04-22 00:23 subdir
testdir/subdir:
total 0
-rw-rw-rw- 1 root root 0 2006-04-22 00:23 second_file
I didn't have a vfat filesystem handy, to test this so I created a fat32 (vfat) filesystem on a file instead. In your case, don't use the option "loop".
-----------
If your system uses the udev daemon, I think you can allow access to a usb vfat drive by making yourself a member of the "disk" group.
from /etc/udev/rules.d/50-udev.rules
KERNEL=="sg*", NAME="%k", GROUP="disk", MODE="660"
I'm not absolutely certain of this, and whether this is the purpose of the "disk" group.
Last edited by jschiwal; 04-22-2006 at 12:46 AM.
|