16

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?

madpoet
  • 329
  • 1
  • 3
  • 10

3 Answers3

9

Since v1.3.0 (came out on 15 Sep 2018), exfatfsck should be able to repair some errors.

SebMa
  • 2,291
  • 1
    This should be the right answer (if not any it was the first remotely helpful one), though take note "some errors" means really few things. For instance, fixing file corruptions still isn't implemented. – mirh Nov 25 '21 at 23:53
7

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.

pd12
  • 1,379
4

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).

Hi-Angel
  • 3,702
  • 1
  • 29
  • 36
  • Ubuntu 20.04 sudo apt-get install exfatprogs yields Unable to locate package exfatprogs. – Pierre ALBARÈDE Nov 02 '20 at 22:53
  • @PierreALBARÈDE that's because Ubuntu 20.04 repos are outdated for this package. If you click the package link in my post, you'll see it's currently available only for Groovy, that is Ubuntu 20.10. However, I think you could try downloading the package for Groovy and installing into your 20.04 manually. The package seems to only depend on glibc, so probably should work this way. – Hi-Angel Nov 03 '20 at 06:16
  • 1
    I have upgraded to 20.10 specially to try exfatprogs and indeed I was able to mount read only an SDXC card with exFAT format and MBR partitioning. – Pierre ALBARÈDE Nov 05 '20 at 19:29
  • I can mount writable only through a USB card reader. Same thing on MacOS. – Pierre ALBARÈDE Nov 05 '20 at 21:02
  • @PierreALBARÈDE try running journalctl -f before mounting, and mount exfat afterwards. You should see in the journal the reason exfat was mounted read-only; do you see anything interesting? And while on it, what's your kernel version? – Hi-Angel Nov 05 '20 at 21:45
  • The solution of my read-only problem is here https://bartechtv.com/read-only-sd-cards-on-macbook-pro-heres-the-solution/ purely hardware and totally fantastic. Kernel 5.8.0-26-lowlatency. Finally, I can read and write my SDXC exFAT. Thanks. – Pierre ALBARÈDE Nov 05 '20 at 22:26