Repair and manage disk drives using Diskutil on the Mac
Disk Utility is a useful tool in OS X on the Mac and you can use it to format disks, partition them, erase them and repair them. However, it is not the only utility that is able to do this and there is a command prompt tool called diskutil that can perform all this and more. It has a lot of functions, but learning a few key ones could help in certain situations, such as when you can't run Disk Utility. Here's an introduction to diskutil to get you started.
Diskutil only works from a command prompt, so go to the Utilities folder and run Terminal. In the terminal window type
The simplest command and the most essential, is list. Type
Look at the identifier column on the right. The first item is disk0, which is the internal hard disk drive in this Mac. The items below are the partitions on it and disk0s1, called EFI, is used for booting the Mac and is essential. The next partition is disk0s2 and this is called Apple_HFS Macintosh HD. It is 118.5Gb and this is the main boot disk containing OS X and all the files and applications. The third item, disk0s3, is Apple_Boot Recovery HD and it is OS X Lion's recovery partition.
Suppose you want to get detailed information about one of the partitions, such as disk0s2. You would enter
Format and erase
Diskutil can be used for format disks and to see what file systems are supported, enter
You can also use
Don't actually do these unless you are absolutely sure you have selected the right partition. For example, disk0s2 in the screen shot is the partition with OS X on and it wouldn't be a good idea to erase it!
Verify and repair the disk
Here are a couple of commands that are safe to use,
More information on diskutil
I have only covered the easy uses of diskutil here and there are many more useful functions that it can perform. However, it does get a bit more complicated and erasing, repairing and formatting are probably all most people need. Get more information on diskutil at the online manual.
blog comments powered by Disqus