Sign in

How to Format a USB Drive on Mac on CLI

For some reason, DiskUtility in UI might not be able to format USB drive successfully, as an alternatively, CLI could solve the issue.

  1. Type the following command and hit enter to list all the mounted devices available in your system:
    diskutil list

2. From this list, go ahead and select the device that you want to format and use the Terminal to format it.

Use the following syntax to format the drive:


3. For the Disk name, you can enter any name you want to give your device.

To find your Disk identifier, refer to the list you found after typing the command diskutil list.

Under the IDENTIFIER column, you’ll find your identifier.

The file system option depends on your preference. The syntax is:.

  • Formatting to MacOS Extended Journaled(JHFS+) — JHFS+
  • Formatting to MacOS Extended (HFS+) — HFS+
  • Formatting to MS-DOS FAT — FAT32
  • Formatting to ExFAT — ExFAT

For example, if you want to format your drive to macOS Extended Journaled and rename it to “MyDisk,” you can enter the terminal command as below:

diskutil erasedisk JHFS+ MyDisk disk2