Skip to main content

diskutil

Format a USB drive with an ESXi installer

I heavily borrowed this approach and associated commands from this Github project. To prep:

  • Download the ESXi ISO file to a folder on your machine and name it esxi.iso
  • Download the syslinux.cfg file from the Github project link into the same folder
  • In Terminal, cd to the destination directory where these two files live and do this:

Terminal commands

diskutil list

(This command is to identify your USB drive...in most cases it's /dev/disk2 but be careful!!! My commands below assume /dev/disk2!!11!111!!!!)

sudo diskutil eraseDisk MS-DOS ESXI MBR /dev/disk2
mkdir -p source
mkdir -p target
hdiutil mount esxi.iso -mountpoint ./source
cp -r source/ /Volumes/ESXI/
cp syslinux.cfg /Volumes/ESXI/
hdiutil eject ./source
diskutil unmountDisk /dev/disk2
diskutil eject /dev/disk2

Secure erase the primary Mac OS drive

First create a USB install of Mac OS, boot to it, and drop to Terminal. Then find your physical disk path:

diskutil list

Unmount it (in my case disk0):

diskutil unmountDisk disk0

Then secure erase it:

diskutil secureErase 2 disk0

(Run diskutil secureErase) to see all the options. I did option 2 which is a seven-pass "secure" erase)