How to format EFI and delete partition usb drive from mac terminal

how to format EFI usb drive from terminal mac

Formatting a USB drive to the FAT32 file system on a Mac is a common requirement for users who need compatibility across different operating systems. FAT32 is compatible with Mac OS X/macOS, Windows, Linux, and DOS systems. There are two methods you can use to format a USB drive to FAT32 on your Mac: using Disk Utility or Terminal command line.

Method 1: Format USB to FAT32 with Disk Utility

Before formatting, ensure you have backed up any important data on the USB drive, as the process will erase all existing data.

  1. Connect the USB flash drive to your Mac computer.
  2. Go to "Applications > Utilities" and open "Disk Utility".
  3. In the sidebar, select your USB flash drive.
  4. Click on the "Erase" tab.
  5. Optionally, rename the USB flash drive.
  6. Choose "MS-DOS (FAT)" for the Format and "Master Boot Record" for the Scheme.
  7. Click "Erase" to begin the formatting process.

Wait for the process to complete, and you'll have a formatted USB flash drive with the FAT32 file system.

Method 2: Format USB to FAT32 with Terminal Command Line

Make sure to back up any important data on the USB drive before proceeding.

  1. Connect the USB flash drive to your Mac computer.
  2. Press "cmd + space" to open Spotlight, type "terminal," and press Enter.
  3. In the Terminal window, type "diskutil list" to identify the disk number of your USB drive.
  4. Type the following command, replacing "/dev/disk2" with the appropriate disk number for your USB drive:

  5. bash
    sudo diskutil eraseDisk FAT32 MBRFormat /dev/disk2


  6. Press Enter to execute the command.

Wait for the process to complete. You can use the command "diskutil list" again to verify if the formatting was successful.

Bonus Tip: Recovering Data from a Formatted USB

If you accidentally lost data during the formatting process, you can use data recovery software like EaseUS Data Recovery Wizard to recover the lost files.

  1. Connect your USB drive to your Mac.
  2. Download and launch EaseUS Data Recovery Wizard for Mac.
  3. Select the USB drive and click "Search for lost files" to start the scanning process.
  4. After the scan completes, you can preview the recovered files.
  5. Select the files you want to recover and click the "Recover" button.

Remember not to save the recovered files back to the USB drive to avoid overwriting data.

Formatting a USB drive to FAT32 on a Mac is a straightforward process. Both Disk Utility and Terminal command line can be used for this purpose. Just ensure you have a backup of your USB drive before formatting. In case of data loss, you can rely on data recovery software like EaseUS Data Recovery Wizard for Mac to recover your files.

@Mac-mini ~ % diskutil list internal

/dev/disk0 (internal, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *512.1 GB   disk0

   1:                        EFI ⁨EFI⁩                     209.7 MB   disk0s1

   2:                 Apple_APFS ⁨Container disk1⁩         511.9 GB   disk0s2


/dev/disk1 (synthesized):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      APFS Container Scheme -                      +511.9 GB   disk1

                                 Physical Store disk0s2

   1:                APFS Volume ⁨MacSSD - Data⁩           15.1 GB    disk1s1

   2:                APFS Volume ⁨Preboot⁩                 270.8 MB   disk1s2

   3:                APFS Volume ⁨Recovery⁩                1.1 GB     disk1s3

   4:                APFS Volume ⁨VM⁩                      1.1 MB     disk1s4

   5:                APFS Volume ⁨MacSSD⁩                  15.4 GB    disk1s5

   6:              APFS Snapshot ⁨com.apple.os.update-...⁩ 15.4 GB    disk1s5s1


@Mac-mini ~ % diskutil list         

/dev/disk0 (internal, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *512.1 GB   disk0

   1:                        EFI ⁨EFI⁩                     209.7 MB   disk0s1

   2:                 Apple_APFS ⁨Container disk1⁩         511.9 GB   disk0s2


/dev/disk1 (synthesized):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      APFS Container Scheme -                      +511.9 GB   disk1

                                 Physical Store disk0s2

   1:                APFS Volume ⁨MacSSD - Data⁩           15.1 GB    disk1s1

   2:                APFS Volume ⁨Preboot⁩                 270.8 MB   disk1s2

   3:                APFS Volume ⁨Recovery⁩                1.1 GB     disk1s3

   4:                APFS Volume ⁨VM⁩                      1.1 MB     disk1s4

   5:                APFS Volume ⁨MacSSD⁩                  15.4 GB    disk1s5

   6:              APFS Snapshot ⁨com.apple.os.update-...⁩ 15.4 GB    disk1s5s1


/dev/disk2 (external, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *31.0 GB    disk2

   1:                        EFI ⁨⁩                        209.7 MB   disk2s1

   2:       Microsoft Basic Data ⁨NEW VOLUME⁩              30.8 GB    disk2s2


@Mac-mini ~ % sudo diskutil eraseDisk FAT32 MBRFormat /dev/disk2

Password:

MBRFormat does not appear to be a valid volume name for its file system



  • sudo provides you user right.
  • Diskutil provides disk utility program.
  • eraseDisk provides commands to format.
  • FAT32 provides sets the file system.
  • MBRFormat provides  disk utility to format with a Master Boot Record.
  • /dev/disk2 location of the pen drive.



@Mac-mini ~ % diskutil eraseVolume "Free Space" ExEFI disk2s1 

Started erase on disk2s1

Unmounting disk

Finished erase on disk2


@Mac-mini ~ % diskutil list

/dev/disk0 (internal, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *512.1 GB   disk0

   1:                        EFI ⁨EFI⁩                     209.7 MB   disk0s1

   2:                 Apple_APFS ⁨Container disk1⁩         511.9 GB   disk0s2


/dev/disk1 (synthesized):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      APFS Container Scheme -                      +511.9 GB   disk1

                                 Physical Store disk0s2

   1:                APFS Volume ⁨MacSSD - Data⁩           15.2 GB    disk1s1

   2:                APFS Volume ⁨Preboot⁩                 270.8 MB   disk1s2

   3:                APFS Volume ⁨Recovery⁩                1.1 GB     disk1s3

   4:                APFS Volume ⁨VM⁩                      1.1 MB     disk1s4

   5:                APFS Volume ⁨MacSSD⁩                  15.4 GB    disk1s5

   6:              APFS Snapshot ⁨com.apple.os.update-...⁩ 15.4 GB    disk1s5s1


/dev/disk2 (external, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *31.0 GB    disk2

   1:       Microsoft Basic Data ⁨NEW VOLUME⁩              30.8 GB    disk2s2


@Mac-mini ~ % diskutil eraseVolume "Free Space" ExEFI disk2s2


Started erase on disk2s2 (NEW VOLUME)

Unmounting disk

Finished erase on disk2


diskutil eraseVolume


@Mac-mini ~ % diskutil list

/dev/disk0 (internal, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *512.1 GB   disk0

   1:                        EFI ⁨EFI⁩                     209.7 MB   disk0s1

   2:                 Apple_APFS ⁨Container disk1⁩         511.9 GB   disk0s2


/dev/disk1 (synthesized):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      APFS Container Scheme -                      +511.9 GB   disk1

                                 Physical Store disk0s2

   1:                APFS Volume ⁨MacSSD - Data⁩           15.2 GB    disk1s1

   2:                APFS Volume ⁨Preboot⁩                 270.8 MB   disk1s2

   3:                APFS Volume ⁨Recovery⁩                1.1 GB     disk1s3

   4:                APFS Volume ⁨VM⁩                      1.1 MB     disk1s4

   5:                APFS Volume ⁨MacSSD⁩                  15.4 GB    disk1s5

   6:              APFS Snapshot ⁨com.apple.os.update-...⁩ 15.4 GB    disk1s5s1


/dev/disk2 (external, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *31.0 GB    disk2



@Mac-mini ~ % sudo diskutil eraseDisk FAT32 /dev/disk2 

Password:

Usage:  diskutil eraseDisk format name [APM[Format]|MBR[Format]|GPT[Format]]

        MountPoint|DiskIdentifier|DeviceNode

(Re)-partition a whole disk (create a new partition map). This completely

erases any existing data on the given whole disk; all volumes on this disk

will be destroyed. Format is the specific file system name you want to erase it

as (HFS+, etc.). Name is the (new) volume name (subject to file system naming

restrictions), or can be specified as %noformat% to skip initialization

(newfs). You cannot erase the boot disk.

Ownership of the affected disk is required.

Example: diskutil eraseDisk JHFS+ UntitledUFS disk3



@Mac-mini ~ % diskutil list                           

/dev/disk0 (internal, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *512.1 GB   disk0

   1:                        EFI ⁨EFI⁩                     209.7 MB   disk0s1

   2:                 Apple_APFS ⁨Container disk1⁩         511.9 GB   disk0s2


/dev/disk1 (synthesized):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      APFS Container Scheme -                      +511.9 GB   disk1

                                 Physical Store disk0s2

   1:                APFS Volume ⁨MacSSD - Data⁩           15.2 GB    disk1s1

   2:                APFS Volume ⁨Preboot⁩                 270.8 MB   disk1s2

   3:                APFS Volume ⁨Recovery⁩                1.1 GB     disk1s3

   4:                APFS Volume ⁨VM⁩                      1.1 MB     disk1s4

   5:                APFS Volume ⁨MacSSD⁩                  15.4 GB    disk1s5

   6:              APFS Snapshot ⁨com.apple.os.update-...⁩ 15.4 GB    disk1s5s1


/dev/disk2 (external, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:     FDisk_partition_scheme                        *31.0 GB    disk2

   1:                 DOS_FAT_32 ⁨UNTITLED⁩                31.0 GB    disk2s1


@Mac-mini ~ %