A FreeBSD 9 Desktop How-to
- First Boot
- Enable Networking
FreeBSD is a fast, secure, modern Unix-like operating system with a fantastic community, great documentation, and powerful technologies like ZFS and LLVM. It’s my operating system of choice for everything from my beefy i7-2600k desktop to my home router to my ARM plug computer jukebox.
“FreeBSD on the server, Linux on the desktop” is an oft-seen sentiment among some FreeBSD enthusiasts, and it’s sort of understandable considering the conservative out-of-the-box FreeBSD installation. Despite that, FreeBSD is just a few settings away from being an easy, powerful Desktop OS rivaling Linux, complete with the same software ecosystem available through the Ports collection.
PC-BSD is tempting as a FreeBSD-derivative designed for desktop use, but I don’t care for its additional layer of abstraction on top of Ports and its KDE-centricism. Luckily for us, it’s easy to achieve PC-BSD-like modern desktop configuration on vanilla FreeBSD without dragging in PBI and all the other downsides of PC-BSD.
My desktop of choice is GNOME 2.x. Much of this guide’s information is applicable to KDE and other environments, but it follows a GNOME 2.32 installation step-by-step.
My system roots from a ZFS filesystem on SSD. The new bsdinstall, while finally ZFS-aware, still isn’t smart enough to handle more than the most basic zpool layouts. I recommend following the excellent Root on ZFS (4k) guide from aisecure.net. It should get your OS installed and leave you looking at a
Login: prompt after a reboot. This tutorial picks up from there but is applicable to any desktop FreeBSD 9 installation.
Log in as root with no password (Hit Enter when prompted), then run
tzsetup and follow the prompts to set the system’s default timezone. Run
newaliases to create the mail address alias database for Sendmail. These are usually done as part of the installation procedure, but we skipped it for manual partitioning.
Enable the Blowfish hash function instead of the default aging MD5 algorithm.
Rebuild the login database with
cap_mkdb /etc/login.conf, then set your new blf-hashed root password with
LANG=xx_YY.ZZZZ environment variable sets the locale to language code
xx, country code
YY, and character encoding
ZZZZ. Language and country code affect default application language, number formatting, date and time formatting, string collation, currency settings, and more.
By enabling a locale using UTF-8 character encoding, the system can understand and display each of the 1112064 characters in the Unicode character set, instead of just US ASCII as is default with
locale -a | grep UTF-8 for a list of every available UTF-8 locale. As an American anglophone, I use
Edit the login database once again to add a default character set and locale.
Rebuild the login database once more with
cap_mkdb /etc/login.conf, then add the new locale to
/etc/profile as well, so GDM and GNOME pick it up properly.
QT 4 GNOMEfiguration
Enable QGTKStyle and CUPS support for QT 4 applications by setting the QT4_OPTIONS variable in make.conf. This will make QT4 programs look and feel like GTK applications under GNOME as well as support printing with CUPS.
Network Audio System support can be enabled as well by adding “NAS” to QT4_OPTIONS.
Make sure KDE 4 applications and libraries install to the normal
They have a custom PREFIX of
/usr/local/kde4 by default as a compatibility shim from the KDE 3 transition days. Obviously, don’t do this if you still intend to use KDE 3 applications.
make.conf before continuing, unless you plan to use the Nouveau or Intel graphics drivers.
The current versions of the Nouveau and Intel graphics drivers require Kernel Mode-setting, something still a work in-progress on FreeBSD and slated to appear in FreeBSD 10. Until then, xorg-drivers/xf86-video-nouveau, xorg-drivers/xf86-video-intel, libdrm, libGL, and dri are pinned to older versions.
Enable your network in
/etc/rc.conf. My computer,
emi, is a desktop with a wired network. I have a Realtek interface,
re0, and use DHCP. Read more about network configuration in the Handbook to learn about other possible configurations.
You can bring up the interface and get a DHCP address immediately by issuing
ifconfig re0 up and
dhclient re0, again substituting the name of your own interface.
For WiFi configuration, see the wireless networking section of the Handbook. I sometimes tether my desktop to my Android phone using a run B/G USB interface. It’s as simple as defining a new virtual
wlan interface on
run0, configuring wpa_supplicant for the WPA pre-shared key, and specifying the SSID and encryption standard (WPA).
Familiarize yourself with the FreeBSD Ports Collection.
When you’re ready to continue, use portsnap to fetch a fresh Ports tree for your system with
portsnap fetch extract. Use
portsnap fetch update to quickly update the tree in the future, after this initial extraction.
Install GNOME and X.org
Change directory to
/usr/ports/x11/gnome2. Since GNOME is a large desktop environment, it takes a while to build and contains many port options (displayed to the user as a blue dialog prompt.)
make config-recursive in
x11/gnome2 to set these port options in advance, very useful if you plan to leave it overnight. When ready, run
When complete, do the same in
/usr/ports/x11/xorg to install the X.org X11 distribution.
X.org doesn’t include many attractive typefaces by default. Luckily, there are plenty available in Ports.
Here are a few I use, including many from non-Roman languages for better Unicode coverage.
x11-fonts/webfonts is a special case. It includes the Microsoft Core Fonts for the Web such as Andale and Verdana.
If you own a valid Microsoft Windows license you can get Tahoma as well by adding to
You can install other invididual fonts later as a user by copying them to
~/.fonts under your home directory.
FreeBSD’s Linuxulator allows it to run Linux application binaries using system call translation. Desktop users will find it useful for running the handful of proprietary but necessary programs that are available for Linux but not for FreeBSD, such as Adobe Flash Player.
Install the Linux base distribution from Ports. As I write this the most modern base distribution is emulators/linux_base-f10, based on Fedora 10. There’s a newer linux_base built on CentOS 6 coming soon, but it isn’t yet ready for use.
Once it’s installed, just tell your system to load the
linux kernel module at boot.
Skip this section if you don’t use an NVIDIA graphics card.
The binary x11/nvidia-driver is the only proprietary software on my system. As much as I’d prefer a free and open solution, I’ve found that neither Nouveau nor the free Radeon driver compare to the speed and feature support of Nvidia’s official driver.
To load the nvidia kernel module at boot, enable it in
X.org and nvidia
nvidia-xconfig to get a base xorg.conf in
/etc/X11/xorg.conf. Then, pull it up in your favourite text editor and add the
Module sections to enable
type1, and to let X know about those fonts you just installed.
Later on, once you’re booted into the graphical environment, you can use
nvidia-settings to configure TwinView and any other settings.
X.org and radeon
The free software
radeon driver is slightly harder to configure than the proprietary
As root, run
X -configure. It will spit out a new X.org configuration file in
/root/xorg.conf.new based on your detected hardware. Copy this file to
/etc/X11/xorg.conf, then pull it up in a text editor for a few modifications.
Add an “Extensions” section and enable the Composite extension.
Add one line to the
ServerLayout section to enable AIGLX.
Enable the EXA
DRI by adding their respective lines to the
Device section. Ensure your
Driver is configured as
radeonhd! radeonhd is an older, Novell-sponsored, defunct driver for Radeon HD hardware. You should use
Lastly, let X know about those fonts you installed by appending their FontPath to the
Tuning and drivers
Change a few sysctl variables to enhance the experience of FreeBSD on the desktop, including expanding the amount of shared memory, tuning the process scheduler for desktop use, and increasing the limit of simultaneously-open files to something sensible.
Some knobs can only be set at boot by the loader by setting them in
/boot/loader.conf. This is also where we define kernel modules to load at boot.
Turn on GNOME and related services to start HAL and D-Bus and get graphical logins with GDM.
gdm_enable, but I enable them all explicitly to avoid errors complaining they aren’t set.
Finally, enable everything else.
Enable remote access via SSH if you plan to use it. Otherwise, there’s no need to expose your system.
Then, set a sysctl variable and configure PolicyKit to allow normal users to mount removable media automatically in GNOME.
Relax default permissions on the device filesystem to allow normal users access to a variety of disks and input/output devices.
Permissions for devices existing at boot time are set in devfs.conf. Each line defines a full device path and octal permission value.
For devices that may be connected post-boot, we add an entry to a devfs.rules ruleset. Rulesets must have a unique name and number, and their rules are composed of a path or quoted path glob and octal permission value.
Enable our new ruleset.
Enable sound support at boot in loader.conf, and load it immediately with
/dev/sndstat to see your available devices.
hw.snd.default_unit sysctl variable controls the default audio output. I want to use the S/PDIF output of my onboard Realtek audio,
pcm6, so I set
hw.snd.default_auto boolean will automatically assign
hw.snd.default_unit to newly-attached devices.
Enable the sample
smartd.conf. It contains one directive,
DEVICESCAN, that causes smartd to scan all attached drives.
You can check the S.M.A.R.T. status of a drive directly with
smartctl as root. The
-H flag will show basic pass or fail health status, and the
-a flag will show everything.
FreeBSD has several available Java providers, including OpenJDK and ~~Sun’s~~ Oracle’s JDK. I recommend OpenJDK 6 for most people. It’s by far the easiest to install and is compatible with the IcedTea-Web browser plugin where OpenJDK 7 is not. An existing JDK is required to build a JDK, so you’ll need to fetch a pre-built binary package from the FreeBSD package repository.
For Opera, install www/opera-linuxplugins. For Firefox and everything else, install www/nspluginwrapper and execute
nspluginwrapper -v -a -i as your normal user to locate and enable the Linux Flash plugin.
Compiz is a sometimes-flashy compositing window manager popular with GNOME 2. You can install Compiz-Fusion from x11-wm/compiz-fusion. Be sure to disable the obsolete and unmaintained window decorator Emerald, a leftover from the Beryl project, when prompted on the port configuration screen.
Once installed, open Settings > Preferences > CompizConfig Settings Manager. You’ll probably want to enable the following plugins at minimum:
- General: Gnome Compatibility
- Desktop: Desktop Cube, Rotate Cube
- Effects: Animations, Window Decoration, Wobbly Windows
- Window Management: Application Switcher, Move Window, Place Windows, Resize Window
Open the “Run” box with Alt+F2 and execute
compiz-manager is a script for detecting and using the proper compiz options for your video hardware. Your screen will flash while Compiz and gtk-window-decorator initialize and replace Metacity, GNOME’s default window manager.
If your windows are missing titlebars, double-check you’ve enabled “Window Decoration” in
ccsm. If all seems well, add
compiz-manager as a new startup application (in Settings > Preferences > Startup Applications), then disable GNOME 2’s default window manager, Metacity, in GConf:
You’ll need one or more input methods once the IME itself is installed. Ports of interest:
- chinese/ibus-chewing - Chewing engine for IBus
- chinese/ibus-pinyin - The PinYin input method
- japanese/ibus-anthy - Anthy engine for IBus
- japanese/ibus-mozc - Mozc engine for IBus
- japanese/ibus-skk - SKK engine for IBus
- korean/ibus-hangul - Hangul engine for IBus
- textproc/ibus-kmfl - KMFL IMEngine for IBus framework
- textproc/ibus-m17n - The m17n IMEngine for IBus framework
- textproc/ibus-table - Table based IM framework for IBus
Open the IBus preferences from the Settings > Preferences menu, then add your chosen input methods. The control panel will prompt you to start ibus-daemon if it’s not running as well as implore you to add lines to your
.bashrc to start IBus at login. Ignore that, and instead add
/usr/local/bin/ibus-daemon -d as a startup item in Settings > Preferences > Startup Applications. Now run any GTK or QT application, press your keyboard shortcut to switch input methods, and test it out.
Preface: Skype is bad, propritary software that doesn’t value your freedom. Use audio/mumble instead of you can. If you still wish to use Skype, make sure you have Linuxulator enabled and install it from
Version 2.1 of Skype’s Linux client dropped support for OSS, found in FreeBSD as the default sound API. Thanks to this, Skype 2.0 persisted for years as the version in Ports. With the introduction of an ALSA compatibility shim in FreeBSD 8.3 and 9.0 and audio/linux-f10-alsa-plugins-oss/, we can use the newer ALSA-only Skype client.
The ALSA client, unlike the old OSS client, requires some explicit configuration to use our sound devices. They must be defined manually in
/compat/linux/etc/alsa/pcm/pcm-oss.conf, the configuration file of alsa-plugins-oss.
In this example, I enable
dsp6 for audio output, and
dsp8, a USB webcam, as a microphone source.
The microphone volume can be controlled by invoking the mixer of your chosen recording device. Let’s raise the microphone volume now from 0% to 75%.
FreeBSD currently lacks the ability to install 32-bit ports on a 64-bit system, precluding one from installing a 32-bit WINE capable of running 32-bit Windows applications.
Finding Clearlooks too drab and blue? You can find a world of themes and icons for GNOME over on GNOME-Look. There are several attractive and usable themes buried among the OS X Aqua clones, Vista Aero clones, and black-as-my-soul darkness-fests that are standard on any theming website.
GNOME 3, while available for a year on Linux, is still experimental on FreeBSD thanks in part to the upstream GNOME project’s continued fight against any operating system that doesn’t have a penguin for a mascot. It can be tested by merging the MarcusCom Ports tree using ports-mgmt/portshaker-config.
I’m a big fan of GNOME 2 and will probably move to MATE, a GNOME 2 fork, in the future.
This is personal preference, but I also set my
LC_TIME environment variable to the
en_DK faux-locale for ISO-8601 date formats instead of the ridiculous American standard.
Quick, what date is 6/5/12? Oh, it’s 2012-06-05, of course.
The locale isn’t included with the FreeBSD base system as it is in many Linux distributions, but it’s available from Ivan Voras’ blog.
Enable it in the login database and
Consider enabling sysutils/bsdstats, the BSDstats agent, to help increase awareness of BSD among vendors and users. By contributing your data, other users can get an overview of what types or hardware work and which ports are popular.
Lastly, and most importantly, enjoy FreeBSD!
This guide is a compilation of the installation notes from my recently-rebuilt desktop machine when I moved from FreeBSD 8 to 9. I’m very happy with my computer, and I hope you, the reader, are now happy with yours!