Edited to work with RHEL9 / Rocky Linux 9

By default RHEL / CentOS sets your virtual guests up for graphical VNC / Spice console which is a definate must in many situations but old covenant guys like me prefer the text console access so here is my notes for setting it up especially for Red Hat Enterprise Linux 9 / Rocky Linux 9 but also applies to other distros with systemd.

First start your guest and access it with virt-manager or equivalent.

See if the guest /etc/default/grub has “console=ttyS0” in GRUBCMDLINELINUX. This should be here. If not keep on reading.

On the guest issue following commands:

grubby --update-kernel=ALL --args="console=ttyS0"
grub2-editenv - unset kernelopts

If you wish to include the grub boot menu as well then add the following to /etc/default/grub:

GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --word=8 --parity=no --stop=1"

and update grub with command

grub2-mkconfig -o /boot/grub2/grub.cfg

This will update grub with kernel arguments to enable text console to the serial port which should be enabled by default in your virtual guest.

Now reboot the guest and try accessing the console with

virsh console <guest name>

If the console is not working then check your guest configuration in your host (not guest!) with command

virsh dumpxml <guest name>

And look for entry such as this (replace NN with a random number between 0 and 12)

<console type='pty' tty='/dev/pts/NN'>
    <source path='/dev/pts/NN'/>
    <target type='serial' port='0'/>
    <alias name='serial0'/>

If not then add it by editing configuration with

virsh edit <guest name>

Reboot guest and try.

~~DISCUSSION|Leave a comment~~ ~~QUICKSTATS:@virshconsolecentos7&basics~~ ~~QUICKSTATS:@virshconsolecentos7&ip~~

  • tips_and_howtos/virsh_console_centos7.txt
  • Last modified: 2023/05/26 11:51
  • by