Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OndrejValenta/338035c23d70d8063aed14b4ae35af43 to your computer and use it in GitHub Desktop.
Save OndrejValenta/338035c23d70d8063aed14b4ae35af43 to your computer and use it in GitHub Desktop.
Enable Serial Console for Rocky Linux 9 / CentOS in Proxmox

Enable Serial Console for Rocky Linux / CentOS / RHEL in Proxmox

This guide is a combination of two sources

https://www.thegeekdiary.com/centos-rhel-7-how-to-configure-serial-getty-with-systemd/

https://pve.proxmox.com/wiki/Serial_Terminal

Done in Proxmox console

Add serial port to VM

qm set [VM ID] -serial0 socket

Shutdown completely the VM and start it again so the serial port is active.

Done in VM

Copy template settings for Serial Console to ttyS0 file

 cp /usr/lib/systemd/system/serial-getty@.service /etc/systemd/system/serial-getty@ttyS0.service

Update the new file like this

[Service]
ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM    <-- Change this parameter, add %I
Type=idle

Create a symlink and reload the console

ln -s /etc/systemd/system/serial-getty@ttyS0.service /etc/systemd/system/getty.target.wants/

systemctl daemon-reload
systemctl start serial-getty@ttyS0.service
systemctl enable serial-getty@ttyS0.service

Update GRUB

# in /etc/default/grub change the GRUB_CMDLINE_LINUX parameter so it contains both consoles like this

GRUB_CMDLINE_LINUX="quiet console=tty0 console=ttyS0,115200" 

Apply changes and reboot

grub2-mkconfig -o "$(readlink -e /etc/grub2.conf)"

reboot

Back in Proxmox terminal you can now attach to the Console like this

qm terminal [VM ID]
@docop
Copy link

docop commented Jun 15, 2023

Hi just to confirm, the modification of : console=tty0 console=ttyS0,115200 , you do boot into the rocky vm and into the vm you add this to the grub of rocky9 ? And then, when we click in proxmox, at the vm console, we will see directly the console without having to log over ssh to the vm...
thanks for precision.

@OndrejValenta
Copy link
Author

Hi just to confirm, the modification of : console=tty0 console=ttyS0,115200 , you do boot into the rocky vm and into the vm you add this to the grub of rocky9 ? And then, when we click in proxmox, at the vm console, we will see directly the console without having to log over ssh to the vm... thanks for precision.

That is not precise.. I did not manage to just open a VM console with
image
it gets stuck with
image

I was able to get all data with qm terminal so I let it be for time being but if you find out what to do to make it fully working let me know..

And yes, I have a template VM that has all the changes mentioned above implemented, even the GRUB line.. I just realized it doesn't say it specifically that you should just add the consoles there and not change whole GRUB line, I hope it's understandable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment