virt-v2v
is a tool that can be used to convert images from VMware/VirtualBox/ESXI/HyperV over to KVM. When using it to convert VMware images over to KVM, you may get an error saying no hard disks were found:
1 2 3 |
[root@vmhost ~/Metasploitable]$ virt-v2v -i vmx Metasploitable.vmx -o rhev -of raw -os localhost:/home/vmimport --network lab_malware_net [ 0.0] Opening the source -i vmx Metasploitable.vmx virt-v2v: error: source has no hard disks! |
Converting VMX files over with virt-v2v requires that you set one of 4 hard disk types:
"disk" | "plainDisk" | "rawDisk" | "scsi-hardDisk"
To find your image’s disk type, you can grep the .vmx file for ".vmdk"
:
1 2 |
[root@vmhost ~/Metasploitable/Metasploitable2-Linux]$ grep ".vmdk" Metasploitable.vmx scsi0:0.fileName = "Metasploitable.vmdk" |
In my case, I only have one disk in this image, and it’s a SCSI disk. Note that “scsi0.0” means that this disk is the first disk on the first SCSI adapter. Next, you’ll have to echo the disk device type and SCSI bus and disk number into the bottom of the .vmx file so virt-v2v knows how to handle the disk:
1 |
echo "scsi0:0.deviceType = "scsi-hardDisk"" >> Metasploitable.vmx |
And of course, if there are multiple disks, you want to make sure that you echo a similar line in the bottom of the .vmx file for each disk attached to the image. A VM with 3 disks would look like this:
1 2 3 |
echo "scsi0:0.deviceType = "scsi-hardDisk"" >> Metasploitable.vmx echo "scsi0:1.deviceType = "scsi-hardDisk"" >> Metasploitable.vmx echo "scsi1:0.deviceType = "scsi-hardDisk"" >> Metasploitable.vmx |
After that change, virt-v2v should be happy:
1 2 3 4 5 6 |
[root@vmhost ~/Metasploitable/Metasploitable2-Linux]$ virt-v2v -i vmx Metasploitable.vmx -o rhev -of raw -os localhost:/home/vmimport --network lab_malware_net [ 0.0] Opening the source -i vmx Metasploitable.vmx [ 0.0] Creating an overlay to protect the source from being modified [ 0.4] Initializing the target -o rhv -os localhost:/home/vmimport [ 0.6] Opening the overlay ... |