This article explains how to format a USB drive on Mac using the command-line. Even though using the Disk Utility tool to format your USB drive on Mac is a straightforward procedure, sometimes you might want to use the Terminal. Its use allows you to execute commands that provide the same result without having to rely on software applications. Just as with the Disk Utility method, macOS Mojave offers a simple, efficient formatting procedure through the use of its command line.

How to format a USB drive on Mac

Access the Terminal by doing a spotlight search for “Terminal.”

Result of the Spotlight search for Terminal

The first thing we will want to do is to identify the computer drive linked to your USB key. Make sure that you have inserted a USB drive before continuing. Enter the following command:

diskutil list

Screenshot of the diskutil list command output used to format a usb drive on mac.

You will find a list of disks; in the example above, you can see that my USB key is the external drive located on disk 2. You can identify your pen drive by the following:

When it says “(external, physical),” it means that it is an external drive such as a pen drive or external hard drive. If you see the words “internal,” “synthesized,” or “disk image,” it is not a pen drive.

It will be easier if you have a single flash drive inserted when wanting to format a USB drive using your Mac. Otherwise, look for the particularities of the pen drive you wish to use. Its size is the biggest giveaway.

Now that you know the disc allocated to your USB key, you will need to take note of its identifier and location. You will notice that your pen drive has two identifiers. That is unless you had previously partitioned it, in which case it might have more than two. The one that we want to remember is the first identifier, in this case, “disk2” (and not “disk2s2”, which is a partition). As for the location, it is usually /dev/[YOURDRIVE], or in this case /dev/disk2.

To format your USB drive on Mac, enter the following command:

sudo diskutil eraseDisk [FORMAT] [VOLUME-NAME] [USB-LOCATION-AND-NAME]


[FORMAT] is where you choose which format you want to use when erasing and formatting your pen drive. There are many file types available when you format a USB drive on Mac, such as exFAT, FAT32, JHFS+, etc. For a complete description and compatibility list (as not all formats are compatible with all operating systems), see this article. For reference purposes, exFAT and FAT32 are compatible with Windows, macOS, and Linux. JHFS+ refers to the Mac OS Extended Journaled format, which is proprietary to Apple and can only be used on macOS.

[VOLUME-NAME] is the name you want to give to your pen drive. For this example, it will be “Untitled.”

[USB-LOCATION-AND-NAME] is the name and location of your pen drive, which usually looks like “/dev/disk2” or “/dev/disk3”.

As we use the “sudo” command, you will be asked to enter your login password; the “sudo” command means that you are executing a command as an Admin.

MAKE SURE THAT YOU ARE USING THE CORRECT DISK WHEN EXECUTING THIS COMMAND. Unlike with the Disk Utility tool, the Terminal will give you NO WARNING before formatting the disk (and thus erasing its content). A single-digit mistake (for instance by typing disk0 or disk1 instead of disk2) could result in erasing your internal drive or another drive which wasn’t meat to be formatted.

In this example, the command looks like this:

sudo diskutil eraseDisk exFAT Untitled /dev/disk2

Screenshot of the command used to format a usb drive on mac.

*You might notice that you get no option to choose a partition table (GLOSSARY). By default, macOS uses MBR when you format a USB drive on Mac from the Terminal. However, there exists more than one partition table, the most popular ones being MBR and GPT. MBR refers to Master Boot Record, whereas GPT refers to GUID Partition Table. GPT is more technologically modern than MBR. However, you will need to use a third-party software called gdisk (click HERE for the SourceForge page) to use it in this procedure. However, the use of this tool is outside the scope of this article. Indeed, one of the reasons to use the Terminal to format a USB drive on Mac is to stick to a procedure that is readily available on your stock OS. 

Note: if you want to use your pen drive to burn the disk image of Windows 10, then you have to use MBR for your boot loader partition. Otherwise, Windows will not recognize nor initiate the boot sequence.

Now, wait. The command line will give you a percentage timeline while formatting your drive. After a short time (less than a minute), the process will be completed, and you will see a written recap of what just happened. In this example, it looks like this:

Written recap of the procedure used to format a usb drive on mac.

Started erase on disk2

Unmounting disk

Creating the partition map

Waiting for partitions to activate

Formatting disk2s2 as ExFAT with name Untitled

Volume name : Untitled

Partition offset : 411648 sectors (210763776 bytes)

Volume size : 15245312 sectors (7805599744 bytes)

Bytes per sector : 512

Bytes per cluster: 32768

FAT offset : 2048 sectors (1048576 bytes)

FAT sectors : 2048

Number of FATs : 1

Cluster offset : 4096 sectors (2097152 bytes)

Clusters : 238144

Volume Serial # : 5d5ec376

Bitmap start : 2

Bitmap file size : 29768

Upcase start : 3

Upcase file size : 5836

Root start : 4

Mounting disk

Finished erase on disk2

All is set and done! You have completed the procedure to successfully format your USB drive on Mac. You can now safely eject your pen drive. To do so, unmount it using the command line by typing:

diskutil unmount /dev/disk2s2

*Alternatively, if you have more than one external drive connected you might have to indicate a different drive, such as /dev/disk3s2.

A note regarding USB drives

You can use any old pen drive laying around to burn a disk image or stock data. However, as with most things tech-related, the better the hardware, the easier the process. For instance, the type of USB you choose (USB 2.0 vs. USB 3.0 vs. USB 3.1) will have an impact on the data transfer speed. The brand you opt for (e.g., a free pen drive received as a promotional item from your dentist vs. a SanDisk USB flash drive) will also have an impact. The better recognized the brand and the better its hardware reputation, the fewer chances you will have of having your electronics fail on you at a critical time. 

As we are talking about a USB flash drive procedure, I figured why not add some high-tech pen drives recommendations to this article. 

Because we are dealing with the sleek designs of a MacBook Air, MacBook Pro or Mac desktop computer, I kept the appealing design of this machine in mind when selecting the following USB drives. You will notice that they all have a metal finish, which doesn’t clash as much with your computer as those bulky plastic pen drives.

I have not personally tested these USB keys. However, I feel confident about their performance judging by the numerous, well-detailed reviews available for these particular models. As always, YMMV. These flash drives are for those that are looking for some serious performance from their electronics.

SanDisk Ultra Flair USB 3.0 (128 GB)

SanDisk Ultra Flair USB 3.0 128GB Flash Drive High Performance up to 150MB/s (SDCZ73-128G-G46)

And for the security and tech aficionados, a 64 GB Lexar USB drive with fingerprint authentication (up to 10 fingerprint IDs allowed, no software needed)

LEXAR LJDF35-64GBNL Lexar 64GB JumpDrive Fingerprint F35 USB 3.0 Flash Drive

Note that the two links posted above are affiliate links. If you go through them to make a purchase, I will earn a commission (at no cost to you). I link these companies and their products because of their quality and not because of the commission I receive from your purchases. These links are used to pay for the cost and upkeep of Thank you!

Owner and content creator behind Geeky girl and blogger based in Montreal, Canada. Chocolate and nature lover (in that order). View all posts by Larryssa →


  1. Hello,

    Great, easy to follow instructions with a useful warning about the dangers! I get the error “Untitled does not appear to be a valid volume name for its file system” when I in put sudo diskutil eraseDisk FAT32 Untitled /dev/disk8 , do you know why? Other named failed also.

    I may buy a new USB drive.

  2. Hi Ben, I’m glad you found the article useful. Has the issue been resolved? If not, capitalizing every letter in the VOLUME-NAME and the USB-LOCATION-AND-NAME you are specifying in the “sudo diskutil eraseDisk [FORMAT] [VOLUME-NAME] [USB-LOCATION-AND-NAME]” command should do the trick. Hope that helps!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: