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..

There are many cloud platforms which are working in Linux virtualisation on back-end. In terms of connectivity we have better option in KVM, which connect it through serial console.

In this post we would see how we could connect Ubuntu17.04 KVM Virtual machine through serial console. I remember in earlier version and distributions, it need to configure serial console in grub file, but in Ubuntu its very easy and reliable as most of configurations and settings are already configured in OS.

let’s see how things happened here …


For this post, we are using Ubuntu-17.04 Guest Machine on Ubuntu-16.04 Host machine.

#virsh list
 Id    Name                           State
 23    ubuntu-17.04                   running

How to setup serial console, for same we have to connect machine and login on as root user.

Login through SSH

We could connect on KVM Guest machine through SSH from Host Machine.

root@'s password: 
Welcome to Ubuntu 17.04 (GNU/Linux 4.10.0-19-generic x86_64)

    .......  ...... ...... .......

Last login: Sun Aug  6 04:16:38 2017
root@srvu:~# hostname

Connect through VNC

We could connect Guest machine through VNC Viewer and could setup Serial console from there. Configuring and connecting VNC viewer posted here. This could be best option to connect Guest machine in any troubleshooting because it could configure without any network connectivity, this also make it same control which we have in serial console with Graphical User Interface from remote host.

Connect with virt-manager

This is Graphical User interface on Host Machine. For this we should have access to Host Machine or Graphical desktop from remote through SSH or VNC.

#apt-file search bin/virt-manager
virt-manager: /usr/bin/virt-manager

Above package should installed for this command. Like in below image we could connect KVM Guest machine.

Configure a serial console in the Ubuntu guest

After getting login console we need to start serial console and enable it with below two commands.

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

Now we could connect serial console in easy way with virsh console command.

#virsh console ubuntu-17.04
Connected to domain ubuntu-17.04
Escape character is ^]

Ubuntu 17.04 srvu ttyS0

srvu login: root
Last login: Sun Aug  6 04:44:22 IST 2017 from on pts/0
Welcome to Ubuntu 17.04 (GNU/Linux 4.10.0-19-generic x86_64)

 ...... ...... ......

root@srvu:~# hostname

Small Video for same