While I was working on ESXi 6.7.0, I ended up with an issue which I couldn’t resolve easily with the web interface of ESXi 6.7.0 or from vSphere Client. I had an extra HDD space which I would like to merge in my ESXi system to host more VMs.
VMFS Datastores in vSphere ESXi can be increased in size by adding a new extent on a different storage device (spanning), or by increasing the size of the existing storage device and then growing the existing datastore extent to fill that available adjacent capacity. It is very easy to do from VMware ESXi web interface but I started getting an error even though I had enough size to increase.
failed to expand vmfs datastore – cannot change the host configuration.
I searched on lots of blogs and few of them were very helpful. Therefore, I thought to share it here by combining all of them and the proper steps that I have used so it will be helpful for other IT Engineer in the future.
Before continuing these steps, I would like to warn not to overlap any Primary and Logical partitions. This could result in data loss.
- Enable SSH so you can connect to the CLI of ESXi.
- After successfully connecting with your root password or administrator password, first, obtain the device identifier for your VMFS Datastore to be modified.
vmkfstools -P "/vmfs/volumes/datastorename"
- Hereby, your datastore may be different (eg: naa,mpx, eui etc.) For more information on it, I would recommend you to explore VMWare page
My output is:
VMFS-6.82 (Raw Major Version: 24) file system spanning 1 partitions. File system label (if any): datastore1 Mode: public Capacity 88583700480 (84480 file blocks * 1048576), 850395136 (811 blocks) avail, max supported file size 70368744177664 Disk Block Size: 512/512/0 UUID: 5d2f42c4-be811510-d257-000c298045f3 Partitions spanned (on "lvm"): mpx.vmhba0:C0:T0:L0:3 Is Native Snapshot Capable: NO
- In the following step, I have used mpx which you can replace as your datastore information.
- Use partedUtil to identify the existing partitions.
partedUtil get "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0"
- You can take the reference from web interface to make sure about your VMFS. I also did the same as I am not so much expert on VMware. My one is Partition 3 which I would like to extend.
- After it, you need to check the usable sectors or the available space that you can merge on your existing system.
partedUtil getUsableSectors "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0"
- Now, you just provide the proper partition number where you would like to merge
partedUtil resize "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0" 3 15472640 188743646
- During the above steps, if you get an error with:
The kernel was unable to re-read the partition table on /dev/Device (Device or resource busy).
- Reboot the host before proceeding with the next step. Run the following command to refresh your VMFS volumes.
- The final step is to grow the VMFS Datastore:
vmkfstools --growfs "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0:3" "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0:3"
That’s all but kindly be sure about Primary and Logical partitions while doing these steps else you will lose your data.