EN FR

GNU/Linux: read-only file system error when accessing FAT/FAT32 drive

Sometimes and for no obvious reason, I suddenly cannot write or delete a file located on a removable USB drive using a FAT file system. Having no knowledge about all the magic going on under file system operations, I can just observe that some actions previously done successfully on some drives are no longer possible!

$ rm -r /path/to/some/obsolete/data/*
rm: cannot remove ‘/path/to/some/obsolete/data/data1’: Read-only file system

It happened a few times in the previous years and I think it always involved FAT, but this is maybe not limited to that file system. We can easily solve this issue by running fsck, in this case in the form of its vfat variant:

$ sudo fsck.vfat -a /dev/sdc1

Replace /dev/sdc1 with your rebellious partition. The -a flag tells fsck to automatically repair the file system. The man page warns to use this feature with caution. You may prefer the -r flag which makes fsck asking you confirmation.

Note that fsck comes with lot of flavors, such as fsck.ext2|3|4, fsck.msdos, fsck.nfs... You may have to install some of them depending on your GNU/Linux distribution.

"Upgrade to Firefox" bannerSupport La Quadrature du Net!Soutenir FramasoftSupport the Gooseberry project, Blender Foundation's 5th Open Movie project