exFAT unmount error results in lost files that I can't remove

I was writing Data to an external exFAT HDD when power to my system was interrupted. This wasn't an issue for my main drive since it uses journaling and recovered fine. My trouble is with the external Harddrive I was writing to. I was writing a tarball to the external drive (interrupted at roughly 1TB). After rebooting the target file was reported by ls -la at 0 B size, however df still showed that roughly 1TB was occupied. When mounting the drive for the first time after the incident exFat fuse gave an error "not unmounted correctly", however this error does not reappear now.

TLDR: After power loss there is a discrepancy between df and du of about 1TB (the Tarball I was writing)

What I tried so far:

  • exfatfsck: finds no errors, used space is as high as df (includes unlisted files)

  • deleting the 0B file : worked, but did not change the df, du difference.

I do not need the tarball (source files are still on my main drive), but there are other files still on the drive, that I would like to keep. Is there a way to fix the damage? I would really like to fix the damage because the other files on the disk are quite large and offloading them before formating the drive would be inconvinient.

I am running Ubuntu Server 18.04.5 LTS

Thank you for your time and help =)


Solution 1:

Linux in its latest kernels natively supports extfat. Moreover, the file format is rather simple. Therefore, maintenance and repair should fully be possible on linux.

See man fsck.exfat (provided the tool is installed) for options. To effectively proceed to repair, i.e., delete invalid directory items and recover or discard lost clusters, use either the -r option ("Repair the filesystem interactively."), the -y option ("Repair the filesystem answering yes to all questions.") or the -p option ("Repair the filesystem without user interaction if it can be done safely."). For example, if your exfat partition is known as /dev/sdc1, you will first unmount that partition, then perform the check:

sudo umount /dev/sdc1
sudo fsck.exfat -r /dev/sdc1