Adding a non-VMFS drive to your ESX(i) server and use it!

I had some spare Windows drives lying around and wanted to put them in my HP MicroServer running ESXi 4.1.

After installing the SATA drive, and rebooting, I tried to simply add the drive in the vSphere console. No love from VMWare — I got the message, “Error while adding drive – disk not available.” Hmmm. I was sure the drive was working.

Turns out that in ESXi, once a disk has been written to, in any format, it won’t initialize.
Here’s what it took to add the drive in:

Low-level formatted the drive (the name of the drive might be shorter or longer):
~ # dd if=/dev/zero of=/vmfs/devices/disks/t10.ATA_ST3500413AS_Z2A3TKQ6 bs=512 conv=notrunc

Try adding the disk to your datastore now; I canceled this command after waiting 5 minutes and noticed that ESXi now saw the disk as a ‘blank disk’. Adding it to my datastore now worked! If not, continue…

Recreate the partition table:
~ # fdisk /vmfs/devices/disks/t10.ATA_ST3500413AS_Z2A3TKQ6

Then ‘o’ to Create a new empty DOS partition table
Then ‘n’ to add a new partition. I used Primary as the type, and 1 as the partition number.
Then ‘t’ to change the type. ‘fb’ is the code for VMFS 3.0
Then ‘w’ to write everything to the drive

Finally, use the ‘vmkfstools’ program to create the volume. I added it as a new datastore using the following command:
~ # vmkfstools -C vmfs3 -S Datastore2 /vmfs/devices/disks/t10.ATA_ST3500413AS_Z2A3TKQ6

As always, YMMV.