Formatting a Hard Drive from the Mac OS X Command Line

Late last night I got a text message from a client asking how one goes about formatting a hard drive from the command line on Mac OS X. So instead of simply sending over the directions to him this morning, I figured I would provide them to the world. These way next time someone calls asking, I can simply point them in the direction of this wonderful little how to post.

How to Format A Hard Drive from Terminal

  1. Launch the command line app found at the following location /Applications/Utilities/
  2. Type the below listed command, which will provide you a list of all the volumes mounted on your machine:
    diskutil list
  3. Using the results of the above command determine which drive it is you are trying to format. You are going to need the information displayed in the IDENTIFIER Column.
  4. Once you have identified the drive to format you are going to issue the command found below, replace JHFS+ please the file system you want to use, JHFS+ is for the standard mac os journaled file system. Replace the text NEWDISK with what you want to call the volume, and last but not least insert the IDENTIFIER for the drive where {disk identifier} is. Not that when putting in the disk identifier you should only include the portion that is “disk#”, the “S” and the number following it should be left off. The S identifies a portion on the disk. Since you are reformatting the drive the partition is not a factor, unless you want to setup partitions on the drive but thats a how to for another blog post on another day.
    diskutil eraseDisk JHFS+ NEWDISK /dev/{disk identifier}

    If you need to know which file systems your machine supports the following command will provide you a list of file systems and the shorted version to use in the above command.

    diskutil listFilesystems

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This site uses "tracking cookies" on your computer to deliver the best experience possible. To learn how these cookies are used please review our Privacy Policies by clicking here. Your continued use of this site indicates you have read and agree to our Terms of Use and Privacy Policies, collectively known as "the agreement". If you do not agree to this agreement or are not authorized to utilize the site because of the conditions of the agreement. Please close your browser now. This notice will be provided once every seven calendar days.