Install KVM in Debian 9
- Installing the KVM packages
sudo apt install -y qemu-kvm libvirt0 virt-manager bridge-utils
- Reboot system
sudo reboot
- Add user to
libvirt
group so user can run commands
sudo gpasswd libvirt -a najibul
- Create ISO Directory
$ sudo mkdir /var/lib/libvirt/iso
$ sudo mv debian-9.0.0-amd64-netinst.iso /var/lib/libvirt/iso/
$ sudo chown libvirt-qemu:libvirt \
/var/lib/libvirt/iso/debian-9.0.0-amd64-netinst.iso
Note: Download Local SG/MY mirrors for different distro:
http://ftp.sg.debian.org/debian-cd/
http://download.nus.edu.sg/mirror/centos/
http://mirror.myren.net.my/centos/7/isos/x86_64/
http://mirror.nus.edu.sg/ubuntu-ISO/
- Load
kvm_intel
module if not loaded already
modprobe kvm_intel
- Enable and start
libvirtd
deomon
systemctl enable --now libvirtd
Create Virtual Machine from CLI
Create a virtual machine named "centos-temp"
virt-install --name=centos-temp \
--vcpus=4 \
--memory=8192 \
--cdrom=/var/lib/libvirt/iso/CentOS-7-x86_64-Minimal-1708.iso \
--disk size=50 \
--os-variant=rhel7
Connect to virt-manager
Remotely
You can connect to virt-manager
to create, delete, install etc. your VM using the GUI. The assumtion is that the KVM server is a remote machine.
-
Make sure X11 forwarding is turned on in SSH config of the KVM node
$ sudo grep X11Forwarding /etc/ssh/sshd_config X11Forwarding yes
-
Connect to the KVM node via SSH
ssh -X username@kvm-node-ip
OR configure the KVM node IP/Host in your PC in ~/.ssh/config
with the following parameter:
ForwardX11 yes
- Once logged use following command
virt-manager
The GUI window will appear.
Note: The above assumes you already have an X11 client like XQuartz installed on your Mac