I was fiddling around in Ubuntu 14.04 with Docker and noticed a Kali Linux container installation was just four steps:
$ wget -qO- https://get.docker.com/ | sh
$ docker pull kalilinux/kali-linux-docker
$ docker run -t -i kalilinux/kali-linux-docker /bin/bash
# apt-get update && apt-get install metasploit
This made me curious about comparing to the VM steps. Unfortunately they still only offer a VMDK version to play with. And this made me curious about how quickly I could convert to KVM.
On my first attempt I did the setup and conversion in eight (nine if you count cleanup):
- Install KVM
- Download kali vmdk zip file
- Extract zip file
- Convert ‘vmdk’ to ‘qcow2’
- Change ownership
- Convert ‘vmx’ to ‘xml’
- Create VM
- Edit VM configuration to link new qcow2 file
- Start the VM
- Delete vmdk
$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils virt-goodies p7zipfull
$ wget https://images.kali.org/Kali-Linux-1.1.0c-vm-amd64.7z
(Optional) Verify checksum is 1d7e835355a22e6ebdd7100fc033d6664a8981e0
$ sha1sum Kali-Linux-1.1.0c-vm-amd64.7z
$ 7z x Kali-Linux-1.1.0c-vm-amd64.7z
$ cd Kali-Linux-1.1.0c-vm-amd64
$ ll
-rw------- 1 user user 3540451328 Mar 13 03:50 Kali-Linux-1.1.0c-vm-amd64-s001.vmdk -rw------- 1 user user 1016725504 Mar 13 03:50 Kali-Linux-1.1.0c-vm-amd64-s002.vmdk -rw------- 1 user user 1261895680 Mar 13 03:50 Kali-Linux-1.1.0c-vm-amd64-s003.vmdk -rw------- 1 user user 1094582272 Mar 13 03:50 Kali-Linux-1.1.0c-vm-amd64-s004.vmdk -rw------- 1 user user 637468672 Mar 13 03:50 Kali-Linux-1.1.0c-vm-amd64-s005.vmdk -rw------- 1 user user 779747328 Mar 13 03:50 Kali-Linux-1.1.0c-vm-amd64-s006.vmdk -rw------- 1 user user 1380450304 Mar 13 03:50 Kali-Linux-1.1.0c-vm-amd64-s007.vmdk -rw------- 1 user user 1376256 Mar 13 03:50 Kali-Linux-1.1.0c-vm-amd64-s008.vmdk -rw------- 1 root root 929 Mar 13 02:56 Kali-Linux-1.1.0c-vm-amd64.vmdk -rw-r--r-- 1 user user 0 Mar 13 05:11 Kali-Linux-1.1.0c-vm-amd64.vmsd -rwxr-xr-x 1 root root 2770 Mar 13 05:11 Kali-Linux-1.1.0c-vm-amd64.vmx* -rw-r--r-- 1 user user 281 Mar 13 05:11 Kali-Linux-1.1.0c-vm-amd64.vmxf
$ qemu-img convert -f vmdk -O qcow2 Kali-Linux-1.1.0c-vm-amd64.vmdk qcow2 Kali-Linux-1.1.0c-vm-amd64.qcow2
$ sudo chown username:group Kali-Linux-1.1.0c-vm-amd64.qcow2
$ vmware2libvirt -f Kali-Linux-1.1.0c-vm-amd64.vmx > Kali-Linux-1.1.0c-vm-amd64.xml
(Note this utility was installed by virt-goodies. An alternative is to download just vmware2libvirt and run as “python vmware2libvirt -f Kali-Linux-1.1.0c-vm-amd64.vmx > Kali-Linux-1.1.0c-vm-amd64.xml”)
(Optional) Create some uniqueness by replacing default values (e.g. mac address 00:0C:29:4B:9C:DF) in the xml file
uuid
$ uuidgen
mac address
$ echo 00:0C:$(dd if=/dev/urandom count=1 2>/dev/null | md5sum | sed ‘s/^\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4/’)
$ vi Kali-Linux-1.1.0c-vm-amd64.xml
$ sudo ln -s /usr/bin/qemu-system-x86_64 /usr/bin/kvm
$ virsh -c qemu:///system define Kali-Linux-1.1.0c-vm-amd64.xml
Find this section
driver name='qemu' type='raw'
source file='/path/Kali-Linux-1.1.0c-vm-amd64.vmdk'
Change raw and vmdk to qcow2
driver name='qemu' type='qcow2'
source file='/path/Kali-Linux-1.1.0c-vm-amd64.qcow2'
$ virsh start Kali-Linux-1.1.0c-vm-amd64
$ rm *.v*
One thought on “Convert Kali Linux VMDK to KVM”