KVM Virsh: Redirect FreeBSD Console To A Serial Port

Posted on in Categories , , last updated February 1, 2011

I‘m using KVM to run multiple virtual machines under Redhat Enterprise Linux server 5.5. I’ve installed FreeBSD 7.x 64 bit as guest operating systems. How do I redirect the FreeBSD version 6, 7 or 8 virtual machine console to a serial port using virsh console command for management purpose from host itself?

FreeBSD does support a dumb terminal on a serial port as a console. This is useful for quick login or debug guest system problem without using ssh. First, login as root using ssh to your guest operating systems:
$ ssh [email protected]
su -

Edit /boot/loader.conf, enter:
# vi /boot/loader.conf
Append the following entry:
Save and close the file. Edit /etc/ttys, enter:
# vi /etc/ttys
Find the line that read as follows:

ttyd0  "/usr/libexec/getty std.9600"   dialup  off secure

Update it as follows:

ttyd0   "/usr/libexec/getty std.9600"   vt100   on secure

Save and close the file. Reboot the guest, enter:
# reboot
After reboot, you can connect to FreeBSD guest as follows from host (first guest the list of running guest operating systems):
# virsh list
Sample outputs:

 Id Name                 State
  3 ographics            running
  4 freebsd              running

Now, connect to Freebsd guest, enter:
virsh console 4
virsh console freebsd
Sample outputs:

Fig.01: Virsh console connected to FreeBSD guest
Fig.01: Virsh console connected to FreeBSD guest


3 comment

  1. I think you have a typo: ttyd0 had to be ttyu0 for me to get this working.
    I just found it in the reference link you posted :)


  2. Hi ,

    Guest VM installation done using below command on RH6.4

    [[email protected] ~]# virt-install --connect qemu:///system -n vm10 -r 1024 --vcpus=4 --disk path=/var/lib/libvirt/images/vm10.img,size=15 -c /home/ISO/ubuntu-12.04-server-i386.iso --vnc --noautoconsole --os-type linux --os-variant ubuntu --accelerate --network=bridge:br0 --hvm

    I am unable to connect guest OS …

    [[email protected] ~]# virsh --connect qemu:///system
    Welcome to virsh, the virtualization interactive terminal.
    Type:  'help' for help with commands
           'quit' to quit
    virsh # list
     Id    Name                           State
     1     vm10                           running
    virsh # exit
    [[email protected] ~]# virsh console vm10
    Connected to domain vm10
    Escape character is ^]



  3. In FreeBSD 9/10, I couldn’t get this to work. When getty was sleeping for 30 seconds I was able to login, however the tty would be killed as soon as getty woke up after 30 seconds. Finally got it working by using a different tty device.

    Error as such were shown on the console from virsh:
    getty[6235]: login_tty /dev/ttyu0: Inappropriate ioctl for device
    init: getty repeating too quickly on port /dev/ttyu0, sleeping 30 secs

    The fix for me was using cuau0 vs. ttyu0 in ttys
    cuau0 “/usr/libexec/getty std.9600” vt100 on secure

    /boot.conf has ‘-Dh’ vs. comconsole in /boot/loader.conf

    My QEMU config is:

Leave a Comment