KVM: Configure libvirt Network
You can update the network configuration for your KVM installation using the command line using the virsh command.
To list all of the available network enter the following command. The --all will is used to include the inactive networks:
# virsh net-list --allName State Autostart-----------------------------------------default active yesNattedNetwork active yes
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 *.ovaHTAOE.ova$ tar tf HTAOE.ovaHTAOE.ovfHTAOE-disk001.vmdkHTAOE.mf
So, you can simply extract the files:
Find the IP Addresses of KVM Virtual Machines (Command Line)
To find details about the virtual network you can use these commands:
root@slacker:~# virsh net-listName State Autostart Persistent--------------------------------------------default active yes yesroot@slacker:~# virsh net-info defaultName: defaultUUID: 14a90f27-9a85-42ca-b434-6ce6c142690cActive: yesPersistent: yesAutostart: yesBridge: virbr0root@slacker:~# virsh net-dhcp-leases defaultExpiry Time MAC address Protocol IP address Hostname Client ID or DUID------------------------------------------------------------------------------------------------------------2023-07-22 16:18:45 52:54:00:dd:7b:62 ipv4 192.168.122.216/24 centos7-bbk -
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 15GFormatting '/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=15Password:WARNING Requested memory 1024 MiB is less than the recommended 1536 MiB for OS centos8Starting 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:00Running graphical console command: virt-viewer --connect qemu:///system --wait CentOS-Stream-9
How to convert VirtualBox VDI to KVM qcow2
It is easy to convert a VirtualBox VDI image to a KVM qcow2 file. You have to use the RAW file format as an intermediate.
Make sure the VirtualBox machine is shutdown.
- Convert the VDI to a raw disk image. Note: VDIs are compressed and raw images are not, so you will need to leave enough disk space for entire uncompressed disk. $ VBoxManage clonehd –format RAW vm.vdi vm.img
- Then on your KVM host: $ qemu-img convert -f raw vm.img -O qcow2 vm.qcow2