“Operation Not Permitted” and the FAT-32 System

chown“, “chgrp“, “ln“, and “chmod“, behave oddly on fat-32, vfat, and ntfs file systems.  The “Operation not permitted” message may mean “This type of filesystem does not support that operation”.

Here’s the example:  I want to create a file and own the file.  I can’t seem to do it.

Step 1:  Confusion!  I don’t own the files I create!

chasm@chasm-blue-laptop:/big$ whoami
chasm
chasm@chasm-blue-laptop:/big$ date > today
chasm@chasm-blue-laptop:/big$ ls -la today
-rwxrwx— 1 root plugdev 29 2009-12-22 15:15 today

The created file, /big/today, is owned by user root, and group plugdev.  I can create, modify, and delete the file but I can’t seem to own it.  I had not heard of the plugdev group and Google is not helpful.   The plugdev group manages which users are allowed to use hot pluggable media and FAT-32 media.  Use ‘grep plugdev /etc/group’  to see who is in the plugdev group.

Step 2:  Failures and Bad Error Messages.

Even as root, I cannot change the owner, root, or permissions.

chasm@chasm-blue-laptop:/big$ ls -la today
-rwxrwx— 1 root plugdev 29 2009-12-22 15:27 today
chasm@chasm-blue-laptop:/big$ sudo chown chasm today
chown: changing ownership of `today’: Operation not permitted
chasm@chasm-blue-laptop:/big$ sudo chgrp chasm today
chgrp: changing group of `today’: Operation not permitted
chasm@chasm-blue-laptop:/big$ sudo chmod -x today
chasm@chasm-blue-laptop:/big$ ls -la today
-rwxrwx— 1 root plugdev 29 2009-12-22 15:27 today
chasm@chasm-blue-laptop:/big$ sudo ln -s today anotherday
ln: creating symbolic link `anotherday’: Operation not permitted

Note the problems with error messages:   “Operation not permitted” is not about user privileges, and chmod fails silently.  In this case, “Operation not permitted” means “The vffat filesystem does not support that operation”.

Step 3:  Enlightenment

The problem is that FAT-32 file systems do not have permissions, owners, and groups per se.   The entire file system is given one set of permissions at mount time, specified in the file /etc/fstab.  Let’s change it.

chasm@chasm-blue-laptop:/big$ grep “/big” /etc/fstab
# /big was on /dev/sda6 during installation
UUID=C14C-CE25  /big            vfat    utf8,umask=007,gid=46 0       1
chasm@chasm-blue-laptop:/big$ sudo vi -u NONE /etc/fstab
chasm@chasm-blue-laptop:/big$ grep “/big” /etc/fstab
# /big was on /dev/sda6 during installation
UUID=C14C-CE25  /big            vfat    utf8,umask=007,uid=1000,gid=1000 0       1

I made this change using vi -u NONE to preserve tabs.  Before the change all files in the /big file system were owned by the uid of 0 (root) in the gid of 46 (plugdev).  After the change, all files will now belong to uid and gid.  Here’s the quick test of remounting the filesystem with the new permissions.

chasm@chasm-blue-laptop:/big$ cd ..
chasm@chasm-blue-laptop:/$ sudo umount /big
chasm@chasm-blue-laptop:/$ sudo mount /big
chasm@chasm-blue-laptop:/$ ls -l /big/today
-rwxrwx— 1 chasm chasm 29 2009-12-22 15:27 /big/today

The only way to change a permission is to change permissions for the entire file system in /etc/fstab.  Also, the file system supports neither symbolic links nor hard links.

del.icio.us Reddit Slashdot Digg Facebook Technorati Google StumbleUpon Tailrank Yahoo Bloglines Newsvine Spurl Fark