KVM Virsh: Redirect FreeBSD Console To A Serial Port

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 vivek@freebsd.nixcraft.in
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


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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • G Jun 14, 2012 @ 11:29

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


  • daya Mar 4, 2014 @ 14:00

    Hi ,

    Guest VM installation done using below command on RH6.4

    [root@ramlo ~]# 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 …

    [root@ramlo ~]# 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
    [root@ramlo ~]# virsh console vm10
    Connected to domain vm10
    Escape character is ^]



  • nick binary Mar 10, 2016 @ 16:15

    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 Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum