28

Fix corrupted exFAT disk macOS/OSX

 1 year ago
source link: https://gist.github.com/scottopell/595717f0f77ef670f75498bd01f8cab1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Fix corrupted exFAT disk macOS/OSX · GitHub

Instantly share code, notes, and snippets.

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

I have tried your suggestions @scottopell but it has not worked for me. What should I do next?

$ sudo fsck_exfat /dev/disk2s2
Password:
** Checking volume.
** Checking main boot region.
fsck_exfat: Could not read boot region
** The volume  could not be verified completely.
$ sudo fsck_exfat -d disk2s2
Password:
Opening /dev/rdisk2s2
** Checking volume.
** Checking main boot region.
fsck_exfat: Could not read boot region
** The volume  could not be verified completely.

Dude, thank you so much!

@ashutoshdesign you can try doing the command in single-user mode by holding ⌘+S on boot-up just after pressing the power button of your mac.

Any tips for getting single-user mode to work? I get the wall-of-command-line-text but then it just kicks into the usual 'select user' GUI login screen. I've also turned off Firmware password. One suggestion I haven't tried is turning off Filevault, which some sources say take up to a week (!) to decrypt the start-up drive.. MacBook Air Intel 2018 with macOS 11.3 here.

Thank you this was very useful, I had an 8TB drive crashed got all the data recovered....

I'm getting an error saying- "Can't open /dev/rdisk2s2: Resource Busy". What do I do?

I was stuck with "Resource Busy" too, but a comment on the Source link (on craigsmith.id.au) describes how to find and kill the process locking the resource which worked for me.

ps -ax | grep disk2 (but your disk)
13699 ?? 11:52.83 /System/Library/Filesystems/hfs.fs/Contents/Resources/./fsck_hfs -y /dev/disk2s2

sudo kill 13699

Once the offending process is killed, I got an OS prompt about an error mounting the drive (something along the lines of it being mounted in read only mode, don't remember the wording). After that the drive mounted in Finder and Disk Utility and I was able to run "First Aid" using "Disk Utility"

i did exactly the same and i manage to reach to the step whereby i am able to run "First Aid" using "Disk Utility", however, i get stuck at first aid for very very long time and it doesn't move on from there, anybody can help me?

Hi I tried the above. After the drive debug on a 6TB WD Elements usb hard drive Took more than 12/hrs whew...the message said "everything seems to be ok" received No errors. Back to square one the drive shows but still won't repair in disk utility tried almost everything since mid March of this year. One thing I did notice maybe that's the problem I go to the drive icon right click go to "Get info" my Storage Info is wrong it says Modified:Monday, December 31,1969 at 11:00PM and under General: Created: Wednesday,December 31,1969 at 7:00PM Modified: Monday, December 31,1979 at 11:00PM. The format, capacity, available space left on partion info are correct. The drive content did show on windows but Not in Mac the format is Exfat there is a 'Back Up" partion also.When I run Diskutil: I get this message "Updating boot support partitions for the volume as required.Unable to unmount volume for repair.Operation failed..." The drive did open once the files were accessible. When I reboot my Mac I'm back to square one. Any ideas on how to fix this problem. I ran fsck in single mode diskutil in terminal all that.At least I got some good Mac lessons. Please Help Thanx

markveronin commented on Jun 15, 2021

edited

I'm getting password enter doesn't work and I don't have a password for the computer or the drive

I think it was a virus that corrupted the partition map on the Mac usb storage drive. I think the virus rewrote the partition info this a Mac formated drive. After the infection the drive was recognized as NTFS Microsoft windows file system or something like that. I'm using "Testdisk" to fix the MBR on the drive to rewrite Mac hts back to original partition. Using a usb boot 64bit version of "GParted Live" hopefully that works I'm on the second day. The GParted site recommend that the fix be done to the drive with the corrupted MBR partition table Mac hard drives we in the can do's of hardrive map partition fixes.

Get Outlook for Android<https://aka.ms/AAb9ysg>

________________________________ From: markveronin ***@***.***> Sent: Tuesday, June 15, 2021 11:23:06 AM To: scottopell ***@***.***> Cc: T3kbug58 ***@***.***>; Comment ***@***.***> Subject: Re: scottopell/fix_exfat_drive.md

@markveronin commented on this gist.

________________________________

I'm getting enter doesn't work and i don't have a password for the computer or the drive

— You are receiving this because you commented. Reply to this email directly, view it on GitHub<https://gist.github.com/595717f0f77ef670f75498bd01f8cab1#gistcomment-3781165>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AUJZ2PPJNRXLSN4NUBCO7Y3TS5V5VANCNFSM4HIMNYKQ>.

I am not able to erase my drive. It's 240gb ssd. While I try to erase my disk in disk utility, it is stuck saying "Waiting for partitions to activate". Is there any way to fix this issue?

➜  ~ sudo fsck_exfat disk2s1
fsck_exfat: Opened /dev/rdisk2s1 read-only
** Checking volume.
** Checking main boot region.
   Main boot region is invalid. Trying alternate boot region.
** Checking alternate boot region.
   Alternate boot region is invalid.
** The volume  could not be verified completely.

Any update for this?

~ sudo fsck_exfat disk4s1
fsck_exfat: Opened /dev/rdisk4s1 read-only
** Checking volume.
** Checking main boot region.
Main boot region is invalid. Trying alternate boot region.
** Checking alternate boot region.
Alternate boot region is invalid.
** The volume could not be verified completely.

I am also facing the same ↑, anyone solve this?

I was stuck with "Resource Busy" too, but a comment on the Source link (on craigsmith.id.au) describes how to find and kill the process locking the resource which worked for me.

ps -ax | grep disk2 (but your disk)
13699 ?? 11:52.83 /System/Library/Filesystems/hfs.fs/Contents/Resources/./fsck_hfs -y /dev/disk2s2

sudo kill 13699

Its working for me thank you so much

I'm getting an error saying- "Can't open /dev/rdisk2s2: Resource Busy". What do I do?

I used activity monitor and killed the "fsck" activity. Then it worked. It was as simple. If it does not work try killing in activity monitor in safe boot (press shift while booting)

PS: sudo fsck command did not work for me in command S commamd line, neither it worked for me in recovery mode terminal.

The ntfs disks are so delicate. I wish there was a crashproof partition system.

➜ ~ sudo fsck_exfat disk2s1 fsck_exfat: Opened /dev/rdisk2s1 read-only ** Checking volume. ** Checking main boot region. Main boot region is invalid. Trying alternate boot region. ** Checking alternate boot region. Alternate boot region is invalid. ** The volume could not be verified completely.

Did anyone solve this yet? I beg you tell how

bonatoc commented on Dec 8, 2021

edited

@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, this fixed my Seagate SSD which can not be mounted

** Checking active bitmap.
Checking bitmap cluster 2
Read      offset = 0x000001f00000  length = 0x020000
Read      offset = 0x000000100000  length = 0x001000
Read      offset = 0x000000105000  length = 0x001000
Read      offset = 0x000000108000  length = 0x001000
Read      offset = 0x000000109000  length = 0x001000
Read      offset = 0x00000010a000  length = 0x001000
Read      offset = 0x00000010b000  length = 0x001000
   The bitmap needs to be repaired.
0000001B: FF should be BF
0000029B: FF should be 47
0000029C: FF should be CE
000002A0: FF should be 7F
000002A1: FF should be C3
00000402: FF should be FB
000004A6: FF should be FA
000004A7: FF should be F7
000004AF: FF should be 1F
000004B0: FF should be 00
000004B1: FF should be 00
000004B2: FF should be 40
000004B3: FF should be C7
000004B4: FF should be FC
000004B9: FF should be 7F
000004BA: FF should be EF
000004BC: FF should be FB
000004BD: FF should be DF
000004BE: FF should be 8C
000004BF: FF should be FE
000004C1: FF should be FE
000004CA: FF should be DD
000004CE: FF should be 07
000004CF: FF should be 00
000004D0: FF should be 00
000004D1: FF should be 00
000004D2: FF should be B0
000004D5: FF should be 9F
000004D7: FF should be 7F
000004D8: FF should be FC
00000504: FF should be EF
00000512: FF should be 3F
00000513: FF should be F8
00000537: FF should be FB
0000055A: FF should be EF
0000055B: FF should be 03
0000055C: FF should be E2
0000055D: FF should be 3C
0000055E: FF should be DF
0000055F: FF should be 97
00000561: FF should be 39
00000562: FF should be FE
00000563: FF should be C3
00000567: FF should be BF
00000568: FF should be FE
0000056E: FF should be FB
0000056F: FF should be 9F
00000570: FF should be 96
00000571: FF should be F8
00000573: FF should be 7F
00000574: FF should be F0
00000578: FF should be BE
0000057B: FF should be FD
00000580: FF should be 07
00000581: FF should be FE
00000582: FF should be 6F
00000583: FF should be FB
00000585: FF should be EF
00000587: FF should be F1
00000588: FF should be BE
00000589: FF should be D8
0000058A: FF should be FE
00000594: FF should be 87
00000595: FF should be EF
000005B6: FF should be 7F
000005BF: FF should be FD
000005CA: FF should be 8F
000005D2: FF should be 1F
000005D3: FF should be FE
000005D4: FF should be 7F
000005D5: C3 should be C0
00003B13: 0F should be 2F
Repair? yes
Checking bitmap cluster 3
Read      offset = 0x000001f20000  length = 0x020000
Checking bitmap cluster 4
Read      offset = 0x000001f40000  length = 0x020000
Checking bitmap cluster 5
Read      offset = 0x000001f60000  length = 0x020000
Checking bitmap cluster 6
Read      offset = 0x000001f80000  length = 0x020000
Checking bitmap cluster 7
Read      offset = 0x000001fa0000  length = 0x020000
Checking bitmap cluster 8
Read      offset = 0x000001fc0000  length = 0x020000
Checking bitmap cluster 9
Read      offset = 0x000001fe0000  length = 0x020000
192 clusters were marked used, but not referenced
0 clusters were marked used and CLUST_BAD
1 clusters were marked free, but referenced
** Rechecking main boot region.
** Rechecking alternate boot region.
Write     offset = 0x000001f00000  length = 0x020000
fsck_exfat: Couldn't write 131072 bytes at offset 32505856, errno 9: Bad file descriptor

There is an error at the end, but it seems OK. I can mount the SSD now, and everything comes back.

After the disk becomes accessible again, I would advise to backup your data and reformat the hard drive using "Mac OS journaled" as the format.

While Mac OS X states exFAT partitions are compatible, it's probable we come across these problems in part because of that.

Making your hard drive fully compatible with OS X's file system can prevent future problems to arise.

Hi. Is there any partition type in making which will support hot eject

On Mon, Dec 13, 2021, 17:43 Christian Bonato ***@***.***> wrote: ***@***.**** commented on this gist. ------------------------------

After the disk becomes accessible again, I would advise to backup your data and reformat the hard drive using "Mac OS journaled" as the format.

While Mac OS X states exFAT partitions are compatible, it's probable we come across these problems in part because of that.

Making your hard drive fully compatible with OS X's file system can prevent future problems to arise.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://gist.github.com/595717f0f77ef670f75498bd01f8cab1#gistcomment-3993535>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ASYKCFOAAYXPLXVYNTG4OWDUQXPNPANCNFSM4HIMNYKQ> . Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.

@bonatoc
Thank you, but I've already gone mad, gave up and bought a macbook.

Thank you this was helpful.

JingboXia commented on Jan 25

It works. Thanks.

Did anyone ever solve this:

sudo fsck_exfat -d disk4s1
Opening /dev/rdisk4s1
fsck_exfat: Opened /dev/rdisk4s1 read-only
** 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.

It does not appear to be something busy, but I don't know enough about Terminal/DOS to be able to read this and see what is wrong. Disk Utility tells me that there is an orphaned cluster that can't be fixed when I try to run First Aid. So, I tried this route, but it isn't working either...

cocotyty commented on Feb 1

sudo gdisk /dev/disk2
just w
Everything become ok!

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!

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

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 commented on Mar 13

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

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

edubskiy commented on Mar 24

@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!

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

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK