In a previous article, I answered the question: If VMware ESXi 4 is so small, why is it so big? It’s quite clear now that the disk footprint of VMware ESXi 4 is less than 60MB. But to really drive the point home, I wanted to demonstrate that VMware ESXi 4 could boot and run from a tiny 64MB flash device, so I asked Olivier Cremel, the inventor of ESXi, if that was feasible. He said it was — and gave me advice on how to set it up. This article shows you how.
- The VMware ESXi 4 dd image file (Vladan’s site may help)
- A 64MB flash drive — check your junk drawer
- A Linux machine — make sure you have mkfs.vfat
- This fdisk script — save it as a txt file
Extract necessary components from the large image
Use dd to copy the first 1.5MB of the boot partition and the files that make up ESXi.
# dd if=VMware-VMvisor-big-175625-x86_64.dd of=esxi-boot-part skip=32 count=3000 3000+0 records in 3000+0 records out 1536000 bytes (1.5 MB) copied, 0.036249 seconds, 42.4 MB/s # mkdir tmp # mkdir esxi # mount -o loop,offset=$((8224*512)) VMware-VMvisor-big-175625-x86_64.dd tmp/ # cp tmp/* esxi # sync # umount tmp/
Prepare the flash device
Plug in your flash device and use dmesg to determine the device id (/dev/sdk in this example). Run fdisk on it and delete all partitions – very important. Then, run my fdisk script to create the required partition structure. If this doesn’t work on your flash drive due to different size/geometry, you will need to create the partitions yourself — refer to the table at the end of these instructions for reference.
# fdisk /dev/sdk < fdisk.txt
Write data to the flash device
Use dd to write the saved boot partition to flash.
# dd if=esxi-boot-part of=/dev/sdk4 3000+0 records in 3000+0 records out 1536000 bytes (1.5 MB) copied, 1.31462 seconds, 1.2 MB/s # sync
Then create a FAT filesystem on the flash drive, mount it, and copy the ESXi files.
# mkfs.vfat /dev/sdk5 mkfs.vfat 2.11 (12 Mar 2005) # mount /dev/sdk5 tmp/ # cp esxi/* tmp/ # sync # umount tmp/
Double-check your partition layout
If your disk partition does not look like this, something went wrong.
# fdisk -l /dev/sdk Disk /dev/sdk: 65 MB, 65273856 bytes 3 heads, 42 sectors/track, 1011 cylinders Units = cylinders of 126 * 512 = 64512 bytes Device Boot Start End Blocks Id System /dev/sdk1 26 1011 62118 5 Extended /dev/sdk4 * 1 25 1554 4 FAT16 <32M /dev/sdk5 26 1011 62097 6 FAT16
Test it out
If you followed all of the instructions above, you should be able to boot from that flash drive.
There you have it — a fully functional VMware ESXi 4 system entirely contained on a 64MB flash device. Of course, this procedure is entirely unsupported, so please do not use a system like this in production. Please!Follow @eric_gray Tweet