Back in the late 1980's the announcement that AT&T and SUN would work together on the next unified System V release, triggered the "Unix Wars". Pretty much all UNIX systems vendors (IBM, HP, SGI, DEC and others) reacted to this with some forming the Open Software Foundation (which subsequently became Open Group). As Open Software Foundation they developed OSF/1 OS (now another dead Unix flavour) and Motif X11 desktop.

At around the same time University of California Berkeley was stripping out the legacy AT&T code from its BSD distribution so it could release an unencumbered release. The first release being BSD Net/2 and then 4.4 BSD Lite. This all took time and there was a lot of legal activity going on. Additional serious tickering by Linus Torvalds resulted in Linux, which was grafted into the stalled GNU free Unix OS initiative.

Now the UNIX business has Linux at its heart and 4.4 BSD has soldiered on through FreeBSD, NetBSD, OpenBSD and even MacOS via Darwin.  Interestingly MacOS (via NextStep) was built on top of (Carnegie Mellon sourced) Mach mirco-kernel and BSD with X11 replaced with Apple Macintosh UI. So the result is aligned with what GNU Hurd was aiming for, but it losts its Stallman / GNU "freeness" along the way.

So why use FreeBSD ? For me, the answer was that in 1995 FreeBSD 2.0.5 was available via Walnut Creek CDROM and as SUN user at work BSD was a known proposition. Linux on the otherhand was provided as a very diverse set of distributions and simply deciding which of these to use was hard to determine.

Status - now working, just documenting the results and configuration


FreeBSD - VM on QEMU / KVM

To get a current FreeBSD release (11.3 or 12.1) running in QEMU / KVM requires that you build a machine with a custom kernel, due to current and known bug.

Here is summary of QEMU / KVM configuration I have used:

  • QEMU / KVM / libvirt on Ubuntu 19.10
  • QEMU Q35 with OVMF VM
  • SATA HD & CD
  • vmxnet3 network (rather than e1000)
  • QEMU Generic USB keyboard & EvTouch USB Tablet
  • Custom kernel build with "dev netmap" disabled

With FreeBSD 11.3 / 12.X you can only get QEMU Q35 VM running by using SATA HD and then building a custom network kernel, to get networking up and running.

Once you have build your Q35 / OVMF machine, you should do a boot and while in  UEFI / TianoCore bootup press ESC to get into the UEFI configuration parameters. Note this might take a few trys as need to ensure windows has focus and press ESC early in the boot sequence.

One you are in UEFI configuration screen you should set the default screen resolution of your machine (I set my to a relatively low 1024 x 768). This is required to ensure that X11 is able to discover the framebuffer and use the scfb (screen framebuffer) driver (see below: "FreeBSD - Kernel & X11 Configuration").

NOTE #1: On Ubuntu 19.10 apt package required are: qemu-system-x86 libvirt-clients libvirt-daemon-system ovmf virt-manager

NOTE #2: See my tip on "MacOS on Ubuntu with KVM/QEMU and OVMF/Clover EFI" for more information on setup KVM / QEMU.


FreeBSD Desktop (GNOME) with QEMU EvTouch USD Tablet Pointer

This is the "tricky" and very poorly documented part. There are two options to getting "Desktop" environment running:

  1. Build via Ports
  2. Binary Package Install

While in general I have always used Ports (us FreeBSD'ers love source code ;-) ). In the case of GNOME / X11 , I would strongly recommend using option 2 - "Binary Package Install". On a simple 2 CPU VM with 4096 GB RAM doing build will take a whole day. If you don't to a "config-recursive" the process will keep halting and going into aditional config steps as all the various dependencies are build, which will likely result in multi-day build.

My recommendation, binary installation packages: xorg, gnome3

Binary install of extra xorg drivers: evdev

# pkg install xorg gnome3 xf86-input-evdev

Ports build of: misc/utouch

The misc/utouch driver is they helper driver that supports QEMU Q35 EvTouch UDB Tablet. Using this is essential to get "absolute coordinates" mouse, which is required to using mouse via virtual console provided via QEMU / VNC driver.

NOTE #3: Thanks to Vladimir Kondratyev for tip on using misc/utouch

You can now do your initial testing. Assuming you have not yet added anything to /etc/rc.conf, simply log in to root and try and start X11 from the console:

# startx

This may:

  • do nothing,
  • result in x11 starting with multiple xterm windows with non working mouse or
  • if you are really lucky have X11 starting with multiple xterm windows and a working mouse.

Depending in result you can look in /var/log/Xorg.0.log for startup results.

In my case I got nothing until I set the UEFI resolution as per notes above in: "FreeBSD - VM on QEMU / KVM".

Tne once I had set resolution, I got XTerm windows but none working mouse.

So next step was to validate the evdev / utouch mouse was working and which /dev/input/eventN the QEMU EvTouch tablet is on.

To do this you can use the evdev.evtest python tool, which is installed as part of xf86-input-evdev package. Here is example:

# python3.7 -m evdev.evtest
ID  Device               Name                                Phys                                Uniq
------------------------------------------------------------------------------------------------------------------------------------------
0   /dev/input/event0    System keyboard multiplexer         kbdmux0                                 
1   /dev/input/event1    System mouse                        sysmouse                                
2   /dev/input/event2    AT keyboard                         atkbd0                                  
3   /dev/input/event3    IntelliMouse Explorer               psm0                                    
4   /dev/input/event4    QEMU QEMU USB Keyboard, class 0/0, rev 2.00/0.00, addr 2 ukbd0                               68284-0000:00:1d.7-1
5   /dev/input/event5    QEMU QEMU USB Tablet, class 0/0, rev 2.00/0.00, addr 4 utouch0                             28754-0000:00:1d.7-5
6   /dev/input/event6    QEMU QEMU USB Mouse, class 0/0, rev 2.00/0.00, addr 3 ums0                                89126-0000:00:1d.7-4

Select devices [0-6]: 5
Listening for events (press ctrl-c to exit) ...
time 1582007519.619301 --------- SYN_DROPPED --------
time 1582007519.619301 --------- SYN_REPORT --------
time 1582007519.638179 type 3 (EV_ABS), code 0    (ABS_X), value 22015
time 1582007519.638179 type 3 (EV_ABS), code 1    (ABS_Y), value 26495
time 1582007519.638179 --------- SYN_REPORT --------
time 1582007519.642895 type 3 (EV_ABS), code 0    (ABS_X), value 21663
time 1582007519.642895 type 3 (EV_ABS), code 1    (ABS_Y), value 27348
time 1582007519.642895 --------- SYN_REPORT --------
time 1582007519.65342 type 3 (EV_ABS), code 0    (ABS_X), value 21215
time 1582007519.65342 type 3 (EV_ABS), code 1    (ABS_Y), value 28585
time 1582007519.65342 --------- SYN_REPORT --------
time 1582007519.66421 type 3 (EV_ABS), code 0    (ABS_X), value 20863
time 1582007519.66421 type 3 (EV_ABS), code 1    (ABS_Y), value 29823
time 1582007519.66421 --------- SYN_REPORT --------
time 1582007519.677026 type 3 (EV_ABS), code 0    (ABS_X), value 20607
time 1582007519.677026 type 3 (EV_ABS), code 1    (ABS_Y), value 31060
time 1582007519.677026 --------- SYN_REPORT --------
time 1582007519.686741 type 3 (EV_ABS), code 0    (ABS_X), value 20415
time 1582007519.686741 type 3 (EV_ABS), code 1    (ABS_Y), value 32297
time 1582007519.686741 --------- SYN_REPORT --------
time 1582007536.383169 type 3 (EV_ABS), code 0    (ABS_X), value 12031
time 1582007536.383169 type 3 (EV_ABS), code 1    (ABS_Y), value 17108
time 1582007536.383169 --------- SYN_REPORT --------
time 1582007536.449228 type 3 (EV_ABS), code 0    (ABS_X), value 12063
time 1582007536.449228 --------- SYN_REPORT --------
time 1582007536.744538 type 3 (EV_ABS), code 1    (ABS_Y), value 17066
time 1582007536.744538 --------- SYN_REPORT --------
time 1582007536.754257 type 3 (EV_ABS), code 0    (ABS_X), value 12095
time 1582007536.754257 type 3 (EV_ABS), code 1    (ABS_Y), value 17023
time 1582007536.754257 --------- SYN_REPORT --------
time 1582007536.765432 type 3 (EV_ABS), code 0    (ABS_X), value 12127
time 1582007536.765432 type 3 (EV_ABS), code 1    (ABS_Y), value 16980
time 1582007536.765432 --------- SYN_REPORT --------
time 1582007536.779227 type 3 (EV_ABS), code 0    (ABS_X), value 12159
time 1582007536.779227 type 3 (EV_ABS), code 1    (ABS_Y), value 16938
time 1582007536.779227 --------- SYN_REPORT --------
time 1582007536.786433 type 3 (EV_ABS), code 0    (ABS_X), value 12223
time 1582007536.786433 type 3 (EV_ABS), code 1    (ABS_Y), value 16895
time 1582007536.786433 --------- SYN_REPORT --------
time 1582007536.805982 type 3 (EV_ABS), code 0    (ABS_X), value 12255
time 1582007536.805982 type 3 (EV_ABS), code 1    (ABS_Y), value 16852
time 1582007536.805982 --------- SYN_REPORT --------
time 1582007536.809289 type 3 (EV_ABS), code 0    (ABS_X), value 12319
time 1582007536.809289 type 3 (EV_ABS), code 1    (ABS_Y), value 16810
time 1582007536.809289 --------- SYN_REPORT --------
time 1582007536.822264 type 3 (EV_ABS), code 0    (ABS_X), value 12351
time 1582007536.822264 type 3 (EV_ABS), code 1    (ABS_Y), value 16767
time 1582007536.822264 --------- SYN_REPORT --------
time 1582007536.831691 type 3 (EV_ABS), code 0    (ABS_X), value 12383
time 1582007536.831691 type 3 (EV_ABS), code 1    (ABS_Y), value 16724
time 1582007536.831691 --------- SYN_REPORT --------
time 1582007536.854654 type 3 (EV_ABS), code 0    (ABS_X), value 12415
time 1582007536.854654 type 3 (EV_ABS), code 1    (ABS_Y), value 16682
time 1582007536.854654 --------- SYN_REPORT --------
time 1582007537.103654 type 1 (EV_KEY), code 272  (['BTN_LEFT', 'BTN_MOUSE']), value 1
time 1582007537.103654 --------- SYN_REPORT --------
time 1582007537.236717 type 3 (EV_ABS), code 0    (ABS_X), value 12479
time 1582007537.236717 --------- SYN_REPORT --------
time 1582007537.2603  type 3 (EV_ABS), code 0    (ABS_X), value 12511
time 1582007537.2603  --------- SYN_REPORT --------
time 1582007537.279146 type 1 (EV_KEY), code 272  (['BTN_LEFT', 'BTN_MOUSE']), value 0
time 1582007537.279146 --------- SYN_REPORT --------
time 1582007537.280155 type 3 (EV_ABS), code 0    (ABS_X), value 12543
time 1582007537.280155 type 3 (EV_ABS), code 1    (ABS_Y), value 16724
time 1582007537.280155 --------- SYN_REPORT --------
time 1582007537.282278 type 3 (EV_ABS), code 0    (ABS_X), value 12607
time 1582007537.282278 --------- SYN_REPORT --------
time 1582007537.292983 type 3 (EV_ABS), code 0    (ABS_X), value 12671
time 1582007537.292983 type 3 (EV_ABS), code 1    (ABS_Y), value 16767
time 1582007537.292983 --------- SYN_REPORT --------
time 1582007537.313748 type 3 (EV_ABS), code 0    (ABS_X), value 12735
time 1582007537.313748 --------- SYN_REPORT --------
time 1582007537.315358 type 3 (EV_ABS), code 0    (ABS_X), value 12895
...
...
...

time 1582007545.415462 --------- SYN_REPORT --------

This test let you identify the right /dev/input/device as well as validate that the EvTouch device is generating an input stream and you can see it is providing absolute X,Y values which is what we need.

Now you you have made sure evdev is working your are ready for getting final steps completed.


FreeBSD - Kernel & X11 configuration

I was not able to get "automagic" X11 going which is apparently possible if you do a build with most current xorg version. Instead I had to do some manual configuration of:

  • /boot/loader.conf - to ensure console was used correctly and utouch evdev KLM was loader
  • /usr/local/etc/X11 - to force loading of right HW devices
  • /usr/local/lib/xorg/modules/input - hack to stop default mouse driver from loading...
  • /etc/rc.conf - to enable and auto start GNOME desktop

Here are my working configurations:

 -- Ensure utouch is loaded and enable vt console
$ cat /boot/loader.conf 
utouch_load="YES"
kern.vty=vt

Generate a default X11 startup configuration and then exit this to load particular configuration

$ cd /usr/local/etc/X11

-- NOTE: main X11 device configuration, which has "Screen0" and "Mouse0" identifiers and AutoAddDevices options set to Off
--        This stops loading of automatically discovered devices

# cat xorg.conf
Section "ServerLayout"
        Identifier   "Plain"
        Screen       0  "Screen0" 0 0
	InputDevice "Mouse0" "CorePointer"
        Option       "DontZap" "Off"
        Option       "AutoAddDevices" "Off"
        Option       "Log" "sync"
EndSection

Section "Files"
	ModulePath   "/usr/local/lib/xorg/modules"
	FontPath     "/usr/local/share/fonts/misc/"
	FontPath     "/usr/local/share/fonts/TTF/"
	FontPath     "/usr/local/share/fonts/OTF/"
	FontPath     "/usr/local/share/fonts/Type1/"
	FontPath     "/usr/local/share/fonts/100dpi/"
	FontPath     "/usr/local/share/fonts/75dpi/"
	FontPath     "catalogue:/usr/local/etc/X11/fontpath.d"
EndSection

Section "Module"
	Load  "glx"
EndSection
# 
# ---
# NOTE: now go down to configuration directory
#        qxl is the default graphics device for QEMU and you should be using this driver
         you need to ensure that PCI BudID is consistent with your VM
         Screen0 == matches main config above
# ---
#
# cd xorg.conf.d
# cat device-qxl.conf
Section "Device"
	Identifier  "Card0"
	Driver      "qxl"
	BusID       "PCI:0:1:0"
EndSection

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport   0 0
		Depth     1
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     4
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     8
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     15
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     16
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection
#
# ---
# NOTE: the sreen frame buffer driver
# ---
#
# cat driver-scfb.conf
Section "Device"
	Identifier "Card0"
	Driver     "scfb"
EndSection
#
# ---
# NOTE: Keyboard Driver configuration
# ---
#
# cat input-kbd.conf
Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection
#
# ---
# NOTE: evdev configuration, where Mouse0 == as per main configuration
#         Device == /dev/input/event5 , as per evdev.evest result
#         No oether configuration is required for EvTouch to work
# ---
# cat input-qemu-tablet.conf
Section "InputDevice"
	Identifier "Mouse0"
	Driver "evdev"
	Option "Device" "/dev/input/event5"
EndSection

To stop xorg from loading the default mouse driver I did a rename of the mouse driver. This was required as the mouse driver was installed by default with xorg binary package and if you do a "pkg remove" then it will try to remove the xorg package as well.

# cd /usr/local/lib/xorg/modules/input
mv mouse_drv.so mouse_drv.so.bak

Finally my /etc/rc.conf to start GNOME automatically on boot (enable: dbus, hald, gdm & gnome):

# cat /etc/rc.conf
clear_tmp_enable="YES"
hostname="ME-NAME"
ifconfig_vmx0="DHCP"
ipv6_network_interfaces="none"
ipv6_activate_all_interfaces="NO"
local_unbound_enable="YES"
sshd_enable="YES"
#moused_enable="YES"
#moused_flags="-t auto -p /dev/usm0"
dbus_enable="YES"
hald_enable="YES"
gdm_enable="YES"
gnome_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"

FreeBSD Desktop - Result & Conclusion

It works !!

FreeBSD (GNOME) Desktop on QEMU / KVM

Was it worth it ...

FreeBSD provides a robust and reliable server machine, but if you want a "Unix GNOME" desktop, then I would recommend Ubuntu for Linux. The other option is MacOS for Unix with slickness and commercial applications.


Reference & Links:

FreeBSD 11.3 / 12.X and SCSI, VirtIO & Networking Bug with QEMU Q35 VM -  when you find a bug in an Open Source reporting it and helping with diagnosis is a key way of helping to contribute. The work around for this bug is to build a custom kernel with /usr/src/sys/amd64/config/GENERIC update to disable "dev netmap" disabled.

TianoCore - the Open Source UEFI project kick started by Intel and basis of QEMU OVMF (Open VM Firmware) implementation

FreeBSD / QEMU / KVM Q35 USB Tablet (EVTouch) input device not captured by evdev - reporting bugs in Open Source can also lead to helpful tips, such as advise by Vladimir Kondratyev on using misc/utouch

FreeBSD Handbook - "The X Window System" has useful tips but does not cover QEMU / KVM setup

utouch - FreeBSD driver for absolute USB HID mouses - thanks to Vladimir Kondratyev