User Tools

Site Tools


unix:virtualization:techniques

This is an old revision of the document!


Tricks and Techniques

Following are just some notes on how to “do things” with virtuals, especially converting from one form to another

Move VirtualBox images to KVM/Xen

Oracle VirtualBox uses their own format for the disk back end. In order to move the block device from VirtualBox to something something else, the image needs to be converted to a raw format, then optionally converted to a qcow2 format to conserve disk space. Note: in each case below, the commands need to be executed from a machine which has the virtualization tool installed. VBoxManage is only available on a VirtualBox machine, and qemu-img is only available on a machine which uses it, ie something that has had virt-manager, kvm, xen or qemu installed.

Also, note that neither of these commands modify the original disk image. They convert the image, copying the converted file to a new one.

The following code will take VirtualBox's sparse disk and convert it to a raw format, in essence a disk image with no compression. In other words, if you have a 40G disk image, but are only using 2.4G of disk space because VirtualBox realizes you are only using that much space, /target/disk.raw will require the full 40 gigabytes.

VBoxManage clonehd /source/disk.vdi /target/disk.raw --format raw

Virt-Manager can work with qcow2 formatted disk images, which are similar to VirtualBox's vdi (sparse) format, so we would really like to convert the raw image above to qcow2 whenever disk space is important. To do this, issue the following command:

qemu-img convert -f raw /path/to/raw/disk.raw -O qcow2 /path/to/qcow/disk.qcow2

You can now delete the original and intermediate files when you feel confident the process has gone well

Sticky IP's (Reservations) with virt-manager

unix/virtualization/techniques.1582146138.txt.gz · Last modified: 2020/02/19 15:02 by rodolico