Diskutil - Mac OS X Disk Management Utility

Manage local disks and volumes on Mac OS X with the diskutil command. Learn to list, repair, unmount, and eject disks efficiently.

Diskutil

Diskutil Command Overview

The diskutil command is a powerful command-line utility for Mac OS X that allows users to manage local disks and volumes. It provides a comprehensive set of functions for inspecting, repairing, and manipulating storage devices directly from the terminal. Understanding and utilizing diskutil is essential for system administrators and advanced users who need fine-grained control over their Mac's storage.

Core Diskutil Operations

Here are some of the most common and essential operations you can perform with the diskutil command:

Listing Disks and Volumes

To see a detailed breakdown of all available disks, their partitions, and currently mounted volumes, use the list subcommand. This is often the first step in diagnosing disk-related issues or understanding your storage configuration.

# List all currently available disks, partitions and mounted volumes:
diskutil list

Repairing File System Integrity

If you suspect data corruption or encounter errors with a volume, diskutil can attempt to repair the file system data structures. Replace /dev/diskX with the identifier of the volume you wish to repair.

# Repair the file system data structures of a volume:
diskutil repairVolume /dev/diskX

Unmounting and Ejecting Disks

Before physically removing a disk or to ensure data is safely written, you can unmount a volume. For removable media like CDs/DVDs, you can then eject them.

# Unmount a volume:
diskutil unmountDisk /dev/diskX

# Eject a CD/DVD (unmount first):
diskutil eject /dev/disk1

Further Disk Management

The diskutil utility offers many more advanced features, including creating, resizing, deleting, and formatting partitions, as well as managing RAID sets and CoreStorage volumes. For comprehensive details and advanced usage, consult the official macOS documentation or the man diskutil page in your terminal.

For more information on disk management and file systems, you can refer to resources like: