Linux: How to Manually Create a USB Bootable Drive for ESXi

Step 1: Find the USB mount
root@kimlinux:/home/kim# ls /dev/s*
/dev/sda /dev/sdb1 /dev/sdb3 /dev/sdc1 /dev/sg1 /dev/snapshot /dev/stdin
/dev/sdb /dev/sdb2 /dev/sdc /dev/sg0 /dev/sg2 /dev/stderr /dev/stdout

lttng-ust-wait-7 lttng-ust-wait-7-1000

by-id controlC0 controlC2 hwC0D2 pcmC0D0p pcmC0D3p pcmC0D8p pcmC1D0c pcmC2D0p timer
by-path controlC1 hwC0D0 pcmC0D0c pcmC0D10p pcmC0D7p pcmC0D9p pcmC2D0c seq

# Unmount USB
# This ensures that an assumed /dev/sdc device is the correct USB-drive
# sudo umount /media/usb # Alternate command
sudo umount /dev/sdc1
Step 2: Create a primary FAT32 partition
root@kimlinux:/home/kim# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-3938303, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-3938303, default 3938303):

Created a new partition 1 of type 'Linux' and of size 1.9 GiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.

Command (m for help): w
The partition table has been altered.
Failed to remove partition 1 from system: Device or resource busy
Failed to add partition 1 to system: Device or resource busy

The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.
Step 3: Format the USB drive
root@kimlinux:/home/kim# /sbin/mkfs.vfat -F 32 -n ESXi_7 /dev/sdc1
mkfs.fat 4.1 (2017-01-24)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows

# This error would appear if disk has not been remounted/refreshed
mkfs.vfat: /dev/sdc1 contains a mounted filesystem.
Step 4: Copy the boot loader
/usr/bin/syslinux /dev/sdc1
cat /usr/lib/syslinux/mbr/mbr.bin > /dev/sdc

# This would occur if a wrong path was provided
root@kimlinux:/home/kim# cat /usr/lib/syslinux/mbr.bin > /dev/sdc
cat: /usr/lib/syslinux/mbr.bin: No such file or directory

# Try this as last resort
# sudo dd if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/sdc
Step 5: Mount USB Drive with a specific path
mkdir /media/usbDrive
mount /dev/sdc1 /media/usbDrive
Step 6: Mount ISO and Copy the ESXi binaries to the USB drive
mkdir /media/esxi
sudo mount /home/kim/Downloads/VMware-VMvisor-Installer-7.0b-16324942.x86_64.iso /media/esxi -o loop
cp -r /media/esxi/* /media/usbDrive
sudo umount /media/esxi # unmount when done copying
Step 7: Fix the boot configuration file
mv /media/usbDrive/isolinux.cfg /media/usbDrive/syslinux.cfg
sed -i 's/APPEND -c boot.cfg/APPEND -c boot.cfg -p 1/g' /media/usbDrive/syslinux.cfg

These errors have been known to be caused by a defective USB thumb drive:

Error 33 (Inconsistent data) while decompressing data
Error 33 (Inconsistent data) while loading module: /vsan.v00
Compressed MD5: 6a9790e72fbc457f7885e2dfa0359f9e
Decompressed MD5: 000000000000000000000000000000000000000
Fatal error: 33 (Inconsistent data)

Module content is likely corrupt
isize: 186207365, hdrlen: 26, recdCRD: 0, osize: 0
gzip_extract failed forl /tools.t00 (size 186207365): CRC error
Error 28 (CRC error) while loading module: /tools/t.00
Compressed MD5:
Decompressed MD5: 000000000000000000000000000000000000000
Fatal error: 28 (CRC Error)

Leave a Reply

Your email address will not be published. Required fields are marked *