TechSpace Knowledgebase
Search:     Advanced search
Browse by category:
Contact Us

How to Verify and Repair a Disk From the OS X Command Line

Views: 569
Votes: 1
Posted: 09 Sep, 2017
by: Poh-ek C.
Updated: 09 Sep, 2017
by: Poh-ek C.

How to Verify and Repair a Disk From the OS X Command Line

The Disk Utility application is a powerful tool for keeping the drives that are connected to your Mac happy and healthy. But there are situations in which it may not be available. As an example, connecting to a remote computer via SSH, or Disk Utility simply refusing to launch.  

In this tutorial, Iíll show you how to:

  • Find a disk that may have an error
  • Verify a disk from the command line
  • Repair that disk (if need be) from the command line


Important Notes

Before I take you any further, you need to understand a couple of things:

  1. I will be working on an SD Card I have inserted into my mac. If you need to target your Mac's hard drive, make sure you substitute the word Macintosh HD for SD in any of the commands I am showing in this article.
  2. These instructions are not meant for novice Mac users. If you aren't at least a bit comfortable in Terminal, you may want to stick to the graphical user interface applications like Disk Utility.

Locating the Disk

All of the disks that are attached to the Mac are located within the Volumes directory in Terminal. This directory is located one step away from the root of the Mac. The command used to switch from directory to directory is cd. In the terminal a /is known as the root, or lowest level, directory.

So to switch to the Volumes directory, open Terminal and type or paste in this command: cd /Volumes. The Terminal window should now look very similar to this:

Accessing the Volumes directory from the OSX Terminal

Accessing the Volumes directory from the OSX Terminal

Type ls and press Return. Youíll be shown a list of disks attached to your Mac.

Verify the Disk

Once you have the list of disks, you can target one or many of them for verification and repair. To start the verification process, type the following command, while being sure to substitute the [drive identifier] portion for the actual name of the drive.  

diskutil verifyVolume [drive identifier]

If you are targeting the Mac's hard drive you can also simply use a /. You will see something that looks like this:

Verifying a Disk via Terminal in OSX

Verifying a Disk via Terminal in OSX

This test came back successful. So I can be confident in the drive and its ability to store data. If there was an error I would see a message that reads: The volume [volume tested] was found corrupt and needs to be repaired.

Repairing the Disk

Assume, for a moment, that the disk did come back with an error or needing repair. To repair a disk from the command line, type or paste the following command into terminal: diskutil repairvolume /Volumes/[drive identifier]/ and press Return.

Just as before, Iíll use SD as my drive identifier. If you wish to target a different drive, insert the name of that drive instead of SD. You may also use / as the identifier for your Mac's hard drive. Your Terminal window should now look similar to this:

Repairing a disk from Terminal in OSX

Repairing a disk from Terminal in OSX

Congratulations! Your disk has now been verified and repaired entirely from the command line.


Others in this Category
document How to Install Windows on a Mac With Boot Camp
document Introduction to the Mac OS X Command Line
document How to reinstall OS X from recovery
document How to repairing a Boot Disk with Disk Utility
document How to Create Bootable USB From a Windows ISO for Mac
document How to Reinstall OS X from Recovery
document Safari crashing when typing in search bar
document How to find out the charge cycle count on an Apple Mac
document Zip files do not unzip Mac OSX
document How to Fix iTunes Error 3194 Successfully on iPhone/iPad/iPod
document Reset the System Management Controller (SMC) on your Mac
document Move a PiP Video Player Window Anywhere on Mac
document Sort Folders and Files on Mac Just Like Windows With a Single Setting Switch
document Create Hidden Administrative Accounts in OS X from the Terminal
document Six Keyboard Shortcuts Every Computer User Should Know
document How to Upgrade Your Computer's Login Screen
document How to Map a Network Drive on a Mac
document How to require a password for shared printers in OS X
document How to Switch from one language to another on Mac
document How to take a screenshot on your Mac
document Map a Network Drive on a Mac
document Use Disk Utility to Create a RAID 0 (Striped) Array
document Tired of the Apple logo on the back of your iPhone 6/6 Plus panel? Use this DIY to install cool LED in its place
document How to transfer photos from your iphon to a computer
document How to update Chrome On Mac
document How to install Windows 10 on a Mac
document Set up an email account on your iPhone, iPad, or iPod touch
document How to Add & Switch Languages in Mac OS X
document How to Manually Install Fonts on Your Mac
document How to Password Protect a Folder in a Mac
document How to Set Up Network File Sharing on macOS, Without Sharing Your Username and Password
document Use Preview to combine PDFs on your Mac
document How to use Hot Corners on Mac
document How to edit your Mac's Hosts file and why you would want to
document How to reset your Mac before selling it.
document How to use Continuity Camera on macOS Mojave and iOS 12.
document macOS Mojave: How to troubleshoot common problems
document Formatting External Hard Drive or USB Drive
document About the screens your Mac displays as it starts up.
document Mac startup key combinations.