Linux VPS

Set up a serial console for KVM VMs (virsh console)

Enable a serial console in Linux KVM guests so you can reach them with virsh console without VNC or network: GRUB and kernel settings, getty, rescuing boot problems and exiting cleanly.

IntermediateKVM hosts2 min read

When a VM's network is broken, SSH is useless. A serial console gives you a text login over the hypervisor, with no network or graphics. This guide shows how to set up a KVM serial console and use virsh console.

Before you start

  • Root on the KVM host and the guest (via VNC for the first setup if needed).
  • VPS customers usually use the panel's VNC console instead; see VNC console access.

Check the VM has a serial device

virsh dumpxml web01 | grep -A3 "<serial"

virt-install adds one by default. If missing, add with virsh edit:

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

Power-cycle the VM afterwards.

Configure the guest kernel and GRUB

Edit /etc/default/grub in the guest:

GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"
GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

Regenerate GRUB: sudo update-grub (Debian/Ubuntu) or sudo grub2-mkconfig -o /boot/grub2/grub.cfg (RHEL family). Cloud images often already include console=ttyS0.

Enable a login prompt

systemd usually starts serial-getty@ttyS0 automatically when the kernel console is set. To be sure:

sudo systemctl enable --now serial-getty@ttyS0.service

Connect

virsh console web01

Press Enter to see the login prompt. Exit with Ctrl+]. Reboot the VM while connected to watch GRUB and boot messages, very useful for boot problems.

Rescue tricks from the serial console

  • At the GRUB menu press e, append systemd.unit=rescue.target to the linux line and press Ctrl+X to boot into rescue mode.
  • Fix network config or firewall rules that locked you out of SSH.
  • Read boot errors that scroll past too quickly in VNC.

Troubleshooting

  • Blank console: press Enter; if still blank, the kernel lacks console=ttyS0 or getty is not running.
  • "Active console session exists": someone else is connected; use virsh console web01 --force.
  • Garbled text: speed mismatch; use 115200 everywhere.

Frequently asked questions

Does Windows support the serial console?

Windows offers the Emergency Management Services console, but most admins use VNC/RDP instead.

Is the serial console secure?

Only users with access to the hypervisor can reach it, and the guest still requires a login.

Can I log the console?

Yes, use <log file='/var/log/libvirt/qemu/web01-serial.log'/> in the serial device.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.