Today, I replaced one of my disks in one of my ESXi hosts. The disk has been used in a SAN before and had a partition. When I was trying to create a new datastore using the vSphere Client, I got the following error: Call “HostDatastoreSystem.QueryVmfsDatastoreCreateOptions” for object “ha-datastoresystem” on ESXi “xxx.xxx.xxx.xx″ failed. According to VMware, this error occurs if there are existing partitions on the disk.
“Ok, no problem! I just delete the partition”, I thought. Easier said than done. After over an hour of googling, I only found complex guides with multiple commands which was not working in my environment. I was just to give up before I found this post. It turned out that all you have to do is to remark the partition as DOS, then ESXi is able to format it itself and create a new datastore.
Enable SSH on your host, connect to it and run the following command:
partedUtil mklabel /dev/disks/<disk id> msdos
How do you find the disk id, you might ask. That’s pretty easy. Login to your host via vShpere Client and go to Configuration -> Storage -> Devices and take a note of the name:
Then run the following commnd via SSH: esxcli storage core device list. Now locate the disk, in my case GB0750C4414. The disk id you need is the one next to Other UIDs. In my case vml.01000000003551443435483451202020202020202020202020474230373530.
t10.ATA_____GB0750C4414_____________________________5QD45H4Q____________ Display Name: Local ATA Disk (t10.ATA_____GB0750C4414_____________________________5QD45H4Q____________) Has Settable Display Name: true Size: 715404 Device Type: Direct-Access Multipath Plugin: NMP Devfs Path: /vmfs/devices/disks/t10.ATA_____GB0750C4414_____________________________5QD45H4Q____________ Vendor: ATA Model: GB0750C4414 Revision: n/a SCSI Level: 5 Is Pseudo: false Status: on Is RDM Capable: false Is Local: true Is Removable: false Is SSD: false Is Offline: false Is Perennially Reserved: false Queue Full Sample Size: 0 Queue Full Threshold: 0 Thin Provisioning Status: unknown Attached Filters: VAAI Status: unknown Other UIDs: vml.01000000003551443435483451202020202020202020202020474230373530 Is Local SAS Device: false Is USB: false Is Boot USB Device: false
That’s it! You can now add the a new datastore via the vShere Client just as usual.