Skip to content

Instantly share code, notes, and snippets.

@scottopell
Last active April 30, 2024 22:46
Show Gist options
  • Save scottopell/595717f0f77ef670f75498bd01f8cab1 to your computer and use it in GitHub Desktop.
Save scottopell/595717f0f77ef670f75498bd01f8cab1 to your computer and use it in GitHub Desktop.
Fix corrupted exFAT disk macOS/OSX

exFAT support on macOS seems to have some bugs because my external drives with exFAT formatting will randomly get corrupted.

Disk Utility is unable to repair this at first, but the fix is this:

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run sudo fsck_exfat -d <id from above>. eg sudo fsck_exfat -d disk1s3
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
  6. Open Disk Utility and you should be able to repair here successfully.

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

@mitchelldmiller
Copy link

Open Disk Utility and you should be able to repair here successfully.

I forgot that Volume was open in Disk Utility - stuck on "resource busy" - while I found / applied this fix.
Unmountable USB disk was automagically mounted by disk utility, after fsck_exfat - Thank you!

@harrisondesbrosses
Copy link

Thank you, there seems to be a larger issue with ex_FAT volumes and M1 macs + Monterrey...

@stars-island
Copy link

Thank you for summarizing and sharing your idea about this!

Just wondering if it is safe to do this with my drive which has already stored piles of data. I just searched online but found nothing saying about that.

(I would say I am lazy but I have little spared storage for my large drive to backup data...)

@kurianoff
Copy link

I gotta pay you for this advice, cause I thought I lost my disk drive forever. THANKS A LOT!!!

@sandeepr79
Copy link

Awesome advice, I tried so many things in last couple of weeks without luck. Thanks a lot.

@edubskiy
Copy link

@krsnk — Did you try from the Terminal:

diskutil list

The volumes listed should show your disk ("rdisk2s1") and possibly its partitions.

Then, copy paste this (replace "disk2") in the example below with your disk's or partition's name (of course, remove "(but your disk)").

sudo ps -ax | grep disk2 (but your disk)

you should get the process number keeping your disk busy:

13699 ?? 11:52.83 /System/Library/Filesystems/hfs.fs/Contents/Resources/./fsck_hfs -y /dev/disk2s2

Then execute:

sudo kill 13699

In the example above, "13699" refers to the process currently busy, but it should be a different number on your machine.

After killing the process, the drive should mount, with a Finder's warning.

Thanks, man. You saved my day!

@jazzsequence
Copy link

Props for this. This is exactly what I needed to get my external drive working again. 👍

@onlyabhi52
Copy link

onlyabhi52 commented Jun 6, 2022

any one has faced this issue while launching the terminal - /dev/fd/14:type:296: bad option: -t

@gg4u
Copy link

gg4u commented Jun 28, 2022

Has anyone ever run into this , and can offer a solution?

It could be a bug of Apple..

sudo fsck_exfat -d disk1s2
....
Read      offset = 0x00001e2ba000  length = 0x001000
--- [1] Evicted 1 buffers (4096 bytes; 1 pages)
Read      offset = 0x00001e2bb000  length = 0x001000
Assertion failed: (result->data == NULL), function fsck_exfat_cache_recycle, file /SourceCache/exfat/exfat-66/fsck/fsck_exfat_cache.c, line 248.

laptop powered off while copying files to external drive.
Disk utilies from the GUI mac can't repair the disk.
Disk is now read only.

Please advise.

@Czechmix
Copy link

Czechmix commented Jul 16, 2022

I was able to run the sudo, but it didn't ask me for anything else after it was done. The drive now shows up in Disk Utility and I am currently doing the repair on a 4TB WD Red. It's been going for the past 4 hours stating "Checking system hierarchy". Hoping in the distant future this will resolve it not mounting to the desktop.

@edgarlim
Copy link

Thank you so much with this!

I am now able to mount my ExFat ext hdd in macOS.

Previously it only worked in Windows. You are a lifesaver!

@Harsha345155
Copy link

@edubskiy I tried your way but it's showing
zsh: unknown file attribute: b

I am lost.

@pmaingi
Copy link

pmaingi commented Feb 3, 2023

@krsnk — Did you try from the Terminal:
diskutil list
The volumes listed should show your disk ("rdisk2s1") and possibly its partitions.
Then, copy paste this (replace "disk2") in the example below with your disk's or partition's name (of course, remove "(but your disk)").

sudo ps -ax | grep disk2 (but your disk)

you should get the process number keeping your disk busy:
13699 ?? 11:52.83 /System/Library/Filesystems/hfs.fs/Contents/Resources/./fsck_hfs -y /dev/disk2s2
Then execute:
sudo kill 13699
In the example above, "13699" refers to the process currently busy, but it should be a different number on your machine.
After killing the process, the drive should mount, with a Finder's warning.

Thanks, man. You saved my day!

Thank you, i can now access my flash drive.

@edgarlim
Copy link

edgarlim commented Feb 3, 2023 via email

@alexisdray
Copy link

@gg4u just ran into the same issue, did you ever sort that out?
wondering whether to pull the plug and just reformat

@sergeydgr8
Copy link

I'm running into a similar issue as @gg4u where fsck_exfat fails:

--- [1] Evicted 1 buffers (262144 bytes; 16 pages)
Read      offset = 0x00000a036000  length = 0x001000
Assertion failed: (result != NULL), function fsck_exfat_cache_recycle, file fsck_exfat_cache.c, line 349.
[1]    24285 abort      sudo fsck_exfat -dy disk4s2

The debug logs show that it fails on the exact same file. Anyone have advice on how to combat this?

@fitnessbimbo
Copy link

Started with error
Checking volume.
** Checking main boot region.
fsck_exfat: Could not read boot region
** The volume could not be verified completely.

I've done all of the above with no luck. The latest error I get when I run diskutil verifyDisk /dev/disk2 is

Nonexistent, unknown, or damaged partition map scheme
If you are sure this disk contains a (damaged) APM, MBR, or GPT partition
scheme, you might be able to repair it with "diskutil repairDisk /dev/disk2"

I run diskutil repairDisk /dev/disk2 and get

Error repairing map: Input/output error (5)

Any suggestions?

@sergeydgr8
Copy link

So I figured out how to unbrick my drive, but it required loading up a VM of Windows in Parallels and directing USB over to it. Windows fixed the drive and loaded it up just fine, and after the job, it loaded up in macOS right after.

@lilyhara
Copy link

My external hard disk partition (disk2s1) can't be mounted and grayed out in disk utility.The error I get when I run
sudo fsck_exfat -d disk2s1 is

`Password:
Opening /dev/rdisk2s1
** Checking volume.
** Checking main boot region.
1953519616 total sectors; 512 bytes per sector
FAT starts at sector 2048; size 61440 sectors
7630688 clusters starting at sector 63488; 131072 bytes per cluster
Root directory starts at cluster 11
Read offset = 0x000000100000 length = 0x001000
** Checking system files.
Read offset = 0x000002020000 length = 0x020000
fsck_exfat: Couldn't read 131072 bytes at offset 33685504: Input/output error
No upper case translation table was found.
CONTINUE? Yes
Using default upper case translation table.
No main bitmap was found.

CONTINUE? Yes
**** Checking file system hierarchy.**
Directory /
Read offset = 0x000002020000 length = 0x020000
fsck_exfat: Couldn't read 131072 bytes at offset 33685504: Input/output error
Upper case translation table must be replaced.
Replace? Yes

Read offset = 0x000001f00000 length = 0x020000
fsck_exfat: Couldn't read 131072 bytes at offset 32505856: Input/output error
The volume could not be verified completely.

The disk utility gives me this error when I run first aid on the unmounted partition.

Running First Aid on “” (disk2s1)
Repairing file system.
Volume is already unmounted.
Performing fsck_exfat -y -x /dev/rdisk2s1
Checking volume.
Checking main boot region.
Checking system files.
No uppercase translation table was found.
Using default uppercase translation table.
No main bitmap was found.
Checking file system hierarchy.
Uppercase translation table must be replaced.`

Does anyone have same experience? Any suggestions? Thank you in advance :)

@minksW
Copy link

minksW commented Jul 5, 2023

halp pls

@berkeozkir
Copy link

I have been dealing with this error for almost 6 years now. My drives are big 6TB - 8TB I cannot use FAT32 for that reason I have to use exFat to make my drives compatible with both windows and Mac. The drives always mount on my windows machine but on Mac it randomly mounts. Apple needs to fix this. When I urgently have a need to access my data sometimes I cannot mount it on Mac so I have to use windows as a middle man or use virtual machine like parallels. It's interesting the Mac cannot mount but VM running on it can mount it. Anyways thanks for your help. It sucks that I always have to come here to check solutions because I forget the command prompts.

@dejanovicnenad
Copy link

dejanovicnenad commented Aug 16, 2023

@krsnk — Did you try from the Terminal:

diskutil list

The volumes listed should show your disk ("rdisk2s1") and possibly its partitions.

Then, copy paste this (replace "disk2") in the example below with your disk's or partition's name (of course, remove "(but your disk)").

sudo ps -ax | grep disk2 (but your disk)

you should get the process number keeping your disk busy:

13699 ?? 11:52.83 /System/Library/Filesystems/hfs.fs/Contents/Resources/./fsck_hfs -y /dev/disk2s2

Then execute:

sudo kill 13699

In the example above, "13699" refers to the process currently busy, but it should be a different number on your machine.

After killing the process, the drive should mount, with a Finder's warning.

This worked for me, but I had to use sudo kill -9 {PID} to kill the process successfully.

@Dax-87
Copy link

Dax-87 commented Nov 11, 2023

Thank you so much you saved my life.
I had 3 HDDs that failed at the same time.
With this guide I solved it.

@saxondigital
Copy link

Been fixing the OSX exFAT corruption using MS Windows 'chkdsk /r /f'

So far, has worked every time, but can take a couple hours on spinning disks.
The problem goes back many years (at least with OSX 10.11 - 10.14).

Next time (won't be long), I will try the Mac based method explained here.

@att11
Copy link

att11 commented Jan 2, 2024

Hi @scottopell, thanks, I tried this method, the result was:
** Checking volume.
** Checking main boot region.
fsck_exfat: Invalid jump or signature
Main boot region is invalid. Trying alternate boot region.
** Checking alternate boot region.
fsck_exfat: Invalid jump or signature
Alternate boot region is invalid.
** The volume could not be verified completely.

Any idea what might be wrong, how could I fix this? Thanks in advance, att

@Titencer
Copy link

Titencer commented Jan 6, 2024

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run 'sudo fsck_exfat -d '. eg 'sudo fsck_exfat -d disk1s3'
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
  6. Open Disk Utility and you should be able to repair here successfully.

Hey! Did this after getting my 6tb ExFat drive to at least be view only. Prior to this, I tried sudo pkill -f fsck but that did not allow the drive to mount, nor be repaired through First Aid. Since running the above command, it's been going files for a couple hours now. Is this supposed to take a super long time? Worried it's just stuck in fsck_exfat again. It's view only now but I won't be able to get another hard drive for a little bit.

@Titencer
Copy link

Titencer commented Jan 6, 2024

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run 'sudo fsck_exfat -d '. eg 'sudo fsck_exfat -d disk1s3'
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
  6. Open Disk Utility and you should be able to repair here successfully.

Hey! Did this after getting my 6tb ExFat drive to at least be view only. Prior to this, I tried sudo pkill -f fsck but that did not allow the drive to mount, nor be repaired through First Aid. Since running the above command, it's been going files for a couple hours now. Is this supposed to take a super long time? Worried it's just stuck in fsck_exfat again. It's view only now but I won't be able to get another hard drive for a little bit.

Adding to this - I'm running macOS Ventura 13.6.1 (22G313)

@heihaheihaha
Copy link

Hi @scottopell, thanks, I tried this method, the result was: ** Checking volume. ** Checking main boot region. fsck_exfat: Invalid jump or signature Main boot region is invalid. Trying alternate boot region. ** Checking alternate boot region. fsck_exfat: Invalid jump or signature Alternate boot region is invalid. ** The volume could not be verified completely.

Any idea what might be wrong, how could I fix this? Thanks in advance, att

My solution is link the disk to a Windows computer, it repaired the disk auto. Unbelievable.

@livingperson
Copy link

Also had issues mentioned above. My solution was to connect it to Windows, and do the following:

Run Disk Error Checking

  1. Plug in your external hard disk.
  2. Open File Explorer by pressing the Windows keys button + E.
  3. Go to This PC.
  4. Right-click your external hard disk under Devices and drives.
  5. Select Properties
  6. Go to Tools tab.
  7. Under Error checking, click Check.
  8. If prompted, click Yes or enter the administrator password.
  9. Click Scan drive > Repair drive.
  10. Wait for the process to finish.
  11. The scanning process may take a while depending on the size of your external hard disk and the specifications of your PC.

@suebphattana
Copy link

Also had issues mentioned above. My solution was to connect it to Windows, and do the following:

Run Disk Error Checking

  1. Plug in your external hard disk.
  2. Open File Explorer by pressing the Windows keys button + E.
  3. Go to This PC.
  4. Right-click your external hard disk under Devices and drives.
  5. Select Properties
  6. Go to Tools tab.
  7. Under Error checking, click Check.
  8. If prompted, click Yes or enter the administrator password.
  9. Click Scan drive > Repair drive.
  10. Wait for the process to finish.
  11. The scanning process may take a while depending on the size of your external hard disk and the specifications of your PC.

Saved my life! thanks!

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