accessing Linux guests through a serial port?

Discussion in 'Proxmox VE 1.x: Installation and configuration' started by mangoo, Feb 18, 2009.

  1. mangoo

    mangoo Member

    Joined:
    Feb 4, 2009
    Messages:
    198
    Likes Received:
    0
    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.
     
  2. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,940
    Likes Received:
    244
    This works for OpenVZ only.

    I will do some research on that - maybe its possible.
     
  3. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,940
    Likes Received:
    244
    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.
     
  4. mangoo

    mangoo Member

    Joined:
    Feb 4, 2009
    Messages:
    198
    Likes Received:
    0
    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.
     
  5. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,940
    Likes Received:
    244
    That makes no sense, because the web backend uses VNC - so you get not advantage at all.

    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
     
  6. mangoo

    mangoo Member

    Joined:
    Feb 4, 2009
    Messages:
    198
    Likes Received:
    0
    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
     
    #6 mangoo, Feb 18, 2009
    Last edited: Feb 18, 2009
  7. mangoo

    mangoo Member

    Joined:
    Feb 4, 2009
    Messages:
    198
    Likes Received:
    0
    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).


    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
     
  8. mangoo

    mangoo Member

    Joined:
    Feb 4, 2009
    Messages:
    198
    Likes Received:
    0
    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?
     
  9. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,940
    Likes Received:
    244
    yes

    you can use vnc then ( a very rare case)

    but fast enough to reconfigure the network.
     
  10. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,940
    Likes Received:
    244
    Please update your software.
     
  11. mangoo

    mangoo Member

    Joined:
    Feb 4, 2009
    Messages:
    198
    Likes Received:
    0
    Good, that does the trick, thanks!
     
  12. mangoo

    mangoo Member

    Joined:
    Feb 4, 2009
    Messages:
    198
    Likes Received:
    0
    And way too fast to capture a kernel OOPS, panic etc. when it scrolls through your screen ;)
    I summarized all this info in this FAQ:

    http://pve.proxmox.com/wiki/FAQ

    Feel free to correct it and/or move to a separate page.
     
    #12 mangoo, Feb 27, 2009
    Last edited: Feb 27, 2009
  13. pixel

    pixel Member
    Proxmox VE Subscriber

    Joined:
    Aug 6, 2014
    Messages:
    135
    Likes Received:
    2
    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
     
    #13 pixel, Aug 6, 2014
    Last edited: Aug 6, 2014
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice