KVM Virsh: Redirect FreeBSD Console To A Serial Port

Posted on in Categories , , last updated May 6, 2017

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:
console="comconsole"
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
OR
virsh console freebsd
Sample outputs:

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

References:

This entry is 7 of 14 in the CentOS / Redhat (RHEL) KVM Virtulization series. Keep reading the rest of the series:
  1. CentOS / Redhat: Install KVM Virtualization Software
  2. CentOS / Redhat: KVM Bridged Network Configuration
  3. KVM virt-manager: Install CentOS As Guest Operating System
  4. KVM virt-install: Install FreeBSD / CentOS As Guest Operating System
  5. KVM: Install CentOS / RHEL Using Kickstart File (Automated Installation)
  6. Troubleshooting KVM Virtualization Problem With Log Files
  7. KVM Virsh: Redirect FreeBSD Console To A Serial Port
  8. KVM: Starting / Stopping Guest Operating Systems With virsh Command
  9. Linux KVM: Disable virbr0 NAT Interface
  10. FreeBSD / OpeBSD Running in KVM Does Not Accept FTP Traffic
  11. KVM: Start a Virtual Machine / Guest At Boot Time
  12. KVM virt-install: Install OpenBSD As Guest Operating System
  13. Linux KVM: OpenBSD Guest Hangs At Starting tty Flags
  14. KVM Virtualization: Start VNC Remote Access For Guest Operating Systems

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 :)

    Thanks!

  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 ^]
    

    Thanks

    DAYA

  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