KVM: Importing an OVA appliance
You may or may not be aware if it, but an OVA file is just a
tar archive containing an .ovf
and a .vmdk
files, respectively the VM configuration and disk.
$ ls *.ova
HTAOE.ova
$ tar tf HTAOE.ova
HTAOE.ovf
HTAOE-disk001.vmdk
HTAOE.mf
So, you can simply extract the files:
$ tar xvf HTAOE.ova
And convert to a format appropriate for QEMU/KVM:
List the available formats
$ qemu-img -h | tail -n4
Supported formats: blkdebug blklogwrites blkverify bochs cloop compress copy-before-write copy-on-read dmg file ftp ftps host_cdrom host_device http https luks nbd null-aio null-co nvme parallels preallocate qcow qcow2 qed quorum raw replication ssh throttle vdi vhdx vmdk vpc vvfat
See <https://qemu.org/contribute/report-a-bug> for how to report bugs.
More information on the QEMU project at <https://qemu.org>.
Do the actual conversion (I chose qcow2 here)
$ qemu-img convert -O qcow2 HTAOE.vmdk HTAOE.qcow2
Have a look at the .ovf
too, for information on expected
machine configuration, resources (eg. memory and cpu), etc.
After the conversion, simply create a new VM and make it use the newly created disk as the primary disk.
Tags: cli, kvm, ova, virtualization, qemu, motd
Create a QEMU/KVM Virtual Machine from the Command Line
You can use a combination of command line tools to create and configure a virtual machine. Here we will use few tools from the QEMU and libvirt packages to do this.
Use QEMU to create a 15GB QCOW disk image:
$ qemu-img create -f qcow2 /home/user/KVM/CentOS-Stream-9.qcow2 15G
Formatting '/home/user/KVM/CentOS-Stream-9.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=16106127360 lazy_refcounts=off refcount_bits=16
Start the installation:
$ sudo virt-install --name=CentOS-Stream-9 --vcpus=1 --memory=1024 --location=/home/user/Downloads/CentOS-Stream-9-20230704.1-x86_64-boot.iso --os-variant=centos8 --network bridge:virbr0 --disk path=/home/user/KVM/CentOS-Stream-9.qcow2 --disk size=15
Password:
WARNING Requested memory 1024 MiB is less than the recommended 1536 MiB for OS centos8
Starting install...
Retrieving 'vmlinuz' | 0 B 00:00:00 ...
Retrieving 'initrd.img' | 0 B 00:00:00 ...
Allocating 'CentOS-Stream-9.qcow2' | 2.5 MB 00:00:03 ...
WARNING Overriding memory to 3072 MiB needed for centos8 network install.
Creating domain... | 0 B 00:00:00
Running graphical console command: virt-viewer --connect qemu:///system --wait CentOS-Stream-9
Once this gets to this point another window should open up by the
virt-viewer
application (which you should install if you
didn’t already) and you can complete the installation and reboot. You’ll
use the same virt-viewer
window to use the shell or desktop
(depending upon the distro you installed).
When you are done and close the virt-viewer
GUI you can
find the VM in the running state using virsh
:
$ sudo virsh list --all
Password:
Id Name State
------------------------------------
5 CentOS-Stream-9 running
- slackware-current shut off
Then you can shut it down:
$ sudo virsh shutdown 5
Password:
Domain '5' is being shutdown
$ sudo virsh list --all
Password:
Id Name State
------------------------------------
- CentOS-Stream-9 shut off
- slackware-current shut off
Optionally, you can delete the VM domain and the QCOW file using the
undefine
parameter:
$ sudo virsh undefine --domain CentOS-Stream-9 --remove-all-storage
Password:
Domain 'CentOS-Stream-9' has been undefined
Volume 'vda'(/home/user/KVM/CentOS-Stream-9.qcow2) removed.