Qemu is very old virtualization technology used to virtualize system components and run operating systems on it. Before KVM and XEN QEMU was used heavily but it can not race with VMWARE or VIRTUAL PC. But with the KVM qemu get superfast speed for computing by using hardware based virtualization. QEMU acts as a hardware supplier and KVM is the CPU. KVM resides in linux kernel and there is little configuration for it. Virtualization configuration is made on the QEMU.
- To get help and all of the configuration options
$ qemu-kvm -h
- Simply run qemu
$ qemu-kvm fedoraraw.qcow2
Download Cloud Images
Popular Linux distributions like Fedora, CentOS, Debian, Ubuntu, RedHAT provides virtual machine images in various formats like raw, qcow2, vmdk etc. We will download Fedora 25 cloud image from following link which is provided by Fedora project.
Download with wget like below.
Set CPU and Core Count
Set the core count which make vm faster.
$ qemu-kvm -smp cores=2
Boot From Network
- Firstly boot from network
$ qemu-kvm -boot order=nc
Set RAM or Memory Size
- Set memory size of the vm in megabyte. Default memory size is 128
$ qemu-kvm -m 256
Set VM Name
- Set the name of the vm which is show on the window caption
$ qemu-kvm -name ismail
Specify Disk File
- Start vm with existing disk file which is in qcow2 format and virtio driver is used. Be aware that virtio drivers must have installed on the guest operating system.
$ qemu-kvm -drive file=fedoraraw.qcow2,if=virtio
- Disable graphical interface and use remote connection or console
$ qemu-kvm -nographic
Connect To Virtual Switch Like virbr0
By default started guest will be connected no network and only single interface will be attached. This is not practical and useful feature for the most of the situations. We can add a network interface and connect this interface into bridge device which is running in host operating system. In this example we will connect our guest with a virtuo type network interface into virtual switch/bridge called
$ qemu-kvm -drive file=fedoraraw.qcow2,if=virtio -display none -net bridge,br=virbr0 -net nic,model=virtio
Use Remote Disk Images
- Use remote disk image via ssh
$ qemu-kvm -drive file=ssh://email@example.com/disk.img