Accessing Console Of Ubuntu 16.04 KVM Guest

consolekvmtty

When I added Debian 8 to my KVM management tool, I found that I could not access the console unless I added console=ttyS0 to the grub boot configuration. It wasn't great but it worked. I am in the process of adding Ubuntu 16.04 to the management tool, and this time when the guest is installed it has the same problem, but I can no longer see the grub menu options when I reboot the instance whilst connected to the console. Therefore, I cannot implement the workaround.

I managed to find the IP address of the guest instance by running arp -an on the hypervisor and connecting to the IPs on the KVM bridge until I found the right one. This allowed me to confirm that the guest was installed and running correctly. I would like to be able to connect to the console using sudo virsh console [guest ID] in case something goes wrong with the networking or if openssh suddenly decides to stop working. What do I need to do to be able to connect to the guest ubuntu 16.04 console from the hypervisor?

My gut feeling is that I should just need to tweak the configuration settings which are accessed by sudo virsh edit [guestID]. At the moment I have:

...
<serial type='pty'>
  <target port='0'/>
</serial>
<console type='pty'>
  <target type='serial' port='0'/>
</console>
...

Extra Info

  • Ubuntu 14.04 KVM hypervisor using kernel 4.2.0-36-generic
  • Virsh 1.2.2

Best Answer

Thanks @Programster solution works for me. Since I do not even have SSH access, I have to install and use virt-edit.

sudo apt install libguestfs-tools
sudo virt-edit -d myVM /boot/grub/grub.cfg

Replace all instances of quiet with quiet console=ttyS0 in the grub.cfg file and start my VM for console connect.

virsh start myVM && virsh console myVM

Do not forget to edit and update grub per @programster answer after login.

Related Question