Is it possible to unmount a (FAT32-formatted) pendrive without committing changes?

Use case: easy recovery of accidentally deleted files

  • Don't think so, even if there was the chances of it working like that are pretty slim. testdisk works really well for FAT32 file recovery – Graeme Mar 3 '14 at 1:45

Linux does not "commit changes" to a file, unless one is using a version control system (VCS) like Git or Fossil. It has what are known as "dirty buffers" -- files that have been changed without the changes being written to disk. The purpose of these dirty buffers is to speed up things; they are not designed to allow it to be possible to undelete files.

If you have just deleted a file, it may (or may not) be possible to pull the USB stick without unmounting the file system and still have the deleted file in question.

What you are looking for is something Linux usually doesn't have called a "versioning file system" or "snapshot file system", where older versions of all files are stored, and can be recovered in case of accidental deletion or rewriting of a file. FAT32, of course, is not a versioning file system either. (A question for others here: Has anyone ever used the Tux3 file system successfully?)

Another solution is to use a VCS like Git, and just check out an earlier version of a deleted or overwritten file (just be sure to add the file to the VCS's database and commit any version you want to store a record of).

I have used git trees in Windows (OK, Cygwin) without problem and I don't think Git needs any extended attributes not present in FAT32.


FAT has the (in)famous "undelete" command. The testdisk utility is supposed to be able to undelete files. But before perhaps making things worse, copy an image of the pendrive (dd if=/dev/pendrive of=/var/tmp/image bs=4096 or so), loop mount that image and/or work on that one. Once you've got your file(s) back, repeat the exact same steps on the original (or copy them over). Testdisk is an official package in Fedora 20, so it shouldn't be hard to get for your distribution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.