Did you ever install linux VM from its iso file using virt-manager or virsh cli, and then when you try to have console access, you simply cannot !!
In this blog, I will show you how to connect to centos or Ubuntu KVM Virtual machine through serial console.
There are two methods to enable serial console access:
- First method works on new versions and distributions of centos and ubuntu, it is very easy and reliable since most of configurations and settings are already configured in OS. Just type two commands (though VNC or virt-manager GUI), and this will do the trick. Here are the commands:
systemctl start serial-getty@ttyS0
systemctl enable serial-getty@ttyS0
Now you could connect to the VM serial console using the virsh console cli command.
- Second method works on old versions and distributions of centos and ubuntu, you would need to change the grub file to configure serial console.
Here is how your grub file should look like:
GRUB_CMDLINE_LINUX=”rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet”
Once you save and exit the grub file (with the changes), run the grub2-mkconfig command and then shutdown the VM
grub2-mkconfig -o /boot/grub2/grub.cfg
shutdown -h now
Once the VM comes up, it should have serial console access.
If you still have issues with the serial console access, then make sure that your VM properties (xml file) has serial enabled. Here is an example:
virsh edit guest-vm
<target type=’serial’ port=’0’/>