How to fix exfat filesystem
So we accidentally caused our server to go down without a clean shutdown and now df
is reporting wrong stats for the external usb (exfat).
root@srv1:/backup/usbdisk# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb2 3.6T 2.8T 646G 82% /
...
/dev/sde1 7.3T 241M 7.3T 1% /backup/usbdisk
du says:
root@srv1:/backup/usbdisk# du -sh
2.6T .
exfatfsck /dev/sde1
says:
exfatfsck 1.1.0
WARN: volume was not unmounted cleanly.
Checking file system on /dev/sde1.
File system version 1.0
Sector size 512 bytes
Cluster size 128 KB
Volume size 7452 GB
Used space 241 MB
Available space 7452 GB
ERROR: cluster 0x3f of file 'assets' is not allocated.
ERROR: cluster 0x40 of file 'mysql' is not allocated.
ERROR: cluster 0x41 of file 'public_assets' is not allocated.
Totally 3 directories and 0 files.
File system checking finished. ERRORS FOUND: 3.
so how do we fix this?
Solution 1:
Since v1.3.0 (came out on 15 Sep 2018), exfatfsck should be able to repair some errors.
Solution 2:
The manpage for exfatfsck
says:
exfatfsck checks an exFAT file system for errors. Note that it cannot repair corrupted FS, it just reports found errors.
One way to fix is to plug it into a Windows system and scan and fix errors there.
Solution 3:
You need to install exfatprogs
package, which (besides mkfs
and tune
) provides a fast fsck
utility. It is presumably pretty reliable too, because it's in particular developed by Samsung (who also contributed exFAT FS to Lunux kernel, available since Lunux 5.7 version).