Skip to main content.

Building a FreeBSD desktop

2013-11-06

Live demo in BSD Now Episode 010 | Originally written by TJ for bsdnow.tv | Last updated: 2015/02/12

NOTE: the author/maintainer of the tutorial(s) is no longer with the show, so the information below may be outdated or incorrect.

While the BSD family of operating systems are known around the world for their stability, scalability, performance and security in the server space, they can actually make a pretty nice desktop as well. The PC-BSD project aims to provide an out-of-the-box BSD desktop system. If you're not comfortable configuring things by yourself, it's recommended that you use PC-BSD. For the rest of us who like doing things our own way, this guide will show you how to go from nothing to a FreeBSD desktop system. The only thing you need to do before reading this tutorial is have a FreeBSD CD, DVD or USB drive created. Let's boot up from the disk and get going! Hit enter and let's start answering some questions. Most of them should be pretty obvious and straightforward. Be sure to add your user to the "wheel" group when creating it. Once you've gone through the install, reboot and login as root on your new system.

The first thing you need to do is check that your network is up and running. ping is a good way to test if DNS and connectivity are both in good standing.

# ping -c 2 bsdnow.tv

PING bsdnow.tv (65.39.148.220): 56 data bytes
64 bytes from 65.39.148.220: icmp_seq=0 ttl=50 time=45.800 ms
64 bytes from 65.39.148.220: icmp_seq=1 ttl=50 time=43.682 ms

--- bsdnow.tv ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 43.682/44.741/45.800/1.059 ms

Keeping a system up to date is a very important part of running any OS. That's what I like to do first upon a new installation.

# freebsd-update fetch install

Looking up update.FreeBSD.org mirrors... 5 mirrors found.
Fetching public key from update5.freebsd.org... done.
Fetching metadata signature for 9.3-RELEASE from update5.freebsd.org... done.
Fetching metadata index... done.
Fetching 2 metadata files... done.
Inspecting system... done.
Preparing to download files... done.
Fetching 88 patches.....10....20....30....40....50....60....70....80.... done.
Applying patches...
[...]
Installing updates... done.

We'll put a basic firewall configuration in place.

# vi /etc/pf.conf

Something like:

ext_if = "em0"
set block-policy drop
set skip on lo0
scrub in all no-df random-id
block in all
antispoof quick for ($ext_if)
block in quick from { urpf-failed no-route } to any
pass out quick on $ext_if keep state 

Replace "em0" with the name of your network interface. Now, let's install some things we'll need. If you want to use pkgng and binary packages, feel free to do so. I'm going to be using ports instead, so skip over the next few parts if you are going binary-only. Let's extract the ports collection and edit a couple configuration files for it.

# portsnap fetch extract

Looking up portsnap.FreeBSD.org mirrors... 7 mirrors found.
Fetching public key from sourcefire.portsnap.freebsd.org... done.
Fetching snapshot tag from sourcefire.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Fri Aug 23 20:04:55 EDT 2013:
e1395518b91e1e2e3921ae45f57f09b656fb9adeb509c5  7% of   69 MB 1843 kBps

It will then extract the whole ports tree to /usr/ports. This may take a bit of time depending on your CPU, disk and network speeds. Before we actually start compiling things, I'd like to make some customizations to our /etc/make.conf file. It controls what options ports are built with.

# vi /etc/make.conf

This is mine. You can adopt it to your needs and how you want your system to be.

CC=clang
CXX=clang++
CPP=clang-cpp
WRKDIRPREFIX=/tmp
CPUTYPE?=native
WITH_PKGNG=yes

The clang-related and pkgng lines are only needed for FreeBSD 9.x and older. The first tool I always install is portmaster. It makes installing and upgrading ports a lot easier.

# cd /usr/ports/ports-mgmt/portmaster
# make install clean

Now we can start building all the software we'll need. My goal is a simple desktop with XFCE, Firefox for browsing and some other small things. You can change XFCE to your window manager or desktop environment of choice. My laptop has an older Intel GMA graphics chip, so I'll get the driver for that. If you have an nVidia card or newer Intel GPU, consult the FreeBSD handbook's nVidia page and Intel GPU wiki for information about what you need. I'm going to include some other utilities that I like having around. You can always add and remove ports, but it's easiest to just get everything you need at once. If you want Adobe Flash in your web browser, you need to install the Linux emulation layer. Although I don't want that stuff on my systems, I'm including it in the tutorial. The ports you install are your choice. Some other popular choices for a GUI would include: x11/gnome2, x11/kde4, x11-wm/i3, x11-wm/openbox, x11-wm/fluxbox, etc.

# portmaster -d --no-confirm x11-wm/xfce4 www/firefox x11/xorg x11/xinit x11/rxvt-unicode \ 
x11-drivers/xf86-video-intel sysutils/tmux x11-fonts/webfonts \
shells/bash editors/vim games/cowsay x11/dmenu graphics/feh sysutils/hal irc/irssi  \
x11/lxappearance multimedia/mplayer mail/mutt www/nspluginwrapper www/linux-f10-flashplugin11 \
x11-fm/pcmanfm net-p2p/rtorrent security/sudo x11-fonts/ubuntu-font x11-themes/gtk-murrine-engine \
sysutils/screenfetch x11/xdm misc/xfce4-wm-themes security/tor net/openntpd

Hit enter and portmaster will present you with configuration options for all the ports you're installing. If you don't know what to choose then just leave the defaults. I like to take out everything I'm not going to use. Once they've compiled, we add the Linux emulation module and HAL to start at boot. Since we're going to reboot anyway, we'll also add a couple other things to /etc/rc.conf, /etc/periodic.conf, /etc/devfs.rules and /etc/sysctl.conf. There are man pages for each of those configuration files if you're not familiar with them.

In /boot/loader.conf, add:

linux_load="YES"

In /etc/rc.conf, add:

pf_enable="YES"
pf_rules="/etc/pf.conf"
sendmail_enable="NONE"
usbd_enable="YES"
clear_tmp_enable="YES"
syslogd_flags="-ss"
update_motd="YES"
openntpd_enable="YES"
openntpd_flags="-s"
hald_enable="YES"
dbus_enable="YES"
xdm_enable="YES"
devfs_system_ruleset="localrules"

We want to be able to mount and unmount drives as a regular user. In /etc/devfs.rules, add:

[localrules=10]
add path 'da*' mode 0660 group wheel
add path 'md*' mode 0660 group wheel
add path 'ada*' mode 0660 group wheel

In /etc/sysctl.conf, add:

vfs.usermount=1

In /etc/periodic.conf, add:

daily_clean_preserve_enable="NO"
daily_backup_pkgdb_enable="NO"
daily_backup_aliases_enable="NO"
daily_status_security_ipfwdenied_enable="NO"
daily_status_security_ipfdenied_enable="NO"
daily_status_security_chkmounts_enable="NO"
daily_status_security_pfdenied_enable="NO"
weekly_status_pkg_enable="NO"
monthly_accounting_enable="NO"
weekly_locate_enable="NO"
weekly_whatis_enable="NO"
weekly_noid_enable="NO"
daily_status_security_chksetuid_enable="NO"
daily_clean_rwho_enable="NO"
daily_status_security_chkportsum_enable="NO"
daily_status_security_neggrpperm_enable="NO"
monthly_statistics_enable="NO"
monthly_statistics_report_devices="NO"

Add linprocfs:

# echo "linprocfs   /compat/linux/proc   linprocfs   rw   0  0" >> /etc/fstab
# reboot

After you log in, you should now have a functioning desktop with default settings, depending on what window manager and/or desktop environment you chose. If you chose to install Flash and the emulation stuff, get it working properly by issuing the following commands:

# ln -s /usr/local/lib/npapi/linux-f10-flashplugin/libflashplayer.so /usr/local/lib/browser_plugins/
$ nspluginwrapper -v -a -i

When you update Flash, run:

$ nspluginwrapper -v -a -u

You can install the PCBSD shell and GUI utilities to make some tasks like connecting to WiFi and managing disks easier. I recommend gnome-look, box-look or kde-look for downloading new themes. Of course, how to configure your graphical environment depends entirely on what window manager you use. I can't write a tutorial for each of them, but Google has lots of walkthroughs and tips for various environments. FreeBSD, as well as most other Unix-like systems, can be configured in countless different ways. It all depends on you personal preferences. I hope this guide was helpful as a starting point in getting your desktop system just how you like it. Here's how mine ended up:

Latest News

New announcement

2017-05-25

Hi, Mr. Dexter...

Two Year Anniversary

2015-08-08

We're quickly approaching our two-year anniversary, which will be on episode 105. To celebrate, we've created a unique t-shirt design, available for purchase until the end of August. Shirts will be shipped out around September 1st. Most of the proceeds will support the show, and specifically allow us to buy...

New discussion segment

2015-01-17

We're thinking about adding a new segment to the show where we discuss a topic that the listeners suggest. It's meant to be informative like a tutorial, but more of a "free discussion" format. If you have any subjects you want us to explore, or even just a good name...

How did you get into BSD?

2014-11-26

We've got a fun idea for the holidays this year: just like we ask during the interviews, we want to hear how all the viewers and listeners first got into BSD. Email us your story, either written or a video version, and we'll read and play some of them for...


Episode 207: Bridge over the river Cam

2017-08-16

Direct Download:HD VideoMP3 AudioTorrent This episode was brought to you by Headlines BSDCam recap The 2017 Cambridge DevSummit took place from 2-4 August 2017. The event took place over three days including a formal dinner at St John's College, and was attended by 55 registered developers and guests. Prior to the start of...

Episode 206: To hier is UNIX

2017-08-09

HD VideoMP3 AudioTorrent This episode was brought to you by Headlines Lumina Desktop v1.3 released Notable Changes: New Utility: lumina-mediaplayer. Lumina Media Player is a graphic interface for the Qt QMediaPlayer Class, with Pandora internet radio streaming integration. Lumina Media Player supports many audio formats, including .ogg, .mp3, .mp4, .flac, and .wmv. It is also...

Episode 205: FreeBSD Turning it up to 11.1

2017-08-02

Direct Download:HD VideoMP3 AudioTorrent This episode was brought to you by Headlines FreeBSD 11.1-RELEASE FreeBSD 11.1 was released on July 26th You can download it as an ISO or USB image, a prebuilt VM Image (vmdk, vhd, qcow2, or raw), and it is available as a cloud image (Amazon EC2, Microsoft Azure, Google Compute Engine,...

Episode 204: WWF - Wayland, Weston, and FreeBSD

2017-07-26

Direct Download:HD VideoMP3 AudioTorrent This episode was brought to you by Headlines Matt Ahrens answers questions about the “Scrub of Death” In working on the breakdown of that ZFS article last week, Matt Ahrens contacted me and provided some answers he has given to questions in the past, allowing me to answer them using...