To setup KVM on Ubuntu 18.04, perform the following steps:
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install qemu qemu-kvm libvirt-bin bridge-utils virt-manager
What the command does:
1. Update and upgrade Ubuntu
2. Install required packages for running KVM
3. We use qemu and qemu-kvm for hypervisor
4. bridge-utils for working with network bridge
5. virt-manager is GUI application for KVM.
Let see our new network interface created by bridge-utils and KVM by running "ip a" command:
4: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 52:54:00:2f:e6:3c brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:2f:e6:3c brd ff:ff:ff:ff:ff:ff
Now, there are two new network interfaces, those are bridge network interface created by libvirt, we can use virbr0 for bridge network with our virtual machine.
Lets run a virtual machine for testing, we will use CentOS minimal as a guest OS, before that, download CentOS minimal image, and put it where ever you want, and the run the following command:
$ virt-install --virt-type=kvm --name centos7 --ram 2000 --vcpus=2 --os-variant=centos7.0 --network=bridge=virbr0,model=virtio --graphics vnc --cdrom=/var/lib/libvirt/images/CentOS-7-x86_64-Minimal-1810.iso --disk path=/var/lib/libvirt/images/centos.qcow2,size=10,bus=virtio,format=qcow2
We create a virtual machine, with 2GB ram, and 2 cpus, using CentOS 7 as a guest OS, and we create 10GB virtual disk.
That's all.
No comments:
Post a Comment