< Day Day Up > 

Mounting/Unmounting Volumes: diskutil

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.

diskutil lets the user mount and unmount volumes, eject disks, rename volumes, work with RAID sets and do some rudimentary disk repairs. diskutil can also be used to good effect in concert with the hdiutil command, which we cover in Chapter 29. The syntax and some important options for diskutil are shown in Table 10.26.

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


list [device]

Lists the disks currently known and available on the system, or on a specific device.

info [device]

Get disk information on all, or a specific device.

Managing Disks

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)

eject <device>

Ejects a disk

mount <device>

Mounts a single volume/partition (for example, diskutil mount disk2s2). (Useful when a volume has been unmounted by hand, and you want it back!)

mountDisk <device>

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.

reformat <device>

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.

enableJournal <device>

Enable HFS+ journaling on the <device>

Checking and Repairing Disks

verifyVolume <device>

Verifies the structure of a volume.

repairVolume <device>

Repairs the structure of a volume.

repairPermissions <device>

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.

RAID Tools

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.

enableRAID mirror|concat

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.

convertRAID <device>

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!

repairMirror <raidDisk>


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.

     < Day Day Up > 

    Mac OS X Tiger Unleashed
    Mac OS X Tiger Unleashed
    ISBN: 0672327465
    EAN: 2147483647
    Year: 2005
    Pages: 251 © 2008-2017.
    If you may any questions please contact us: