Mac computers are known for their reliability and usability. They are designed to be as user-friendly as possible, so as long as you have basic computing know-how, using a Mac shouldn’t be too much of a challenge.
Mac also comes with built-in programs and features that help users make the most of their devices. One of these helpful programs is the Disk Utility. It is a graphical user interface designed to verify and repair hard drives in Mac. You can utilize it as the first line of defense against disk-related errors. This application is a powerful tool that can help keep drives connected to your Mac healthy and safe from various threats.
Bundled with Mac OS X, Disk Utility is indeed a very handy tool to have. However, there will be times when you can’t use it to solve your hard drive problems. Thankfully, for such unfortunate instances, Disk Utility has a command line equivalent, which allows users to perform more advanced disk management and maintenance.
When Disk Utility won’t launch or when you need to perform remote disk repairs through SSH (Secure Shell) or Single User Mode, the best way to go is to access the Terminal, where you can perform various tasks including disk verification and repairs.
In this article, we will give users who are comfortable with performing advanced troubleshooting a guide for using the Terminal and command line to verify and repair hard drives. If you have already experienced using the Terminal and command line before, chances are you will find the steps here easy to follow.
What is Mac Terminal?
Before we get into the technical aspects and look at the steps on how to verify HDD on Mac or how to repair disks in OS X using the Terminal, let us first discuss what the Mac Terminal is in the first place.
Of all the Mac utilities available at a user’s disposal, the Terminal could be said to be among the most misunderstood of them all. If you have chanced upon it before, you might have wondered why one would want to run it when you can simply use other automated utilities?
As mentioned above, there are times when you will need to manually perform troubleshooting tasks through the Terminal. Furthermore, learning about certain commands and using them lets you customize some elements of your Mac.
What you must understand about the Terminal is that it’s just another application. It is launched like you would any other program. Once launched, you will be shown Apple’s implementation of the command-line environment and you can now proceed in doing whatever it is you need to do.
Not for the Faint of Heart
We need to reiterate that this guide is not meant for novice Mac users. You need to have some background in manual command-line troubleshooting and ideally, have already experienced working with the Terminal. Otherwise, you may want to stick to Disk Utility or third-party programs such as Tweakbit MacRepair, which are designed to automatically detect and fix errors in your Mac including its disk drives.
Locating Disks in Mac Terminal
If you’ve decided to verify and repair your hard drive from the command line in OS X, you may want to locate the disk in question first. As mentioned above, you just need to launch Terminal like you would any other app. To access it, go to:
Finder > Applications > Utilities > Terminal
Click Spotlight > Type Terminal
Once the Terminal is launched, you can now look for the disk you need to verify and repair. Every disk connected to the Mac is located in the Volumes directory, which is just a step away from Mac’s root.
To switch from one directory to another, just type in this command:
Next, type 1s, then press Return. You will now see a list of the disks currently attached to your Mac. Take note of their names, also known as drive identifier.
Verifying Disks in Mac Terminal
Now that you already have an idea of the disks connected to your Mac, you can start verifying them. You can target multiple drives at once, as long as you know their names.
Here’s how to verify an internal disk:
- In the Terminal, type the command in this format:
diskutil verifyVolume [drive name]
- If you want to verify or repair your main drive, you can simply use “/” as the drive name. So, type or paste the following:
diskutil verifyVolume /
Meanwhile, here’s how to verify an external disk:
- Type the command in this format:
diskutil verifyvolume /Volumes/[drive name]/
- For example, your external drive’s name is “Backup”, the command will look like this:
diskutil verifyvolume /Volumes/Backup/
The verification process will not always end with bad news, but when it does and any of the drives need to be repaired, the Terminal will show a message like this:
The volume [name of volume tested] was found corrupt and needs to be repaired.
At this point, you’ll need to decide whether to repair the corrupted disk using the Terminal or not. You can simply take note of the compromised disk and repair it at a later time using Disk Utility or another program such as Tweakbit MacRepair. However, if you really want to take your Terminal skills a step further, then go ahead and repair the disk right there and then. Read on for the steps to do so.
Repairing Disks in Mac Terminal
To repair a disk in the terminal, you will also need to type a particular command, which takes the following format:
diskutil repairvolume /Volumes/[drive name]/
For example, the external hard drive “Backup” was the one detected as corrupted, type in the following:
diskutil repairvolumne /Volumes/Backup/
The Terminal will now run a repair routine. All you have to do is wait for the dialog to finish. You will know the repair is already finished when you see this line:
Finished file system repair on disk1s1 [drive name]
Verifying and Repairing Disk Errors Automatically
Aside from the Disk Utility and Terminal, programs such as Tweakbit MacRepair can also be used to verify your Mac’s disks and repair any errors found. But even though it’s now 2018 and there are already a lot of ways to detect and fix errors on your Mac, it still pays to learn about old-school troubleshooting methods. Sooner or later, such knowledge may come in handy.
Have you tried using the Terminal to verify and repair your own Mac disks from the command line in OS X? We’d love to hear about your experience!