If you’ve used Virsh to access a serial console on a Linux VM, you would have noticed that text gets cut off or doesn’t wrap properly. This is because the serial console hasn’t got any bounds set. I’ll show you how to fix it.
It’s an easy fix. Before logging into the VM’s console, we need to get the current size of the window / screen we’re in, from the KVM host machine:
stty -a
We’re looking for the rows and columns values. These will be the boundary we set within the VM.
Next, login to your VM.
Handy Tip #1:
Start and get a console in one line: virsh start vmname --console
Use stty and substitute your values:
stty rows 48 cols 128
This will set the boundary at that size. If you resize your window or anything changes, you might have to resize it again. Keep that in mind.
Note that a restart will reset the changes. You could add the command and values to your .bashrc to apply each login. Don’t forget the behavior of the .bash_profile and .bashrc files to get your desired result.
Handy Tip #2:
If you end up getting Error: operation failed: Active console session exists for this domain
Try restarting libvirtd
- systemctl restart libvirtd