When working with standalone ESXi hosts (especially version 6.7+), moving thin-provisioned VMs between datastores presents unique challenges compared to thick-provisioned VMs. The primary issue is maintaining the sparse disk format during transfer while dealing with limited destination storage capacity.
The most reliable method is using ESXi's native vmkfstools
via SSH. Here's the step-by-step process:
# Connect to ESXi host via SSH
ssh root@esxi-host
# Navigate to VM directory
cd /vmfs/volumes/old-datastore/vm-folder
# Clone while preserving thin provisioning
vmkfstools -i vm-name.vmdk -d thin /vmfs/volumes/new-datastore/vm-folder/vm-name.vmdk
# Verify the new VMDK is thin-provisioned
vmkfstools -D /vmfs/volumes/new-datastore/vm-folder/vm-name.vmdk | grep "thin"
For Windows admins who prefer PowerCLI, here's a script that achieves the same result:
Connect-VIServer -Server esxi-host -User root -Password your-password
$vm = Get-VM -Name "VM-NAME"
$newDatastore = Get-Datastore -Name "NEW-DATASTORE"
Move-VM -VM $vm -Datastore $newDatastore -DiskStorageFormat Thin
Two common scenarios you might encounter:
- Disk space errors: If the clone fails, try cleaning up snapshots first using
vmkfstools -i vm-name.vmdk -d thin
with the-n
flag for non-blocking mode - Permission issues: Ensure you have sufficient rights on both datastores (
chmod 777
temporarily if needed)
After migration:
# Check actual disk usage
du -h /vmfs/volumes/new-datastore/vm-folder/
# Compare with provisioned size
ls -lh /vmfs/volumes/new-datastore/vm-folder/vm-name*.vmdk
# When confirmed working, remove from old datastore
rm -rf /vmfs/volumes/old-datastore/vm-folder
For large VMs, consider:
- Running during off-peak hours
- Using
pv
(pipe viewer) to monitor progress if installing additional packages is an option - Setting ESXi host to maintenance mode if possible
When working with a standalone ESXi host that lacks vCenter Server, migrating VMs between datastores requires careful handling - especially when dealing with thin-provisioned disks. The challenge intensifies when the destination datastore has less capacity than the source.
• No vCenter Server available (only direct ESXi host access)
• Need to maintain thin-provisioning during migration
• Destination datastore has smaller capacity than source
• Must avoid storage overcommitment during transfer
Method 1: Using vmkfstools (Command Line)
SSH into your ESXi host and run:
vmkfstools --clonevirtualdisk /vmfs/volumes/[source-datastore]/[vm-name]/[disk].vmdk \
-d thin \
/vmfs/volumes/[destination-datastore]/[vm-name]/[disk].vmdk
Method 2: Using PowerCLI Script
For Windows administrators with PowerCLI installed:
Connect-VIServer -Server esxi-hostname.local
Get-VM "VM-Name" | Move-VM -Datastore (Get-Datastore "new-datastore") -DiskStorageFormat Thin
When Disk Space is Tight
For situations where the destination datastore barely has enough space:
# First check actual used space
vmkfstools -P /vmfs/volumes/[source-datastore]/[vm-name]/[disk].vmdk
# Then clone with 10% buffer
vmkfstools --clonevirtualdisk source.vmdk \
--diskbytes 10% \
-d thin \
destination.vmdk
Always verify the thin provisioning status after migration:
vmkfstools -D /vmfs/volumes/[destination-datastore]/[vm-name]/[disk].vmdk | grep "Thin"
• If you get "No space left" errors, try defragmenting the VM disks first
• For large VMs, consider doing the migration during low-usage periods
• Always take a snapshot before migration as a safety precaution