, , , , ,

From what I’ve seen so far, FreeBSD is almost identical to Linux. The difference is we don’t get everything out of the box, as we would with Ubuntu or Linux Mint. Instead we get a lightweight and efficient operating system to build on.

This post goes through the process of getting FreeBSD running with a full desktop environment, though perhaps not in the most direct way, as I’ve done a bit of guesswork and improvisation to get there. It should take a couple of hours at most, starting with a basic installation disc or ISO.

Essentially what’s happening here are the following steps:
* Install a base system from the disc image.
* Fetch and install X Windows and desktop environment components.
* Configure the operating system to load X Windows and the desktop environment at startup.

Installing the Base System
For this I used the i386 ‘disc 1’ ISO file in VirtualBox, but the following should apply when running FreeBSD from a disc on generic hardware. The first thing we get is the boot screen.


From the menu select the ‘Boot Multi-user’ option, then at the next menu launch the FreeBSD Installer. Since the installer copies just the base system with a command line interface at this point, it’s fairly quick and straightforward. When prompted, we definitely need to create a second user account.

Reboot the system and login as root. The next stage will require the ‘pkg’ tool to fetch and install other components, so enter the ‘pkg’ command.


Since getting a graphical interface working involves modifying configuration files, I installed the nano text editor. This was before I discovered FreeBSD already includes the ‘ee’ editor, which seems just as usable.
#pkg install nano

Now we need to enable certain components, such as dbus, hald and kdm4 (we’ll come to this). The Hardware Abstraction Layer daemon (hald) is used for handling display-related hardware, and dbus is used for inter-process communication.
Edit /etc/rc.conf to add the following lines:


The thing is hald relies indirectly on procfs, the /etc/fstab file should look something like the following screenshot, and contain the entry for proc:
#nano /etc/fstab


Installing X Server and Desktop Environment
There are some pages on this in the official FreeBSD documentation, but I’ve skipped certain things. The X Window System is the underlying component for rendering windows, desktops and graphical menus, and where most graphics-related issues are fixed later.

First we require X server.
#pkg install xorg

As the status messages indicate, this also fetches and installs the TWM environment. Also required are the X Display Manager (xdm) and Session Manager (xsm).
#pkg install x11/xdm
#pkg install x11/xsm

Run ‘X -configure’ and copy the generated file with the following command:
cp /root/xorg.conf.new /etc/X11/xorg.conf

In the new file (/etc/X11/xorg.conf) add the following section:


Sorting KDE and KDM
Now we’re ready to install a full desktop environment on this. As with Linux, we have a range of possible environments to choose from. I chose KDE, which gives users something very similar to the Windows 7 desktop.
#pkg install x11/kde4

Roughly 950MB of KDE and KDE-related packages are fetched (many of them we don’t really need), and installation takes up around 3GB.
When this is done, we modify /etc/ttys so TTY8 uses KDM instead of XDM:
ttyv8 "/opt/kde/bin/kdm" xterm on secure


I also entered the following to see whether KDM runs as a service at this point.
#service kdm4 start

In the user’s home directory we require a file that starts KDE as the default GUI. Enter the following command:
#nano ~/.xinitrc

And add the following line to the .xinitrc file:
exec /usr/local/kde4/bin/startkde

Hopefully something like the following will load after the system has been rebooted: