accessing Linux guests through a serial port?

mangoo

Member
Feb 4, 2009
198
0
16
wpkg.org
Currently I'm evaluating Proxmox VE to see how it compares with other virtualization solutions.

One thing that is very nice about Xen is its serial console access to guests (it works out of the box for paravirtualized hosts).

It allows to login to a guest even when it's network-disconnected (i.e. you gave it a wrong IP address) or when you have problems accessing the guest with a VNC console (your connection is very slow and the only reasonable access is SSH through the host).

For example, to access a serial console on a guest from a Xen host one would do:

[root@xen2 mangoo]# xm console mysql3

Kernel 2.6.25.1-1-xenU on an i686 / hvc0
mysql3 login: This_is_a_guest_login_prompt!


I couldn't find any documentation on how to achieve it with KVM guests on Proxmox.

Anyone using it? It is implemented through a "-serial" option in KVM.
 

dietmar

Proxmox Staff Member
Staff member
Apr 28, 2005
16,704
373
103
Austria
www.proxmox.com
It allows to login to a guest even when it's network-disconnected (i.e. you gave it a wrong IP address) or when you have problems accessing the guest with a VNC console (your connection is very slow and the only reasonable access is SSH through the host).
This works for OpenVZ only.

I couldn't find any documentation on how to achieve it with KVM guests on Proxmox.
I will do some research on that - maybe its possible.
 

dietmar

Proxmox Staff Member
Staff member
Apr 28, 2005
16,704
373
103
Austria
www.proxmox.com
Ok, in theory it works. For example add the following line to your VM configuration:

Code:
args: -serial tcp:localhost:6000,server,nowait
The you can connect to the console with:

Code:
telnet localhost 6000
But unfortunately this only works if the guest runs getty on the serial console, which is usually disabled. VNC works always and does not depend on the guest configuration.
 

mangoo

Member
Feb 4, 2009
198
0
16
wpkg.org
This works for OpenVZ only.



I will do some research on that - maybe its possible.
I used it when I emulated Debian (ARM) in Qemu some time ago, so it's perfectly possible.

Would be great to have it integrated in the Proxmox VE web backend, but I don't mind using it with minicom on the console.

And of course, it's OK to have to configure the guest to have (min)getty started on a given console.
 

dietmar

Proxmox Staff Member
Staff member
Apr 28, 2005
16,704
373
103
Austria
www.proxmox.com
Would be great to have it integrated in the Proxmox VE web backend,
That makes no sense, because the web backend uses VNC - so you get not advantage at all.

but I don't mind using it with minicom on the console.

And of course, it's OK to have to configure the guest to have (min)getty started on a given console.
So what the usage scenario? Simply using ssh work im 99,9999%. And you can still use VNC if ssh does not work. So I dont think there a need for adding a third method.

- Dietmar
 

mangoo

Member
Feb 4, 2009
198
0
16
wpkg.org
Ok, in theory it works. For example add the following line to your VM configuration:

Code:
args: -serial tcp:localhost:6000,server,nowait
The you can connect to the console with:

Code:
telnet localhost 6000
But unfortunately this only works if the guest runs getty on the serial console, which is usually disabled. VNC works always and does not depend on the guest configuration.
I think it's better to use a unix socket, for at least three reasons:
- when using telnet as above, password is passed on the screen; it's not the case with a "real" serial connection
- we don't really want to open any new ports
- it's easier for the backend to generate such line, because the path is almost similar to the "-monitor" line

-serial unix:/var/run/qemu-server/101.serial,server,nowait


Changes needed on the guest - add "console=ttyS0 console=tty0" to your kernel command line passed by the bootloader - this will make kernel messages appear both on tge VGA console and on serial console. For example, this would be a line for grub:

kernel (hd0,0)/boot/vmlinuz root=LABEL=ik5-root console=ttyS0 console=tty0


In /etc/inittab, look for lines similar to the ones below and make sure you have "ttyS0" there - this would be our serial console:

5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty ttyS0


If you use minicom for connecting, you have to use "A - Serial Device" like:

unix#/var/run/qemu-server/101.serial
 
Last edited:

mangoo

Member
Feb 4, 2009
198
0
16
wpkg.org
That makes no sense, because the web backend uses VNC - so you get not advantage at all.
Does the web backend use VNC for "monitor" as well? I though it is something more lightweight (at least, I've seen such lightwell SSH-web-shells).


So what the usage scenario? Simply using ssh work im 99,9999%. And you can still use VNC if ssh does not work. So I dont think there a need for adding a third method.
- Dietmar
I already mentioned a usage scenario:
- you reconfigure your network on the guest and you loose connectivity
- VNC is slow
- what I didn't mention, VNC viewer is problematic when copying/pasting data - in the terminal, you just mark with a mouse, middle click, done - works both ways
 

mangoo

Member
Feb 4, 2009
198
0
16
wpkg.org
Ok, in theory it works. For example add the following line to your VM configuration:

Code:
args: -serial tcp:localhost:6000,server,nowait
It doesn't work for me that way if I add such line in the config file for a guest - the arguments are not passed.

It only works if I start "kvm" from command line and add "-serial ...".

Is "args: " line parsed by "qm"? I don't see it mentioned in the manual. "args" is not present in "qm" and "QemuServer.pm" as well.

Is there another way to pass custom arguments to qm, or do I do something incorrectly?
 

dietmar

Proxmox Staff Member
Staff member
Apr 28, 2005
16,704
373
103
Austria
www.proxmox.com
Does the web backend use VNC for "monitor" as well? I though it is something more lightweight (at least, I've seen such lightwell SSH-web-shells).
yes

I already mentioned a usage scenario:
- you reconfigure your network on the guest and you loose connectivity
you can use vnc then ( a very rare case)

- VNC is slow
but fast enough to reconfigure the network.
 
Aug 6, 2014
136
2
18
I came looking for this as well. My use case is vm setup automation with expect scripts through the console. For implementation, you can make a unix socket and use screen or redirect it with socat.

at least for my use, the alternate is making a seperate network with a helper vm, set up from that, and then move it into place, or just run kvm outside of proxmox for its initial setup.

vzctl has this, was qm supposed to have it too?

edit: just saw that this is for the old version
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!