At times, some unexpected events happen and damage the directory structure of the external hard drive. This makes data or the drive inaccessible. Fortunately, Disk Utility can help you keep your external hard drive healthy. But there are situations in which it may not be avaliable. In this case, you can also use some command lines to verify and repair an external hard drive. This passage will show you a detailed guide to repair a external hard drive with Mac Terminal.
How to repair external hard drive with Mac Terminal?
Notice: This guide is intended for advanced users who are comfortable with the Terminal and command line. For most Mac users, it's better to repair external hard drive directly with First Aid. Because command lines are so complicated for common users. If you input wrong command lines, it will not only overwrite your data but also damage the external hard drive even your Mac machine.
First of all: Back up important data
It's said that if you successfully repair an external hard drive with Terminal, all data stored on the drive keeps intact. But the truth is when running Terminal to repair a external hard drive, it will write new data on the drive and the original data is possible to be overwritten. So if you have valuable data on the external hard drive, you should you restore data from the corrupted external hard drive at first.
iBoysoft Mac Data Recovery is a free data recovery tool which can recover deleted files even emptied from Mac Trash, recover lost data from corrupted drive, recover lost data from formatted drive, recover lost data from unmountable hard drive, external hard drive, USB flash drive, SD card, memory card, pen drive, etc. Moreover, iBoysoft Data Recovery for Mac supports more than 500 file formats, including pictures, audios, videos, emails.
Step-by-step guidance to recover lost data from corrupted external hard drive
- 1. Download and install iBoysoft Data Recovery for Mac on Mac.
- 2. Launch iBoysoft Data Recovery for Mac.
- 3. Select the corrupted external hard drive and click "Next" to search for deleted files.
- 4. Preview the files in the searching results and choose files those we want to recover, click "Recover" to get those lost files back.
Method 1: Verify and repair external hard drive from command line
- 1. Open Terminal (/Applications/Utilities/Terminal.app)
- 2. Type or paste in this command: cd /Volumes and then type ls and press Return. (You'll be shown a list of disks attached to your Mac. Target the one for verification and repair and notice its drive letter.
- 3. Type in diskutil verifyVolume [drive identifier], then press Enter. (Please make sure to substitute the [drive identifier] portion for the actual name of the external hard drive)
- After verifying the external hard drive, if you don't get any error message, you don't need to repair the external hard drive. But if you get error message: "The volume was found corrupt and needs to be repaired", you have to use other command lines to repair the drive.
- 4. Input diskutil repairvolume /Volumes/[drive identifier]/ and press Return. (For example, if the name of your external hard drive is "ExternalBackups", you should type in diskutil repairvolume /Volumes/ExternalBackups/)
Method 2: Repair external hard drive with fsck
If the above solution fails to repair external hard drive, don't be upset, you can try fsck command. This command line is a bit more complex, but it works for situations when Disk Utility can't repair disk.
- 1. Open Terminal (/Applications/Utilities/Terminal.app).
- 2. Type in diskutil list (This will produce a list of all the currently connect drives, both mounted and unmounted).
- 3. Locate the one you want to and find its drive identifier.
- 4. Restart your Mac and, before the Apple logo appears, hold down Command + S keys. This will boot your Mac into Single User Mode.
- 5. Some white text will scroll by quickly. When it stops, type in /sbin/fsck –fy, then press Enter.
- 6. Type in /sbin/fsck_hfs -fy /dev/[drive identifier] (Change hfs to the file system of the target drive and replace [drive identifier] with actual drive name). fsck will check the file system and attempt to repair any damage that it finds on external hard hard drive.
- 7. When fsck is finished checking and repairing the file system, type reboot into the command prompt and press Enter. Then our Mac will reboot, returning us to the usual login screen.
If you continue to have problems, the external hard drive may have serious file system corruption. You can try iBoysoft Data Recovery for Mac to recover important back and then reformat the drive in Disk Utility. If you still can't use the external hard drive, the drive may be physically damaged. You can only send it to local repair company or replace it with a new one.