Published on (
 See this if you're having trouble printing code examples

FreeBSD Basics Turn FreeBSD into a Multimedia Workstation

by Dru Lavigne

I recently purchased a shiny new PC and decided to turn it into a multimedia desktop. I spend far too much time in research and networking; I figured it was time to delve deeper into the world of Flash, DVD, and mp3s.

FreeBSD still seems to get a bad rap as a desktop. The impression is still out there that sure, it's a rock-solid server, but you need a master's degree in rocket science in order to get a sound card or Java to work. Hogwash. Granted, you still have to take the time to build and configure the components you desire, but that is the beauty of FreeBSD. No company is deciding for you what you want in your desktop, and you have the satisfaction of knowing you built your system your way. Not to mention the literally hundreds of multimedia applications to choose from, some which put their commercial counterparts to shame.

In today's article, I'll concentrate on a fresh install that is totally up-to-date, then move on to integrating Java, Flash, and streaming multimedia into a browser. I'll be taking the slow, systematic route, so follow along and pick out the bits that are interesting to you.

Being the paranoid person that I am, I like to install from CD, reboot into a firewalled system, than CVSup to the latest sources. Before starting any install, I always copy the following onto a floppy:

I then start the install from CD and choose to install everything, including the ports collection. Once bin has been installed, I press Alt-F4, which now has a prompt. I then mount the floppy and copy over the first three files:

mkdir /floppy
mount -t msdos /dev/fd0 /floppy
cp /floppy/.cshrc .
source .cshrc  (I now have my favorite prompt)

cp /floppy/.cshrc /usr/share/skel/dot.cshrc (now the users I create will 
					    also get my favorite prompt)

cp /floppy/ipfw.rules /etc/
cp /floppy/rc.conf /etc/
umount /floppy

Usually, by the time I've unmounted the floppy, the install is also finished and prompting me for post-install configuration. I then reboot and watch the messages to ensure that my firewall rules successfully load.

Now that I'm protected by a firewall, I'll go out on the Internet and download the latest sources and today's port collection. First, I'll install the cvsup-without-gui utility:

cd /usr/ports/net/cvsup-without-gui
make install clean

Once the build is finished, I'll remount that floppy and copy over the remaining files:

mount -t msdos /dev/fd0 /floppy
cp /floppy/cvs-supfile ~
cp /floppy/make.conf /etc/
cd /usr/local/etc
mkdir cvsup
cd cvsup
mkdir sup
cd sup
cp /floppy/refuse .
umount /floppy

If you've never done a CVSup before, you'll want to read the CVSup section of the handbook first.

I was both intimidated and intrigued when I was first introduced to the whole CVSup concept. Now, I couldn't live without it, and the knowledge that my operating system is completely up-to-date in security and functionality and that all of my installed applications are the latest and greatest. The handbook will show you how to customize the files needed to use CVSup; mine look like this:

more /root/cvs-supfile
*default base=/usr/local/etc/cvsup
*default prefix=/usr
*default tag=RELENG_4_6_2_RELEASE
*default release=cvs delete use-rel-suffix compress
ports-all tag=.
doc-all tag=.

more /usr/local/etc/cvsup/sup/refuse

more /etc/make.conf
# $FreeBSD: src/etc/defaults/make.conf,v 
#        2002/06/02 16:07:01 matusita Exp $
CFLAGS= -O -pipe
# To avoid building various parts of the base system:
NO_BIND=	true	# do not build BIND
NO_FORTRAN=	true	# do not build g77 and related libraries
NO_I4B=	true	# do not build isdn4bsd package
NO_LPR=	true	# do not build lpr and related programs
NOPROFILE=	true	# Avoid compiling profiled libraries
NOUUCP=	true	# do not build uucp related programs
DOC_LANG=	en_US.ISO8859-1 

Once you have created your own customized files, invoke CVSup like so:

cvsup -g -L 2 ~/cvs-supfile

The CVSup utility will do its thing, and the results will be displayed to your screen. The first time you run this program, you will download a lot of changes to src; this means you'll also be rebuilding your world. (What did you do on Saturday? Oh, nothing much, just rebuilt the world ... ) You don't have to rebuild the world everytime you CVSup, just when there are changes to src. Once your system is up-to-date, src rarely changes; usually this only occurs when there is a security-related patch. The handbook gives instructions on how to cron your CVSup; I prefer to do mine by hand, so I can watch the output to see if src has changed.

The CVSup utility will also download all of the new ports changes. Ports change on a daily basis, so I like to CVSup every day or so to keep my ports collection up-to-date. I then use the portupgrade utility found in the sysutils section of the ports collection to keep my already installed ports up-to-date. Michael Lucas wrote an excellent article on the portupgrade utility, which should get you started.

Since I'm on a new system, I'll rebuild the world once CVSup is finished. Again, if you've never built a world, a careful read of that section of the handbook is in order.

Since this a fresh install, I don't have any data to back up. If I ever need to rebuild the world on a working system, I'll definitely take a few minutes and back up /etc and my home directory:

cd /etc
tar czvf /dev/fd0 .
tar czvf etc.tar .

I take extra care with /etc and back it up to both a floppy and a file. I then email myself that file, just in case things go terribly wrong. I tend to be less diligent with my home directory, as I usually don't have any data that I would shed tears over if it was lost. Except for my bookmarks; I always email myself a copy of my bookmarks. If you're attached to your data, back up your home directory.

The first time you build world, follow the handbook's instructions carefully and be prepared for it to take a while. Also, use the generic kernel; wait until you have a new world before you customize your kernel. On a fresh install, I go straight into single user mode, which means I can't do anything else on that computer for a few hours. On a working system, I tend to cheat a little and not go into single user mode until it's time to actually install the world.

shutdown now
cd /usr/src		    (enters single user mode)
make -j4 buildworld	(this is the step that takes the longest; 
                     it took about 2 hours on a freshly installed 
                     P3 with 320 MB of RAM)
make buildkernel
make installkernel
make installworld
shutdown -r now

Once my system reboots, I have a totally up-to-date operating system, which means I can start installing my favorite applications. I'll start with the latest release of XFree86, as many of the multimedia applications use it. I've found the easiest way to install is to download the sources directly and use the built-in install script. Since I haven't installed any applications yet, I'll download these files the old-fashioned way. But first, I'll create a directory to hold the files and cd into that directory before starting the ftp:

mkdir /usr/XFree86-4
cd /usr/XFree86-4

Connected to
220 FTP server (Version wu-2.6.1(1) Wed Dec 5 13:09:53 EST 
2001) ready.
Name ( anonymous
331 Guest login ok, send your complete e-mail address as password.
ftp> cd pub
ftp> cd XFree86
ftp> cd 4.3.0
ftp> cd binaries
ftp> cd FreeBSD-4.x
ftp> get
ftp> get extract
ftp> get Xbin.tgz
ftp> get Xlib.tgz
ftp> get Xman.tgz
ftp> get Xdoc.tgz
ftp> get Xfnts.tgz
ftp> get Xfenc.tgz
ftp> get Xetc.tgz
ftp> get Xvar.tgz
ftp> get Xxserv.tgz
ftp> get Xmod.tgz
ftp> bye

Now, it's a simple matter of invoking the script:


and answering the questions as they appear. (Pressing enter for the default answer works, if you're unsure of the correct answer.)

Once that is finished, I start building my favorite windows manager. Currently, this is KDE, which is a very, very long build; the kind of build you start before going to bed in the hopes that it will be finished by the time you wake up in the morning. So, I'll start its build in one terminal:

cd /usr/ports/x11/kde3
make install clean

I'll then go to a second terminal and install the XFree86-4 libraries before I forget; most of the applications I'll be building require these:

cd /usr/ports/x11/XFree86-4-libraries
make install clean

And on a third terminal, I'll configure the XFree86 Server. This is the first time I had configured a system with an USB mouse; during the install, I answered yes when it asked if I had a USB mouse. I'll now double-check that I have the following lines in /etc/rc.conf:


Before configuring your own XFree86 Server, make sure you have the following information:


XF86Setup  (if you have an unsupported video card and get an error 
		    message, choose xf86config instead)

If you're prompted to configure your mouse, do so, and test it 'til it works. You will then be able to use it to select your video card and desired settings. Hopefully, all will go well for you fairly quickly.

Once I had a running XFree86 Server, I left the superuser account and created a .xinitrc file in my home directory that contained the following line:

exec startkde

Once KDE finally finishes building, I'll be able to type startx to receive my KDE desktop.

Next comes the browser. I've been pretty satisfied with Mozilla; it has its flaky moments, but for the most part it is speedy, configurable, and supports plugins and skins.

cd /usr/ports/www/mozilla
make install clean

Next, I'll create a custom kernel that supports Java and sound:

cd /usr/src/sys/i386/conf

I'll then add the following lines to MULTIMEDIA:

options		USER_LDT		#used by java
options		CPU_ENABLE_SSE		#used by DVD
device		pcm			#builds PCI soundblaster support

I've always had good luck with the SoundBlaster PCI 128; it's a reasonably-priced soundcard that only requires one line in the kernel configuration file in order to work.

Once I've saved my changes to MULTIMEDIA:

cd /usr/src
make buildkernel KERNCONF=MULTIMEDIA
make installkernel KERNCONF=MULTIMEDIA

Once the kernel is installed, I'll ensure that I've saved all of the work on my other terminals, then:


Now, I'll use Mozilla to download the files I need for Java support:

cd /usr/ports/java/linux-sun-jdk13
make install clean

cd /usr/ports/java/jdk13
make install clean

To see if it worked, restart Mozilla and go to Help -> About Plug-ins. You should get about a page's worth of Java plugins. A short trip to should convince you that Java is indeed functional.

Next comes streaming multimedia:

cd /usr/ports/www/plugger
make install clean 

This port installs mpeg, avi, quicktime, midi, and pdf support; you'll see the full list once you re-check your Help -> About Plug-ins. Then, head over to the plugger testing grounds.

Finally, the Flash plugin:

cd /usr/ports/www/flashplugin-mozilla
make install clean

Before installing this plugin, be advised that Flash is a registered trademark and it was "designed solely for the Windows PC and Macintosh desktop operating systems." There are also redistribution issues, which means that the GPL version does NOT support full Flash functionality. This means that some Flash sites will work, some will hang, some will crash your browser.

Related Reading

Unix Power Tools
By Shelley Powers, Jerry Peek, Tim O'Reilly, Mike Loukides

For example, if you install the Flash plugin, don't bother heading over to unless you want to watch your browser crash. And I've found that it depends upon the phase of the moon and a certain combination of mojo whether or not the Flash ecards at Hallmark will show me anything other than a grey screen. However, my browser seems to have no problems displaying those annoying Flash introductions that are becoming increasingly popular on Web sites. Go figure.

Now that Mozilla supports plugins, I'll move on to installing some skins. Go to the Edit menu -> Preferences. Click on Appearance -> Themes, then click on the hyperlink for Get New Themes.

I liked the themes at SkyPilot looked interesting, so I clicked on its link, then on SkyPilot again in the Install row of the chart. I then checked "Use this theme" in the Confirm box and pressed OK. Once the install did its thing, I went back to Preferences, highlighted SkyPilot and pressed OK. Mozilla informed me the changes would take effect the next time I started Mozilla.

Now that my browser looks pretty awesome, I'll head over to my favorite wallpaper site:

To change the wallpaper in KDE, right click the desktop and choose Configure Desktop. Click on the Background icon, the Wallpaper tab, and browse for your favorite wallpaper.

In next week's article, we'll move on to the wonderful world of sound and some utilities that will impress even your Windows buddies.

Editor's note: a previous version of this article mistakenly used make installworld instead of make installkernel. As well, the link to the plugger testing grounds has been fixed. We apologize for the inconvenience.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.

Read more FreeBSD Basics columns.

Return to the BSD DevCenter.

Copyright © 2009 O'Reilly Media, Inc.