A FreeBSD 9 Desktop How-to

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.

Installation

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.

First Boot

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.

Securing passwd

Enable the Blowfish hash function instead of the default aging MD5 algorithm.

  1. echo "crypt_default=blf" >> /etc/auth.conf
/etc/login.conf
  1. --- login.conf.default 2012-01-02 17:08:05.804291477 -0500
  2. +++ login.conf 2012-01-02 17:08:16.996213774 -0500
  3. @@ -23,7 +23,7 @@
  4. # AND SEMANTICS'' section of getcap(3) for more escape sequences).
  5. default:\
  6. - :passwd_format=md5:\
  7. + :passwd_format=blf:\
  8. :copyright=/etc/COPYRIGHT:\
  9. :welcome=/etc/motd:\
  10. :setenv=MAIL=/var/mail/$,BLOCKSIZE=K,FTP_PASSIVE_MODE=YES:\

Rebuild the login database with cap_mkdb /etc/login.conf, then set your new blf-hashed root password with passwd.

UTF-8

The 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 LANG=C.

Check locale -a | grep UTF-8 for a list of every available UTF-8 locale. As an American anglophone, I use en_US.UTF-8.

Edit the login database once again to add a default character set and locale.

/etc/login.conf
  1. --- login.conf.default 2012-01-02 17:08:05.804291477 -0500
  2. +++ login.conf 2012-01-02 17:08:16.996213774 -0500
  3. @@ -44,7 +44,9 @@
  4. :pseudoterminals=unlimited:\
  5. :priority=0:\
  6. :ignoretime@:\
  7. - :umask=022:
  8. + :umask=022:\
  9. + :charset=UTF-8:\
  10. + :lang=en_US.UTF-8:

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.

/etc/profile
  1. LANG=en_US.UTF-8; export LANG
  2. GDM_LANG=en_US.UTF-8; export GDM_LANG

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.

  1. echo "QT4_OPTIONS= CUPS QGTKSTYLE" >> /etc/make.conf

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 /usr/local PREFIX. 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.

  1. echo "KDE4_PREFIX=/usr/local" >> /etc/make.conf

Nouvelles Bibliothèques

Set WITHOUT_NOUVEAU in make.conf before continuing, unless you plan to use the Nouveau or Intel graphics drivers.

  1. echo "WITHOUT_NOUVEAU=yes" >> /etc/make.conf

This explicitly disables the Free nvidia driver Nouveau, causing Ports to install newer versions of graphics/libdrm, graphics/libGL, and graphics/dri.

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 Networking

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.

/etc/rc.conf
  1. # Enable DHCP for re0 and don't let dhclient block
  2. background_dhclient="YES"
  3. ifconfig_re0="DHCP"
  4. hostname="emi"

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).

/etc/rc.conf
  1. wlans_run0="wlan0"
  2. ifconfig_wlan0="ssid Doubleshot WPA DHCP"
/etc/wpa_supplicant.conf
  1. network={
  2. ssid="Doubleshot"
  3. psk="pantsupantsu"
  4. }

Ports

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.) Run 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 make install.

When complete, do the same in /usr/ports/x11/xorg to install the X.org X11 distribution.

Install fonts

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 /etc/make.conf first.

/etc/make.conf
  1. # Enable Tahoma in x11-fonts/webfonts if you have a Windows license
  2. # You show me yours and I'll show you mine ;)
  3. .if ${.CURDIR:M*/x11-fonts/webfonts}
  4. WITH_MSWINDOWS_LICENSE=yes
  5. .endif

You can install other invididual fonts later as a user by copying them to ~/.fonts under your home directory.

Enable Linuxulator

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.

  1. echo 'linux_load="YES"' >> /boot/loader.conf

Install nvidia-driver

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.

Install the driver, x11/nvidia-settings, and x11/nvidia-xconfig.

To load the nvidia kernel module at boot, enable it in /boot/loader.conf.

  1. echo 'nvidia_load="YES"' >> /boot/loader.conf

Configuration

X.org and nvidia

Run 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 Files and Module sections to enable freetype2, glx, type1, and to let X know about those fonts you just installed.

/etc/X11/xorg.conf
  1. Section "Files"
  2. FontPath "/usr/local/lib/X11/fonts/misc/:unscaled"
  3. FontPath "/usr/local/lib/X11/fonts/misc/"
  4. FontPath "/usr/local/lib/X11/fonts/TTF/"
  5. FontPath "/usr/local/lib/X11/fonts/TrueType/"
  6. FontPath "/usr/local/lib/X11/fonts/CharisSIL/"
  7. FontPath "/usr/local/lib/X11/fonts/Droid/"
  8. FontPath "/usr/local/lib/X11/fonts/DoulosSIL/"
  9. FontPath "/usr/local/lib/X11/fonts/ecofont/"
  10. FontPath "/usr/local/lib/X11/fonts/OTF/"
  11. FontPath "/usr/local/lib/X11/fonts/Type1/"
  12. FontPath "/usr/local/lib/X11/fonts/artwiz-aleczapka-en/"
  13. FontPath "/usr/local/lib/X11/fonts/bitstream-vera/"
  14. FontPath "/usr/local/lib/X11/fonts/cyrillic/"
  15. FontPath "/usr/local/lib/X11/fonts/hebrew/"
  16. FontPath "/usr/local/lib/X11/fonts/dejavu/"
  17. FontPath "/usr/local/lib/X11/fonts/local/"
  18. FontPath "/usr/local/lib/X11/fonts/100dpi/"
  19. FontPath "/usr/local/lib/X11/fonts/75dpi/"
  20. FontPath "/usr/local/lib/X11/fonts/encodings/"
  21. FontPath "/usr/local/lib/X11/fonts/alee-ttf/"
  22. FontPath "/usr/local/lib/X11/fonts/anonymous-pro/"
  23. FontPath "/usr/local/lib/X11/fonts/fonts-indic/"
  24. FontPath "/usr/local/lib/X11/fonts/gentium/"
  25. FontPath "/usr/local/lib/X11/fonts/gentium-basic/"
  26. FontPath "/usr/local/lib/X11/fonts/Hana/"
  27. FontPath "/usr/local/lib/X11/fonts/stracke/"
  28. FontPath "/usr/local/lib/X11/fonts/junicode/"
  29. FontPath "/usr/local/lib/X11/fonts/profont/"
  30. FontPath "/usr/local/lib/X11/fonts/proggy_fonts-ttf/"
  31. FontPath "/usr/local/lib/X11/fonts/stix/"
  32. FontPath "/usr/local/lib/X11/fonts/terminus-font/"
  33. FontPath "/usr/local/lib/X11/fonts/tolkien-ttf/"
  34. FontPath "/usr/local/lib/X11/fonts/ubuntu-font/"
  35. FontPath "/usr/local/lib/X11/fonts/unfonts-core/"
  36. FontPath "/usr/local/lib/X11/fonts/unfonts-extra/"
  37. FontPath "/usr/local/lib/X11/fonts/webfonts/"
  38. FontPath "/usr/local/share/fonts/TrueType/"
  39. FontPath "/usr/local/share/fonts/TTF/"
  40. FontPath "/usr/local/share/fonts/amsfonts/"
  41. FontPath "/usr/local/share/fonts/cantarell/"
  42. FontPath "/usr/local/share/fonts/shinonome/"
  43. FontPath "/usr/local/share/fonts/cm-super/"
  44. FontPath "/usr/local/share/fonts/std.ja_JP/"
  45. EndSection
  46. Section "Module"
  47. Load "freetype"
  48. Load "bitmap"
  49. Load "type1"
  50. Load "glx"
  51. EndSection

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 nvidia-driver.

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.

/etc/X11/xorg.conf
  1. Section "Extensions"
  2. Option "Composite" "Enable"
  3. EndSection

Add one line to the ServerLayout section to enable AIGLX.

/etc/X11/xorg.conf
  1. Section "ServerLayout"
  2. Identifier "X.org Configured"
  3. Screen 0 "Screen0" 0 0
  4. InputDevice "Mouse0" "CorePointer"
  5. InputDevice "Keyboard0" "CoreKeyboard"
  6. Option "AIGLX" "true"
  7. EndSection

Enable the EXA AccelMethod and DRI by adding their respective lines to the Device section. Ensure your Driver is configured as radeon, not radeonhd! radeonhd is an older, Novell-sponsored, defunct driver for Radeon HD hardware. You should use radeon instead.

/etc/X11/xorg.conf
  1. Section "Device"
  2. Option "AccelMethod" "EXA"
  3. Option "DRI" "true"
  4. Identifier "Card0"
  5. Driver "radeon"
  6. VendorName "Advanced Micro Devices [AMD] nee ATI"
  7. BoardName "RV770 [Radeon HD 4850]"
  8. BusID "PCI:1:0:0"
  9. EndSection

Lastly, let X know about those fonts you installed by appending their FontPath to the Files section.

/etc/X11/xorg.conf
  1. Section "Files"
  2. ModulePath "/usr/local/lib/xorg/modules"
  3. FontPath "/usr/local/lib/X11/fonts/misc/:unscaled"
  4. FontPath "/usr/local/lib/X11/fonts/misc/"
  5. FontPath "/usr/local/lib/X11/fonts/TTF/"
  6. FontPath "/usr/local/lib/X11/fonts/TrueType/"
  7. FontPath "/usr/local/lib/X11/fonts/CharisSIL/"
  8. FontPath "/usr/local/lib/X11/fonts/Droid/"
  9. FontPath "/usr/local/lib/X11/fonts/DoulosSIL/"
  10. FontPath "/usr/local/lib/X11/fonts/ecofont/"
  11. FontPath "/usr/local/lib/X11/fonts/OTF/"
  12. FontPath "/usr/local/lib/X11/fonts/Type1/"
  13. FontPath "/usr/local/lib/X11/fonts/artwiz-aleczapka-en/"
  14. FontPath "/usr/local/lib/X11/fonts/bitstream-vera/"
  15. FontPath "/usr/local/lib/X11/fonts/cyrillic/"
  16. FontPath "/usr/local/lib/X11/fonts/hebrew/"
  17. FontPath "/usr/local/lib/X11/fonts/dejavu/"
  18. FontPath "/usr/local/lib/X11/fonts/local/"
  19. FontPath "/usr/local/lib/X11/fonts/100dpi/"
  20. FontPath "/usr/local/lib/X11/fonts/75dpi/"
  21. FontPath "/usr/local/lib/X11/fonts/encodings/"
  22. FontPath "/usr/local/lib/X11/fonts/alee-ttf/"
  23. FontPath "/usr/local/lib/X11/fonts/anonymous-pro/"
  24. FontPath "/usr/local/lib/X11/fonts/fonts-indic/"
  25. FontPath "/usr/local/lib/X11/fonts/gentium/"
  26. FontPath "/usr/local/lib/X11/fonts/gentium-basic/"
  27. FontPath "/usr/local/lib/X11/fonts/Hana/"
  28. FontPath "/usr/local/lib/X11/fonts/stracke/"
  29. FontPath "/usr/local/lib/X11/fonts/junicode/"
  30. FontPath "/usr/local/lib/X11/fonts/profont/"
  31. FontPath "/usr/local/lib/X11/fonts/proggy_fonts-ttf/"
  32. FontPath "/usr/local/lib/X11/fonts/stix/"
  33. FontPath "/usr/local/lib/X11/fonts/terminus-font/"
  34. FontPath "/usr/local/lib/X11/fonts/tolkien-ttf/"
  35. FontPath "/usr/local/lib/X11/fonts/ubuntu-font/"
  36. FontPath "/usr/local/lib/X11/fonts/unfonts-core/"
  37. FontPath "/usr/local/lib/X11/fonts/unfonts-extra/"
  38. FontPath "/usr/local/lib/X11/fonts/webfonts/"
  39. FontPath "/usr/local/share/fonts/TrueType/"
  40. FontPath "/usr/local/share/fonts/TTF/"
  41. FontPath "/usr/local/share/fonts/amsfonts/"
  42. FontPath "/usr/local/share/fonts/cantarell/"
  43. FontPath "/usr/local/share/fonts/shinonome/"
  44. FontPath "/usr/local/share/fonts/cm-super/"
  45. FontPath "/usr/local/share/fonts/std.ja_JP/"
  46. EndSection

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.

/etc/sysctl.conf
  1. # Enhance shared memory X11 interface
  2. kern.ipc.shmmax=67108864
  3. kern.ipc.shmall=32768
  4. # Enhance desktop responsiveness under high CPU use (200/224)
  5. kern.sched.preempt_thresh=224
  6. # Bump up maximum number of open files
  7. kern.maxfiles=200000
  8. # Disable PC Speaker
  9. hw.syscons.bell=0

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.

/boot/loader.conf
  1. # Devil worship in loader logo
  2. loader_logo="beastie"
  3. # Boot-time kernel tuning
  4. kern.ipc.shmseg=1024
  5. kern.ipc.shmmni=1024
  6. kern.maxproc=10000
  7. # Load MMC/SD card-reader support
  8. mmc_load="YES"
  9. mmcsd_load="YES"
  10. sdhci_load="YES"
  11. # Access ATAPI devices through the CAM subsystem
  12. atapicam_load="YES"
  13. # Filesystems in userspace (SSHFS, etc)
  14. fuse_load="YES"
  15. # Userland character device driver for webcams
  16. cuse4bsd_load="YES"
  17. # Intel Core thermal sensors
  18. coretemp_load="YES"
  19. # AMD K8, K10, K11 thermal sensors
  20. amdtemp_load="YES"
  21. # In-memory filesystems
  22. tmpfs_load="YES"
  23. # Asynchronous I/O
  24. aio_load="YES"
  25. # Handle Unicode on removable media
  26. libiconv_load="YES"
  27. libmchain_load="YES"
  28. cd9660_iconv_load="YES"
  29. msdosfs_iconv_load="YES"

Turn on GNOME and related services to start HAL and D-Bus and get graphical logins with GDM. gnome_enable implies dbus_enable, hald_enable, and gdm_enable, but I enable them all explicitly to avoid errors complaining they aren’t set.

/etc/rc.conf
  1. # Enable GNOME and required services
  2. gnome_enable="YES"
  3. dbus_enable="YES"
  4. hald_enable="YES"
  5. gdm_enable="YES"

Finally, enable everything else.

/etc/rc.conf
  1. # Filesystems in userspace
  2. fusefs_enable="YES"
  3. # Webcam daemon
  4. webcamd_enable="YES"
  5. # Disable line printer daemon since we have CUPS
  6. lpd_enable="NO"
  7. # Enable CUPS
  8. cupsd_enable="YES"
  9. # powerd: adaptive speed while on AC power, adaptive while on battery power
  10. powerd_enable="YES"
  11. powerd_flags="-a hiadaptive -b adaptive"
  12. # Enable IPV6 support
  13. ipv6_activate_all_interfaces="YES"
  14. # Enable BlueTooth
  15. hcsecd_enable="YES"
  16. sdpd_enable="YES"
  17. # Synchronize system time
  18. ntpd_enable="YES"

Enable remote access via SSH if you plan to use it. Otherwise, there’s no need to expose your system.

/etc/rc.conf
  1. # Remote logins
  2. sshd_enable="YES"

Mounts

Mount the procfs, fdesc, and linprocfs virtual filesystems for compatibility with GNOME and other programs requiring them.

/etc/fstab
  1. proc /proc procfs rw 0 0
  2. fdesc /dev/fd fdescfs rw 0 0
  3. linprocfs /compat/linux/proc linprocfs rw 0 0

Then, set a sysctl variable and configure PolicyKit to allow normal users to mount removable media automatically in GNOME.

/etc/sysctl.conf
  1. # Allow users to mount disks
  2. vfs.usermount=1
/usr/local/etc/PolicyKit/PolicyKit.conf
  1. <config version="0.1">
  2. <match action="org.freedesktop.hal.storage.mount-removable">
  3. <return result="yes"/>
  4. </match>
  5. <match action="org.freedesktop.hal.storage.mount-fixed">
  6. <return result="yes"/>
  7. </match>
  8. <match user="root">
  9. <return result="yes"/>
  10. </match>
  11. <define_admin_auth group="wheel"/>
  12. </config>

Device Permissions

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.

/etc/devfs.conf
  1. # Allow all users to access optical media
  2. perm /dev/acd0 0666
  3. perm /dev/acd1 0666
  4. perm /dev/cd0 0666
  5. perm /dev/cd1 0666
  6. # Allow all USB Devices to be mounted
  7. perm /dev/da0 0666
  8. perm /dev/da1 0666
  9. perm /dev/da2 0666
  10. perm /dev/da3 0666
  11. # Misc other devices
  12. perm /dev/pass0 0666
  13. perm /dev/xpt0 0666
  14. perm /dev/uscanner0 0666
  15. perm /dev/video0 0666
  16. perm /dev/dvb/adapter0/demux0 0666
  17. perm /dev/dvb/adapter0/dvr 0666
  18. perm /dev/dvb/adapter0/frontend0 0666

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.

/etc/devfs.rules
  1. [devfsrules_common=7]
  2. add path 'ad[0-9]*' mode 666
  3. add path 'ada[0-9]*' mode 666
  4. add path 'da[0-9]*' mode 666
  5. add path 'acd[0-9]*' mode 666
  6. add path 'cd[0-9]*' mode 666
  7. add path 'mmcsd[0-9]*' mode 666
  8. add path 'pass[0-9]*' mode 666
  9. add path 'xpt[0-9]*' mode 666
  10. add path 'ugen[0-9]*' mode 666
  11. add path 'usbctl' mode 666
  12. add path 'usb/*' mode 666
  13. add path 'lpt[0-9]*' mode 666
  14. add path 'ulpt[0-9]*' mode 666
  15. add path 'unlpt[0-9]*' mode 666
  16. add path 'fd[0-9]*' mode 666
  17. add path 'uscan[0-9]*' mode 666
  18. add path 'video[0-9]*' mode 666
  19. add path 'dvb/*' mode 666

Enable our new ruleset.

/etc/rc.conf
  1. devfs_system_ruleset="devfsrules_common"

Sound

Enable sound support at boot in loader.conf, and load it immediately with kldload snd_driver.

  1. echo 'snd_driver_load="YES"' >> /boot/loader.conf

Then, inspect /dev/sndstat to see your available devices.

  1. cat /dev/sndstat
  2. FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64)
  3. Installed devices:
  4. pcm0: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
  5. pcm1: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
  6. pcm2: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
  7. pcm3: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
  8. pcm4: <HDA Realtek ALC892 PCM #0 Analog> (play/rec)
  9. pcm5: <HDA Realtek ALC892 PCM #1 Analog> (play/rec)
  10. pcm6: <HDA Realtek ALC892 PCM #2 Digital> (play)
  11. pcm7: <HDA Realtek ALC892 PCM #3 Digital> (play)
  12. pcm8: <USB audio> (play) default
  13. pcm9: <USB audio> (rec)

The 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_unit to 6.

Enabling the hw.snd.default_auto boolean will automatically assign hw.snd.default_unit to newly-attached devices.

/etc/sysctl.conf
  1. # S/PDIF out on my MSI board
  2. hw.snd.default_unit=6
  3. # Automatically use new sound devices
  4. hw.snd.default_auto=1

S.M.R.T.

sysutils/smartmontools installs smartd and smartctl, a daemon and utility for checking the S.M.A.R.T. status of your local disks.

Enable the sample smartd.conf. It contains one directive, DEVICESCAN, that causes smartd to scan all attached drives.

  1. cp /usr/local/etc/smartd.conf.sample /usr/local/etc/smartd.conf
  2. echo 'smartd_enable="YES"' >> /etc/rc.conf
  3. service smartd start

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.

smartctl -Hlink
  1. smartctl 5.42 2011-10-20 r3458 [FreeBSD 9.0-RELEASE amd64] (local build)
  2. Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
  3. === START OF READ SMART DATA SECTION ===
  4. SMART overall-health self-assessment test result: PASSED

Extras

Java

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.

  1. pkg_add -r openjdk6

From now on you may build and update the java/openjdk6 port normally using your installed openjdk. If you’re in need of a Java browser plugin, install java/icedtea-web.

Flash Player

Adobe Flash Player is usable on FreeBSD i386 and amd64. Make sure you have Linuxulator enabled and linprocfs mounted, then install Flash from www/linux-f10-flashplugin11.

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-Fusion

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. 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:

  1. gconftool-2 --type string --set /desktop/gnome/session/required_components/windowmanager dummy

IBus

IBus is a modern IME for Unix-like systems, allowing one to input CJK languages. Install the main IME from textproc/ibus as well as QT application support from textproc/ibus-qt.

You’ll need one or more input methods once the IME itself is installed. Ports of interest:

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.

IBus preferences window showing available input methods. GVim testing IBus input with Japanese.

Skype

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 /usr/ports/net-im/skype.

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 pcm6/dsp6 for audio output, and pcm8/dsp8, a USB webcam, as a microphone source.

/compat/linux/etc/alsa/pcm/pcm-oss.conf
  1. pcm.oss8 {
  2. type oss
  3. device /dev/dsp8
  4. hint {
  5. description "Open Sound System - Webcam"
  6. }
  7. }
  8. ctl.oss8 {
  9. type oss
  10. device /dev/mixer8
  11. hint {
  12. description "Open Sound System - Webcam"
  13. }
  14. }
  15. pcm.oss6 {
  16. type oss
  17. device /dev/dsp6
  18. hint {
  19. description "Open Sound System - S/PDIF"
  20. }
  21. }
  22. ctl.oss6 {
  23. type oss
  24. device /dev/mixer6
  25. hint {
  26. description "Open Sound System - S/PDIF"
  27. }
  28. }

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%.

  1. mixer -f /dev/mixer8 mic 75

Miscellany

WINE

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.

As a workaround, David Naylor maintains WINE32 packages for FreeBSD amd64. They can be installed with pkg_add.

Theming

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.

I’m using Shiki-Colors Elegant. It requires the Murrine GTK engine from x11-themes/gtk-murrine-engine.

GNOME 3?

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.

ISO-8601

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.

  1. tar -C /usr/share/locale -zxf /path/to/your/en_DK.UTF-8.tgz

Enable it in the login database and /etc/profile.

/etc/login.conf
  1. @@ -46,7 +46,8 @@
  2. :ignoretime@:\
  3. :umask=022:\
  4. :charset=UTF-8:\
  5. - :lang=en_US.UTF-8:
  6. + :lang=en_US.UTF-8:\
  7. + :setenv=LC_TIME=en_DK.UTF-8:
  1. cap_mkdb /etc/login.conf
/etc/profile
  1. LC_TIME=en_DK.UTF-8; export LC_TIME

BSDstats

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.

  1. echo 'bsdstats_enable="YES"' >> /etc/rc.conf

Conclusion

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!

A screenshot of my FreeBSD GNOME 2 desktop.

Updates

2012-06-06