Adding a disk as a new datastore in ESXi that was previously used may result in this error:
Failed - Cannot change the host configuration.
What! This error doesn’t give you very much information. For some reason a drive that is already partitioned by another operating system seems to produce this error.
It's an easy solution. Enable SSH on ESXi. Simply start the TSM-SSH service. We'll turn it off when we're done.
SSH to your server and list the contents of the /vmfs/devices/disks directory.
ls
Find the device-id for the disk you are attempting to add. It may look something like this (yes, the device-id is this entire string):
[root@server:/dev/disks] ls
naa.600062b20d1994402d0a90723411d52f t10.ATA_____INTEL_SSDSCKKB480G8_____________________PHYH02540027480K____:5 vml.01000000005048594830323534303032373438304b20202020494e54454c20:8
naa.600062b20d1994402d0a90723411d52f:1 t10.ATA_____INTEL_SSDSCKKB480G8_____________________PHYH02540027480K____:6 vml.0200000000600062b20d1994402d0a90723411d52f4d5239333631
naa.600062b20d1994402d0a90723411d52f:5 t10.ATA_____INTEL_SSDSCKKB480G8_____________________PHYH02540027480K____:7 vml.0200000000600062b20d1994402d0a90723411d52f4d5239333631:1
naa.600062b20d1994402d0a90723411d52f:6 t10.ATA_____INTEL_SSDSCKKB480G8_____________________PHYH02540027480K____:8 vml.0200000000600062b20d1994402d0a90723411d52f4d5239333631:5
naa.600062b20d1994402d0a90723411d52f:7 vml.0100000000504859483032343330354e553438304b20202020494e54454c20 vml.0200000000600062b20d1994402d0a90723411d52f4d5239333631:6
naa.600062b20d1994402d0a90723411d52f:8 vml.01000000005048594830323534303032373438304b20202020494e54454c20 vml.0200000000600062b20d1994402d0a90723411d52f4d5239333631:7
naa.600062b20d1994402d0a908034db552e vml.01000000005048594830323534303032373438304b20202020494e54454c20:1 vml.0200000000600062b20d1994402d0a90723411d52f4d5239333631:8
t10.ATA_____INTEL_SSDSCKKB480G8_____________________PHYH024305NU480K____ vml.01000000005048594830323534303032373438304b20202020494e54454c20:5 vml.0200000000600062b20d1994402d0a908034db552e4d5239333631
t10.ATA_____INTEL_SSDSCKKB480G8_____________________PHYH02540027480K____ vml.01000000005048594830323534303032373438304b20202020494e54454c20:6
t10.ATA_____INTEL_SSDSCKKB480G8_____________________PHYH02540027480K____:1 vml.01000000005048594830323534303032373438304b20202020494e54454c20:7
Use the following command to get information about the disk
partedUtil getptbl /vmfs/devices/disks/naa.600062b20d1994402d0a90723411d52f
you will see something like the following
Error: Function not implemented during read on /dev/disks/naa.600062b20d1994402d0a90723411d52f
Error: The primary GPT table states that the backup GPT is located beyond the end of disk. This may happen if the disk has shrunk or partition table is corrupted. Fix, by writing backup table at the end? This will also fix the last usable sector appropriately as per the new reduced size. diskPath (/dev/disks/naa.600062b20d1994402d0a90723411d52f) diskSize (37501992960) AlternateLBA (45002391551) LastUsableLBA (45002391518)
Warning: The available space to /dev/disks/naa.600062b20d1994402d0a90723411d52f appears to have shrunk. This may happen if the disk size has reduced. The space has been reduced by (7500398592 blocks). You can fix the GPT to correct the available space or continue with the current settings ? This will also move the backup table at the end if it is not at the end already. diskSize (37501992960) AlternateLBA (45002391551) LastUsableLBA (45002391518) NewLastUsableLBA (37501992926)
Error: Can't have a partition outside the disk!
Unable to read partition table for device /vmfs/devices/disks/naa.600062b20d1994402d0a90723411d52f
partedUtil setptbl /vmfs/devices/disks/naa.600062b20d1994402d0a90723411d52f msdos
Replace the id 'naa.600062b20d1994402d0a90723411d52f' with the id of the disk that has the problem.
Done! Try adding your datastore now. Remember to turn SSH off when done.
Worked straight away, thank you!