Skip to content

Instantly share code, notes, and snippets.

@ChenxiSSS
Forked from scottopell/fix_exfat_drive.md
Last active May 31, 2023 22:45
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ChenxiSSS/fad9631876ec616dbf5f9f88646383a0 to your computer and use it in GitHub Desktop.
Save ChenxiSSS/fad9631876ec616dbf5f9f88646383a0 to your computer and use it in GitHub Desktop.
Fix corrupted exFAT disk macOS/OSX

exFAT support on macOS seems to have some bugs since exFAT drives may or maynot randomly get corrupted.

In my case, "not ejected properly" often casue the drive in Resource busy, Volume on xxx failed to mount, File system check exit code is 1, or Timed out waiting, when try to use both Disk Utility or diskutil to mount, repair, or first aid the disk.

Possible fix is this:

  1. Use diskutil list to find the right drive id.
    • You want the id under the IDENTIFIER column, it should look like disk1s1.
    • disk1 marks the entire Disk. disk1s1 or disk1s2 marks each Volume.
  2. Usually, you want to check if the disk is occupied by one or many process.
    • You can check possible occupation via ps -ax | grep <id from above>, saying disk3s1.
    • You may get something like this:
      • 13699 ?? 11:52.83 /System/Library/Filesystems/hfs.fs/Contents/Resources/./fsck_exfat -y /dev/disk3s1.
    • You need to kill the process via sudo kill 13699.
  3. Now you can try to fix the Volume via sudo fsck_exfat -d <id from above>. eg sudo fsck_exfat -d disk3s1
    • -d is debug so you'll see all your files output as they're processed.
    • If all good, you will get Mark volume clean?, answer YES will end the debug and get ** The volume xxx appears to be OK.
    • Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
  4. After the fix, you can mount the whole Disk via diskutil mountDisk disk3 or the specific Volume via diskutil mount disk3s1

See the apple man page below for details on the fsck_exfat utility.

Sources/Extra Reading: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man8/fsck_exfat.8.html https://craigsmith.id.au/2014/07/06/repairing-a-corrupted-mac-osx-exfat-partition/ https://discussions.apple.com/thread/4154638?tstart=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment