FreeBSD – virsh serial howto

Goal is to setup FreeBSD so you can connect to virtual serial port for login

  1.  Add serials to KVM instance.  Use Virtual Manager
    1. one is usually the default – you can add up to 3 more.
  2.  In the virtual FreeBSD machine, edit the /etc/ttys
    1. Change the 3wire/ ttyu0 to std.9600.
    2. Secure means root can login
ttyu0   "/usr/libexec/getty std.9600"   vt100   on secure
ttyu1   "/usr/libexec/getty std.9600"   vt100   on secure
#ttyu1  "/usr/libexec/getty 3wire"      vt100   onifconsole secure

3.  login via virsh.   Note that you can obviously have only one login per serial

Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # list
 Id   Name          State
-----------------------------
 3    freebsd12.3   running
 5    rhel8.4       running

virsh # console freebsd12.3 --devname serial1 --safe
Connected to domain 'freebsd12.3'
Escape character is ^] (Ctrl + ])
error: operation failed: Active console session exists for this domain

virsh # console freebsd12.3 --devname serial0 --safe
Connected to domain 'freebsd12.3'
Escape character is ^] (Ctrl + ])


FreeBSD/amd64 (freebsd12_3) (ttyu0)

login:

To get rid of login prompt, press control-]  ( “<ctrl> + “]” ).  This will bring you back to the virsh prompt.

 

 

Leave a Reply