Wednesday, April 7, 2010

Diskutil command

diskutil is a Mac OS X command that provides information about, and allows the administration of, the partitioning scheme of disks, optical discs, and AppleRAID sets.

One example is run the command diskutil list in Terminal.  The result is a list of all disks and all of their partitions are listed.



In the example above:

disk0 is the hard drive in my Mac Mini
disk1 is the attached Drobo
disk2 is the dvd.

Here are some other examples taken from the Man Pages:

Erase a disk
diskutil eraseDisk UFS UntitledUFS disk3

Erase a volume
diskutil eraseVolume HFS+ UntitledHFS /Volumes/SomeDisk

Partition a disk with three partitions
diskutil partitionDisk disk3 3 HFS+ Untitled 10G UFS UntitledUFS 10G MS-DOS DOS 10G

Partition a disk with the APM partitioning scheme
diskutil partitionDisk disk3 APM HFS+ vol1 25% Journaled HFS+ vol2 25% Journaled HFS+ vol3 50% Free Space volX 0%

Partition a disk with the GPT partitioning scheme
diskutil partitionDisk disk3 GPT HFS+ vol1 25% MS-DOS vol2 25% HFS+ vol3 50% Free Space volX 0%

Resize a volume and create a volume after it, using all remaining space
diskutil resizeVolume /Volumes/SomeDisk 50g MS-DOS DOS 0b

Resize a volume and leave all remaining space as unused
diskutil resizeVolume /Volumes/SomeDisk 12g

Merge two partitions into a new partition
diskutil mergePartitions JHFS+ not disk1s3 disk1s5

Split a partition into three new ones
diskutil splitPartition /Volumes/SomeDisk JHFS+ vol1 12g MS-DOS vol2 8g JHFS+ vol3 0b

Create a RAID
diskutil createRAID mirror MirroredVolume JHFS+ disk1 disk2

Destroy a RAID
diskutil destroyRAID /Volumes/MirroredVolume

Repair a damaged RAID
diskutil repairMirror /Volumes/MirroredVolume disk3

Convert volume into RAID volume
diskutil enableRAID mirror /Volumes/ExistingVolume

If seeing all these examples makes you nervous, then stick with the Disk Utility gui app!

1 comment:

  1. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.
    have a peek here

    ReplyDelete