Every time I want to convert a downloaded img image to the vmdk format used by [[ESXi]], I always have to use StarWind software on another [[Windows]] computer, which is particularly troublesome. Therefore, I asked [[ChatGPT]] for a way that does not require Windows.
Preparation#
- First, install qemu using [[brew]]:
# After installation, use qemu-img to call
brew install qemu
- Enable ESXi [[ssh]] service:
- Log in to ESXi
- Select "Manage"
- Select "Services"
- Find "TSM-SSH" and enable it
Usage#
First, convert the img image to the vmdk format:
qemu-img convert -f raw arpl.img -O vmdk arpl.vmdk
Then, upload the converted file to ESXi using [[scp]]:
scp arpl.vmdk root@esxi.immwind.com:/vmfs/volumes/SSD/mirrors/
If you now add the uploaded vmdk image as the system disk to the virtual machine and try to start it, ESXi will give an error:
Unable to power on DSM virtual machine. Disk type 2 for "sata0:0" is not supported or invalid. Please ensure that the disk is imported.
When you think it's a disk problem and change the disk type to IDE, you find that the previous error disappears and it can start normally. However, don't be happy too soon, the surprise comes next:
kernel is not a valid elf file
Because another conversion is needed for ESXi to recognize it correctly. Let's connect to ESXi via SSH: ssh root@esxi.immwind.com
, and then execute:
# Go to the location where the image was uploaded before
cd /vmfs/volumes/SSD/mirrors
# Perform the conversion
vmkfstools -i arpl.vmdk synoboot.vmdk
By default, the disk type after conversion using vmkfstools is: Thick Provision Lazy Zeroed. If you want to change it to Thin Provision, you can add the -d thin
parameter:
vmkfstools -i arpl.vmdk synoboot.vmdk -d thin
After the conversion is complete, use the ls command to see that there is not only synoboot.vmdk but also synoboot-flat.vmdk. Do not delete the latter, as it is the file that actually stores the data. However, you can delete the previously uploaded arpl.vmdk file to avoid confusion during future maintenance:
rm arpl.vmdk
Now you can add synoboot.vmdk as the system disk to the virtual machine and start it, just like the result of converting with StarWind V2V Image Converter.
Information#
Environment
- HPE-ESXi-6.7.0-Update3
- System: macOS 13.4.1
References