Format Flash Drive Mac Command Line

  1. Format Flash Drive Mac Fat32
  2. Reformat Flash Drive Mac

Alternatively, there is another step to fix/repair corrupted USB flash drive using CHKDSK command. Repair Corrupted USB Flash Drive Using CHKDSK Command. Below follow the steps: Step 1: Connect the corrupted flash drive to your PC. Step 2: On your computer click Start and type CMD in the search bar and hit ENTER. On the command-line: sudo apt install gparted 3 On the command line. To show the USB drive among all storage partitions and volumes on your computer use: lsblk You can also use: df Suppose it may be /dev/sdy1. Unmount it with: sudo umount /dev/sdy1 To format drive with the FAT32 file system format: sudo mkfs.vfat -F 32 /dev/sdy1. Formatting a Disk to MS-DOS fat32 from the Command Line in Mac OS X. Diskutil eraseDisk FAT32 DiskNameGoesHere /dev/DiskNodeIDHere. Formatting a Disk to ExFAT from the Command Line in Mac OS X. Diskutil eraseDisk ExFAT DiskName /dev/DiskNodeID. Again, any of these commands erase the entire target disk and obliterates any data on it.

Most users use Disk Utility to erase a disk or hard drive. But some Mac users might need to erase them from the command line on Mac OS. To do that, the only thing you need is a bit of precise syntax to make sure that you are erasing the proper disk.

Here I'll show you how you can erase and format a disk using the command line.

Working with Terminal
CommandFlash

Start off by running the following command in the command line: Diskutil list

Format Flash Drive Mac Fat32

This is going to list all the mounted drives on your Mac.

Once you have found the proper drive to erase, just copy its identifier so you can use it for the next command. Then pick a name and a system format type. This is the syntax we need: Diskutil eraseDisk FILESYSTEM DISKNAME DISKIDENTIFIER

Let’s say the disk I want to erase has “/dev/disk5s2” as its identifier and I’m going to use Mac OS Extended Journaled (JHFS+) as the system format type and name it “Empty”. The syntax is going to look like this: Diskutil eraseDisk JHFS+ Empty /dev/disk5s2

Reformat Flash Drive Mac

It’s important to keep in mind that if you run the eraseDisk command, the target disk is going to lose all its data, so make sure you are erasing the proper disk.

If you need different system format types, here are a few references you could use instead of JHFS+:

  • Mac OS Extended: HFS+
  • MS-DOS fat32: FAT32
  • ExFAT: ExFAT