25

I'm getting this error when trying to repartition an external drive: "".

I want to run fsck -fy on the drive, but don't know the proper syntax for doing it on an external drive?

Can anyone help me out with this problem?

4 Answers 4

41

Actually you want to do:

% sudo fsck_hfs -fy /dev/disk1s1 (depending on what partition you want to check).

It won't work with just fsck you have to put fsck_hfs as the command to run.

1
  • 3
    This is the best answer. Before you run it, List all your disks with diskutil list My SD card is disk2. Then you want to find the partition number, so do something like ls /dev/disk2*. This results in disk2s1. So the final command I run is this sudo fsck_hfs -f /dev/disk2s1. NOTE: I purposly formatted my SD card as hfs. Normally they are using like fat or something.
    – benathon
    Dec 14, 2015 at 9:46
9

I'm getting this error when trying to repartition an external drive: ""

That's a very descriptive error indeed.


In order to run fsck on an external drive, you first need to find out the identifier of the drive. Run diskutil list and check the name of the volume listed under IDENTIFIER – it'll be something like disk3s4, for example.

Use that name to run fsck. You can also pass the -f option to force checking a clean filesystem.

sudo fsck /dev/disk3s4

fsck has shorthands for diverse file system types:

  • fsck_hfs for HFS, use the -f option to force checking journaled systems
  • fsck_exfat for ExFAT (no -f option here)
  • fsck_msdos for FAT (no -f option here)
3
  • Actually, it looks like as of 10.9, you can't use fsck without some sort of flag. Using the command as given here results in the help/usage output.
    – ray
    Dec 15, 2013 at 20:43
  • See Paul’s answer - you have to use fsck_hfs. Feb 17, 2014 at 21:46
  • 1
    (8 years later) and fsck_apfs for modern APFS drives
    – Eric_WVGG
    Jun 1, 2020 at 2:01
2

I had to run with the -l flag:

diskutil list # find your identifier
/sbin/fsck_hfs -l -f /dev/disk16

The -l flag tells fsck to check the drive in read only mode.

2

This is not a direct answer to the original question, but closely related.

Another option is to use diskutil itself to verify or repair an external drive.
I'm not sure how it compares to fsck, but it fixed my external drive that was not mounting after I accidentally left it plugged in during a restart for a system update.

diskutil list  # to find the IDENTIFIER
  (some internal disks listed first)
  /dev/disk2 (external, physical):                                              
    #:                    TYPE NAME                    SIZE       IDENTIFIER
    0:   GUID_partition_scheme                        *500.1 GB   disk2     
    1:                     EFI EFI                     209.7 MB   disk2s1   
    2:               Apple_HFS FreeAgent GoFlex Drive  499.8 GB   disk2s2   

and then commands such as

diskutil verifyDisk disk2
diskutil verifyVolume disk2s1
diskutil verifyVolume disk2s2

For some reason just running the verify commands solved my issue, but if you need to go further there are also repair commands:

diskutil repairDisk disk2
diskutil repairVolume disk2s1
diskutil repairVolume disk2s2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .