Together with friends we decided to join efforts and administrate our own online services. We had some issue when setting up virtualization on Debian Stretch and I wanted to share what we learned.
We chose to use what we believe to be the “most standard” solution: KVM with QEMU, and libvirt. I expected it to work out of the box and I was wrong. Following the Debian Wiki was instructive but not sufficient.
We want to install a VM running Debian Jessie on a host running Debian Stretch.
sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system sudo adduser <youruser> libvirt sudo adduser <youruser> libvirt-qemu
What about checking libvirtd service status ?
sudo systemctl status libvirtd
And you might get errors like:
dnsmasqCapsRefreshInternal:741 : Cannot check dnsmasq binary /usr/sbin/dnsmasq: No such file or directory virFirewallValidateBackend:193 : direct firewall backend requested, but /sbin/ebtables is not available: No such file or directory virFirewallApply:916 : internal error: Failed to initialize a valid firewall backend
To fix those errors, we had to run:
sudo apt-get install ebtables dnsmasq sudo systemctl restart libvirtd
Creating a new Guest
Using Virtual Manager
The Debian Wiki says “The easiest way to create and manage VM guest is using GUI application Virtual Machine Manager” but does not provide information on how to set it up.
I first tried to connect to the host machine from virt-manager installed on my laptop and got the following error
libvirtError: End of file while reading data: sh: nc: command not found
Pretty straightforward to fix you say? You have to install netcat on your host machine. But not any netcat, netcat-openbsd
sudo apt-get install netcat-openbsd
If you install netcat-traditional, it will raise the following error:
The remote host requires a version of netcat/nc which supports the -U option.
Using the Command Line
sudo virt-install --virt-type kvm --name yunoprod \ --memory 8192 \ --location http://cdn-fastly.deb.debian.org/debian/dists/jessie/main/installer-amd64/ \ --extra-args "console=ttyS0" \ -v \ --disk path=/vm/yunoprod.img,format=raw,size=45 \ --os-variant generic \ --os-type linux \ --vcpus 4
For some reason –os-variant debianjessie does not exist anymore.
And there we run in the following error:
ERROR Requested operation is not valid: network 'default' is not active
Which is fixed (until next reboot) by:
sudo virsh net-start default
To be continued…