# diskutil — Manage Disks and Volumes

> Practical guide to diskutil — manage macOS disks, volumes and partitions: list, format, mount, verify, repair and handle APFS containers.

Source: https://www.jpkc.com/db/en/cheatsheets/macos/diskutil/

<!-- PROSE:intro -->
`diskutil` is the command-line counterpart to Disk Utility and your central tool for managing disks, volumes and partitions on macOS straight from the terminal. You list devices, mount and unmount volumes, format them and verify or repair filesystems – and you create, resize or snapshot APFS containers along the way. This guide takes you from the harmless listing and info commands to the powerful format and partition operations you should handle with care.
<!-- PROSE:intro:end -->

## List & Info

`diskutil list` — List all disks and partitions.

```bash
diskutil list
```

`diskutil list internal` — List only internal disks.

```bash
diskutil list internal
```

`diskutil list external` — List only external disks.

```bash
diskutil list external
```

`diskutil info <disk>` — Show detailed info about a disk or partition.

```bash
diskutil info disk0s1
```

`diskutil info -all` — Show info for all disks.

```bash
diskutil info -all
```

`diskutil activity` — Monitor disk activity in real-time.

```bash
diskutil activity
```

## Mount & Unmount

`diskutil mount <disk>` — Mount a volume.

```bash
diskutil mount disk2s1
```

`diskutil mountDisk <disk>` — Mount all volumes on a disk.

```bash
diskutil mountDisk disk2
```

`diskutil unmount <disk>` — Unmount a volume.

```bash
diskutil unmount disk2s1
```

`diskutil unmountDisk <disk>` — Unmount all volumes on a disk.

```bash
diskutil unmountDisk disk2
```

`diskutil unmount force <disk>` — Force unmount a volume.

```bash
diskutil unmount force disk2s1
```

`diskutil eject <disk>` — Eject a disk (unmount and remove from system).

```bash
diskutil eject disk2
```

## Format & Erase

> **Warning – irreversible data loss:** `eraseDisk`, `eraseVolume`, `partitionDisk` and `reformat` destroy data permanently (complete data loss!). Always double-check the target `diskN` with `diskutil list` before running them – a wrong identifier will format the wrong drive.

`diskutil eraseDisk <format> <name> <disk>` — Erase an entire disk and create a single partition.

```bash
diskutil eraseDisk APFS MyDisk disk2
```

`diskutil eraseVolume <format> <name> <disk>` — Erase a single volume/partition.

```bash
diskutil eraseVolume APFS Data disk2s1
```

`diskutil eraseDisk ExFAT USBDrive MBRFormat <disk>` — Format a USB drive as ExFAT with MBR (cross-platform).

```bash
diskutil eraseDisk ExFAT USBDrive MBRFormat disk2
```

`diskutil eraseDisk JHFS+ TimeMachine GPT <disk>` — Format as HFS+ with GPT (for Time Machine).

```bash
diskutil eraseDisk JHFS+ TimeMachine GPT disk2
```

`diskutil secureErase freespace 1 <disk>` — Securely erase free space (1-pass zeros).

```bash
diskutil secureErase freespace 1 /Volumes/Macintosh\ HD
```

## APFS Operations

`diskutil apfs list` — List all APFS containers and volumes.

```bash
diskutil apfs list
```

`diskutil apfs addVolume <container> APFS <name>` — Add a new volume to an APFS container.

```bash
diskutil apfs addVolume disk1 APFS Data
```

`diskutil apfs deleteVolume <volume>` — Delete an APFS volume.

```bash
diskutil apfs deleteVolume disk1s3
```

`diskutil apfs resizeContainer <container> <size>` — Resize an APFS container.

```bash
diskutil apfs resizeContainer disk1 200G
```

`diskutil apfs listSnapshots <volume>` — List APFS snapshots on a volume.

```bash
diskutil apfs listSnapshots disk1s1
```

`diskutil apfs deleteSnapshot <volume> -name <name>` — Delete a specific APFS snapshot.

```bash
diskutil apfs deleteSnapshot disk1s1 -name com.apple.TimeMachine.2026-03-19
```

## Verify & Repair

`diskutil verifyDisk <disk>` — Verify the partition map of a disk.

```bash
diskutil verifyDisk disk0
```

`diskutil verifyVolume <disk>` — Verify the filesystem on a volume.

```bash
diskutil verifyVolume disk1s1
```

`diskutil repairDisk <disk>` — Repair the partition map of a disk.

```bash
sudo diskutil repairDisk disk0
```

`diskutil repairVolume <disk>` — Repair the filesystem on a volume.

```bash
sudo diskutil repairVolume disk1s1
```

## Partitions

`diskutil partitionDisk <disk> <n> GPT <format1> <name1> <size1> <format2> <name2> <size2>` — Partition a disk with multiple partitions.

```bash
diskutil partitionDisk disk2 2 GPT APFS Data 100G ExFAT Shared R
```

`diskutil addPartition <disk> <format> <name> <size>` — Add a partition to a disk.

```bash
diskutil addPartition disk2 ExFAT Extra 50G
```

`diskutil splitPartition <disk> <n> <format1> <name1> <size1>` — Split an existing partition.

```bash
diskutil splitPartition disk2s2 2 APFS Part1 50G ExFAT Part2 R
```

`diskutil mergePartitions <format> <name> <first> <last>` — Merge adjacent partitions.

```bash
diskutil mergePartitions APFS Merged disk2s2 disk2s3
```

<!-- PROSE:outro -->
## Conclusion

`diskutil` covers virtually everything the graphical Disk Utility can do – only faster, scriptable and usable over SSH. For everyday work, `list`, `info`, `mount` and `unmount` are all you need; the destructive verbs like `eraseDisk`, `partitionDisk` and `reformat` run without a confirmation prompt and without a trash – a single wrong `diskN` identifier can wipe an entire drive beyond recovery. Always identify the target with `diskutil list` first and check it a second time before you hit Enter.

## Further Reading

- [diskutil(8) – man page](https://www.manpagez.com/man/8/diskutil/) – complete reference of all verbs and options
- [Apple Support – Disk Utility](https://support.apple.com/guide/disk-utility/welcome/mac) – official documentation for the graphical counterpart
<!-- PROSE:outro:end -->

## Related Commands

- [caffeinate](https://www.jpkc.com/db/en/cheatsheets/macos/caffeinate/) – prevent the Mac from going to sleep
- [defaults](https://www.jpkc.com/db/en/cheatsheets/macos/defaults/) – read and write macOS preferences
- [dscl](https://www.jpkc.com/db/en/cheatsheets/macos/dscl/) – Directory Service command line for users and groups

