Here are the general steps to create a virtual machine (VM) using a qcow2 image file in KVM:
- Install KVM on your system if it is not already installed.
sudo apt-get install qemu-kvm libvirt-bin
- Create a new virtual machine using the
virt-install
command. This command is used to create new virtual machines from the command line.
virt-install --name vm-name --memory 2048 --vcpus 2 --disk path/to/image.qcow2,format=qcow2 --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
Note: You need to replace vm-name
with the desired name of your virtual machine, 2048
with the amount of memory you want to assign to the virtual machine, 2
with the number of virtual CPUs you want to assign, path/to/image.qcow2
with the path to the qcow2 image file you want to use, and br0
with the name of the network bridge you want to connect the virtual machine to. Also, you can use options like --cdrom
or --disk
to specify other boot options.
- Connect to the virtual machine’s console using the
virsh
command-line tool.
virsh console vm-name
- Verify that the virtual machine is running and operational by checking the output of the
virsh list
command.
virsh list --all
- Once the virtual machine is up and running, you can use the
virsh
command-line tool to manage the virtual machine, such as to start, stop, reboot, or delete it.
Note: You may also use graphical tools like Virt-manager to create and manage KVM VMs