Skip to content

diskutil MacOS command

The MacOS diskutil command is a powerful tool that allows users to manage disks and volumes on their Mac computers. With diskutil, you can format, partition, repair, and erase disks, as well as create and manage disk images. This command provides a comprehensive set of options for managing your storage in a reliable and efficient manner. Whether you need to troubleshoot disk issues, create backups, or optimize your storage space, diskutil has you covered. Familiarize yourself with the various functions and parameters of diskutil to effectively manage your MacOS disks.

diskutil Syntax:

Terminal window
diskutil [verb [options] [objects]]

Options:

OptionDescription
-eStay awake for disconnected devices
-fForce. Do not prompt for confirmation.
-hShow help for the given verb
-qQuiet mode. Print less information.
-vIncrease verbosity
-listList all disks and volumes
-mount pointMount the specified volume by specifying its path
-unmount forceForce the unmount of a volume
-resize sizeResize a volume to the specified size

Parameters:

ParameterDescription
verbThe diskutil operation to perform
objectsThe disks or volumes to operate on
optionsAdditional options for the operation

diskutil bash Examples:

List all connected disks

Terminal window
diskutil list

Display a list of all connected disks, including internal and external storage devices.

Erase a disk and format it as APFS

Terminal window
diskutil eraseDisk APFS NewDisk /dev/disk2

Format the disk located at /dev/disk2 as APFS and label it “NewDisk.”

Repair a disk

Terminal window
diskutil repairVolume /dev/disk2s1

Check and repair the disk located at /dev/disk2s1 for any issues.

Mount a disk

Terminal window
diskutil mount /dev/disk2s1

Mount the disk located at /dev/disk2s1 to make it accessible.

Unmount a disk

Terminal window
diskutil unmount /dev/disk2s1

Unmount the disk located at /dev/disk2s1 to safely remove it.

Resize a volume

Terminal window
diskutil resizeVolume /dev/disk2s1 50G

Resize the volume located at /dev/disk2s1 to 50GB in size.

diskutil Command Help Center:

How do I use diskutil in MacOS?

To use the diskutil command in MacOS, execute the following command:

Terminal window
diskutil --option <value>

How can I list all disks in MacOS using diskutil?

To list all disks in MacOS with diskutil, use the following command:

Terminal window
diskutil list

How do I format a disk in MacOS using diskutil?

To format a disk in MacOS with diskutil, you can use the following command:

Terminal window
diskutil eraseDisk <format> <name> <identifier>

How can I repair a disk in MacOS using diskutil?

To repair a disk in MacOS with diskutil, you can use the following command:

Terminal window
diskutil repairVolume <identifier>

How do I mount a disk in MacOS using diskutil?

To mount a disk in MacOS with diskutil, use the following command:

Terminal window
diskutil mount <identifier>

How can I unmount a disk in MacOS using diskutil?

To unmount a disk in MacOS with diskutil, you can use the following command:

Terminal window
diskutil unmount <identifier>

How do I check the available space on a disk in MacOS using diskutil?

To check the available space on a disk in MacOS with diskutil, use the following command:

Terminal window
diskutil info <identifier>

How can I enable or disable journaling on a disk in MacOS using diskutil?

To enable or disable journaling on a disk in MacOS with diskutil, you can use the following command:

Terminal window
diskutil enableJournaling <identifier>
diskutil disableJournaling <identifier>

Applications of the diskutil command

  • Partitioning disks
  • Mounting and unmounting volumes
  • Formatting disks and volumes
  • Verifying and repairing disks
  • Managing CoreStorage volumes
  • Managing RAID sets
  • Managing file systems
  • Mounting disk images