0

My USB was in the USB port and at the time I was copying something to my HDD I decided to cancel it. Immediately afterwards I decided to remove the USB but I forgot to press safe eject.

As a result of this, when I re-inserted my flash drive into the USB port, I saw one folder with some files in it which was one of the many folders I had on my USB, and AUTORUN.INF which wasn't there before. The rest of the files are gone.

The strange thing is that when I check the partition in Gparted it shows that my USB still have some files on it but when I decided to check for hidden files (CTRL+H) there was only one folder .Trash-1000. I also tried to recover some data via Gparted (GPart) but it didn't detect any partitions. According to Gparted the files are still there but I can't see them. I have also checked it on another distro and the results are the same. The file system on my flash drive is FAT32.

What happened to my files and how can I restore them?

Zanna
  • 70,465
  • Could you try to scan the drive with Testdisk and then report about its output? So we can get a more detailed overview of the situation. I will now flag this Q as a possible duplicate of another one which was about exFAT (not FAT32) but you can apply the same answer. – Andrea Lazzarotto Dec 03 '16 at 17:23

1 Answers1

1

It's probably because the USB's FAT32 filesystem has the "Dirty" bit set.

To check:

  1. Unplug the USB drive.
  2. Wait 15 seconds.
  3. Insert the USB drive.
  4. Wait 15 seconds.
  5. Issue the dmesg command, and read the last several lines. If the "Dirty" bit is set, you'll see a line similar (YMMV) to

    FAT-fs (sdc): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

If this is the case, the run fsck step will be:

sudo fsck.vfat -w -y /dev/sdX

(replace /dev/sdX with your disk, and read man fsck.vfat)

When the fsck.vfat has finished, remove and re-insert the USB drive.

If Volume was not properly unmounted. Some data may be corrupt. Please run fsck. is not seen in the dmesg output, but it blathers on about Mount on Windows, run chkdsk then the above answer does not apply, and you must mount it on Windows.

waltinator
  • 36,399