Using fsck on macOS
My old 2015 Macbook Pro has an issue with one of the USB ports that sometimes makes it disconnect connected devices. Before I figure out what’s going on with it I had several accidents with external drives which wouldn’t mount correctly anymore after being disconnedted mid-write.
I’ve had varying success using “First Aid” with Disk Utility but better experiences when using fsck manually (First Aid is just a graphical front to fsck).
Fsck is an old unix tool that can identify and fix problems with filesystems. Problem with fsck is that it actually writes data on the disk (if you tell it to) so it’s potentially dangerous and destructive. With that in mind, here’s how to use it.
Using fsck to manually fix and mount external drives
Running fsck is not deterministic. That is, you might get different results when running it time after time. Also note that the fixing process can take a long time (anything from minutes to hours depending on the size and state of your disk). I don’t deeply understand how the tool works so it mostly looks like magic to me. But, sometimes it works so it’s good magic!
Open up terminal and running diskutil list
will tell you the identifiers of the available disks and volumes, and, importantly, their type.
~ diskutil list
/dev/disk0 (internal):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme 500.3 GB disk0
1: Apple_APFS_ISC 524.3 MB disk0s1
2: Apple_APFS Container disk3 494.4 GB disk0s2
3: Apple_APFS_Recovery 5.4 GB disk0s3
/dev/disk3 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +494.4 GB disk3
Physical Store disk0s2
1: APFS Volume Macintosh HD 15.8 GB disk3s1
2: APFS Snapshot com.apple.os.update-... 15.8 GB disk3s1s1
3: APFS Volume Preboot 399.7 MB disk3s2
4: APFS Volume Recovery 831.9 MB disk3s3
5: APFS Volume Data 370.5 GB disk3s5
6: APFS Volume VM 20.5 KB disk3s6
/dev/disk4 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *2.0 TB disk4
1: EFI EFI 209.7 MB disk4s1
2: Apple_HFS 2.0 TB disk4s2
I’m trying to fix a 2TB external drive which seems to be dick4s2
and formatted as HFS. (The other usual type is FAT or EXFAT.)
Knowing the type and the identifier, I can now say fsck_[apfs|hfs|exfat] -fy /dev/[ disk_identifier]
like so (using sudo here so it will prompt you for your password):
Important: please read the fsck command help to understand what the arguments mean before running anything.
~ sudo fsck_hfs -fy /dev/disk4s2
** /dev/rdisk4s2 (NO WRITE)
Executing fsck_hfs (version hfs-582.60.2).
** Checking Journaled HFS Plus volume.
The volume name is Sabrina
** Checking extents overflow file.
** Checking catalog file.
** The volume Sabrina could not be verified completely.
The result “could not be verified completely” means that fsck was unable to fix and mount the volume. Depending on the state of your drive you might get different output and/or result.
I’ve yet to be able to fix the drive in question but just last week I succesfully fixed a smaller drive with fsck_exfat
which ended up in “The volume [identifier] appears to be OK” message and mounted volume. YMMV.