KVM is great tool for virtualisation on Linux machines, it provide complete control over Virtual machine and provide reliable alternative in terms of any third-party tools in market…
Recently I install Ubuntu 20.04 with KVM on Ubuntu Machine, After installation i tried to get console of it through virsh console, but wasn’t able to get it.

ssirohi@srv2:~$ virsh list
 Id    Name                           State
----------------------------------------------------
 5     ubuntu20.04                    running

ssirohi@srv2:~$ virsh console ubuntu20.04
Connected to domain ubuntu20.04
Escape character is ^]

So, what we can do to get console of Ubuntu 20.04 KVM Virtual machine. So in this post we will see how we can get console of it.

SetUP

For this Setup we are using KVM virtual machine of Ubuntu 20.04 which setup on below Machine.

ssirohi@srv2:~$ kvm --version
QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.27)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
ssirohi@srv2:~$ lsb_release -d
Description:    Ubuntu 18.04.4 LTS
ssirohi@srv2:~$ uname -r
4.15.0-1090-oem

When we tried to connect it through console like below.

ssirohi@srv2:~$ virsh list
 Id    Name                           State
----------------------------------------------------
 5     ubuntu20.04                    running

ssirohi@srv2:~$ virsh console ubuntu20.04
Connected to domain ubuntu20.04
Escape character is ^]

Enable console on Ubuntu20.04 console

We can get console through start serial console service on Ubuntu KVM Machine with below commands.

sudo systemctl start serial-getty@ttyS0
sudo systemctl enable serial-getty@ttyS0
Created symlink /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service → /lib/systemd/system/serial-getty@.service.

So Just after this we can see, KVM virtual machine Ubuntu 20.04 will appear on terminal

ssirohi@srv2:~$ virsh console ubuntu20.04
Connected to domain ubuntu20.04
Escape character is ^]

Ubuntu 20.04 LTS srv21 ttyS0

srv21 login: