Although the functions of Apple's Disk Utility application aren't a traditional part of the Unix command-line environment at least not in a single application Apple has provided an interface to most Disk Utility functions through the diskutil program.
Table 10.26. The Command Documentation Table for diskutil
Modify, verify and repair local disks
diskutil <verb> [<options>]
Renames, ejects, mounts or unmounts disks and volumes.
Verbs and Their Available Options
Lists the disks currently known and available on the system, or on a specific device.
Get disk information on all, or a specific device.
unmount [force] <device>
Unmounts a single disk partition (volume) (for example, diskutil unmount /Volumes/MyDisk or diskutil unmount disk2s1)
unmountDisk [force] <device>
Unmounts an entire drive, and all partitions/volumes on it (for example, diskutil unmountDisk force /dev/disk1)
Ejects a disk
Mounts a single volume/partition (for example, diskutil mount disk2s2). (Useful when a volume has been unmounted by hand, and you want it back!)
Mount all volumes on a drive.
Controlling Disk Parameters and State
rename <device> <newname>
Renames volume. Renames the volume specified as the first argument. For example, diskutil rename /dev/disk1s2 Spanky or diskutil rename /Volumes/MyDisk /Volumes/YourDisk.
Reformats the <device> in the existing format.
randomDisk [times] <device>
Writes random data to <device>, optionally do it [times] times. Useful for wiping sensitive data that you don't want the black-helicopter crowd sniffing from your disk surface.
secureErase [level] <device>
Erase a disk using even more paranoia than randomDisk. Levels 1, 2, and 3 specify one-pass random data, US DoD 7-Pass secure erase mode, and Guttman algorithm 35-pass secure erase mode. Even the black helicopter crowd doesn't know how to get around this one.
Enable HFS+ journaling on the <device>
Checking and Repairing Disks
Verifies the structure of a volume.
Repairs the structure of a volume.
Repairs the permissions of an Mac OS X boot volume. Some people report constant, inexplicable problems with their disk permissions going awry, but we've never seen this happen on our machines.
CreateRAID mirror|stripe <name> <format> <device> <device> [<device> ...]
Creates a RAID set on multiple disks or volumes. Format can be HFS, HFS+, JournaledHFS+, UFS, MS-DOS. We've seen situations where creating a journaled RAID would not properly install the journal, and creating the RAID in HFS+ then enabling journaling separately was required.
Converts a single filesystem or volume into an unpaired mirror
RAID set (essentially a degraded mirrored RAID with no existing partner), or the beginning of a concatenated set.
Converts a RAID converted on Panther or earlier, to Tiger's new 2.x RAID. Personally, we're skeptical that we have the intestinal fortitude to try this with our 2.5 TB XServe RAID!
Repairs a failed mirror. <raidDisk> is the existing RAID, and <newDisk> is the replacement drive/volume to pair into the mirror. <raidDisk> and <newDisk> need to be a /dev/ nodes or disk identifiers.
<device> in these commands can be named volumes, such as /Volume/MyStuff, device nodes such as /dev/disk1s3 (disk 1, partiton 3) or /dev/disk1 (all of disk 1), or just the disk-identifier portion out of the device node name (i.e. disk1s3 or disk1). Some of these don't make sense in certain contexts, such as using the reformat verb on a full drive with multiple partitions, or the mount verb on a named volume. Apple's documentation doesn't suggest what will happen if you use a peculiar combination, so avoid the ones that don't make sense.