Installing a FreeBSD 9.0 (i386) minimal desktop system


FreeBSD 9.0 RELEASE (i386)

Minimal desktop for web browsing, email, video, music playing…

Useful references :
Tested in a VirtualBox 4.1.8 virtual machine with
  • 512Mb RAM
  • 8.0Gb Hard disk

Installation using the new installer, bsdinstall

Just follow the steps.
  • Hostname : a full qualified domain name (eg. fb9.mydomain.net)
  • Enable all daemons at boot : sshd, moused, ntpd, powerd
  • Create a regular user, invite user into other groups : wheel (so that we can login as a regular user into SSH, then su to root)

Post-installation

First reboot, login as root (if using SSH, login as your regular user, then su)
Note : root uses the csh shell by default
Set package mirror (strongly recommended)
# echo >>/root/.cshrc "setenv PACKAGESITE ftp://ftp.fr.freebsd.org/pub/FreeBSD/ports/i386/packages-9.0-release/Latest/"
# setenv PACKAGESITE ftp://ftp.fr.freebsd.org/pub/FreeBSD/ports/i386/packages-9.0-release/Latest/
(Here I’m using a french ftp mirror, please adapt to your location for faster package downloads)
I prefer nano as text editor
# pkg_add -r nano
Improving a bit our root’s csh environment
# nano ~/.cshrc
alias h         history 25
alias j         jobs -l
# add the -G option to ls for colorization
alias la        ls -aG
alias lf        ls -FAG
alias ll        ls -lAG
# set a nicer prompt
alias setprompt 'set prompt="${cwd}# "'
alias cd        'chdir \!* && setprompt'
alias pushd     'pushd \!* && setprompt'
alias popd      'popd  \!* && setprompt'
# A righteous umask
umask 22
set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)
setenv  EDITOR  nano
setenv  PAGER   more
setenv  BLOCKSIZE       K
# adjust your FreeBSD mirror
setenv PACKAGESITE ftp://ftp.fr.freebsd.org/pub/FreeBSD/ports/i386/packages-9.0-release/Latest/
if ($?prompt) then
        # An interactive shell -- set some stuff up
        setprompt
        set filec
        set history = 100
        set savehist = 100
        set mail = (/var/mail/$USER)
        if ( $?tcsh ) then
                bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
        endif
endif

See here for more : http://www.faqs.org/faqs/unix-faq/faq/part2/section-4.html

Install and configure X

# pkg_add -r xorg
TODO : test with pkg_add -r xorg-minimal instead
# Xorg -configure
By default, on FreeBSD systems, the X11 configuration files are located in /usr/local/lib/X11/
# cp xorg.conf.new /usr/local/lib/X11/xorg.conf
# nano /usr/local/lib/X11/xorg.conf
Here is my xorg.conf, for using a 1280×1024 screen in VirtualBox, please adapt to your needs ( http://www.freebsd.org/doc/handbook/x-config.html )
Section "ServerLayout"
        Identifier     "X.org Configured"
        Screen      0  "Screen0" 0 0
        InputDevice    "Mouse0" "CorePointer"
        InputDevice    "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
        ModulePath   "/usr/local/lib/xorg/modules"
        FontPath     "/usr/local/lib/X11/fonts/misc/"
        FontPath     "/usr/local/lib/X11/fonts/TTF/"
        FontPath     "/usr/local/lib/X11/fonts/OTF"
        FontPath     "/usr/local/lib/X11/fonts/Type1/"
        FontPath     "/usr/local/lib/X11/fonts/100dpi/"
        FontPath     "/usr/local/lib/X11/fonts/75dpi/"
EndSection
Section "Module"
        Load  "dbe"
        Load  "dri"
        Load  "dri2"
        Load  "extmod"
        Load  "glx"
        Load  "record"
EndSection
Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "kbd"
EndSection
Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "mouse"
        Option      "Protocol" "auto"
        Option      "Device" "/dev/sysmouse"
        Option      "ZAxisMapping" "4 5 6 7"
EndSection
Section "Monitor"
        Identifier   "Monitor0"
        VendorName   "Monitor Vendor"
        ModelName    "Monitor Model"
        HorizSync    30-107
        VertRefresh  48-120
EndSection
Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
        #Option     "ShadowFB"                  # [<bool>]
        #Option     "DefaultRefresh"            # [<bool>]
        #Option     "ModeSetClearScreen"        # [<bool>]
        Identifier  "Card0"
        Driver      "vesa"
        VendorName  "InnoTek Systemberatung GmbH"
        BoardName   "VirtualBox Graphics Adapter"
        BusID       "PCI:0:2:0"
EndSection

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        DefaultDepth    24
        SubSection "Display"
                Viewport   0 0
                Depth     24
                Modes   "1280x1024" "1024x768" "800x600"
        EndSubSection
EndSection
Enable dbus and hal daemons for mouse/keyboard detection

# echo >>/etc/rc.conf ‘hald_enable=”YES”‘
# echo >>/etc/rc.conf ‘dbus_enable=”YES”‘
# /usr/local/etc/rc.d/dbus start && /usr/local/etc/rc.d/hald start

Setup your keyboard with HAL
(here for a french keymap, adapt XkbLayout to your needs)
# nano /usr/local/etc/hal/fdi/policy/x11-input.fdi
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
  <device>
    <match key="info.capabilities" contains="input.keyboard">
      <merge key="input.x11_options.XkbModel" type="string">pc105</merge>
      <merge key="input.x11_options.XkbLayout" type="string">fr</merge>
    </match>
  </device>
</deviceinfo>
Then test X
# startx
HINT : If you don’t want to mess with HAL stuff, you can set your keymap with the following command in an xterm :
# setxkbmap fr

Now we can install and test some nice minimal window managers

(There are plenty, just look in /usr/ports/x11-wm )

The wm2 window-manager : one of the simplest to use (uses no configuration at all!)

It’s extremely light, the major drawback I found is that windows decorations are always drawn, which is annoying on apps
that are supposed to be borderless (wbar, audacious, …)
# pkg_add -r wm2
You can read the small doc file
# more /usr/local/share/doc/wm2/README
Now let’s edit the system-wide xinitrc
# nano /usr/local/lib/X11/xinit/xinitrc
replace the line :
twm &
by :
wm2 &
Save and restart X!

Trying a simple tiling window-manager : dwm

# pkg_add -r dwm dmenu
Here too, it is highly suggested to have a look at the man page!
# man dwm
# nano /usr/local/lib/X11/xinit/xinitrc
replace wm2 &
by : dmw &
Maybe you will find dwm and wm2 too different/awkward to use…

Why not test pekwm? (very fluxbox-like)

# pkg_add -r pekwm
Then put “pekwm &” in your .xinitrc/.xsession
(the configuration files are in ~/.pekwm)
While we are at it, install menumaker, a menu generator since pekwm comes with a default menu configuration which likely does not reflect your installed apps.
# pkg_add -r menumaker
Run menumaker as a regular user
$ mmaker -v -f pekwm
(this will overwrite pekwm’s menu config file)
Reload pekwm configuration.

Automatically start X at boot

If you don’t want to use a session manager (xdm, gdm, etc…) and want autologin, this can be done this way :
# echo > rc.local su - <your regular user name> -c startx
(Xorg binary should have the suid bit set, this is normally the default)
# ls -al /usr/local/bin/Xorg
Then reboot to test.

Using Xdm

( http://www.freebsd.org/doc/handbook/x-xdm.html )

# pkg_add -r xdm
# nano /etc/ttys
replace “off” by “on” in the ttyv8 line
Then reboot.
Notes :
  • If using Xdm, xinitrc scripts are not used, you must customize your ~/.xsession, or the system-wide /usr/local/lib/X11/xdm/Xsession
  • By default, root is not allowed to login with Xdm

Installing more stuff

Web browsers

Firefox (warning, lots of gnome dependencies!)
# pkg_add -r firefox
then for HTML5 support

# kldload sem
# echo >>/etc/rc.conf ‘kld_list=”sem”‘

Chromium
# pkg_add -r chromium
Add the following line your xorg.conf, in the “Files” section :
        FontPath     "/usr/local/lib/X11/fonts/Droid/"
(Then restart X)
Then let’s test HTML5 videos on youtube, with both browsers
Go to http://www.youtube.com/html5, join the HTML5 trial and try an HTML5 video.
(Note : Chromium seemed to play videos better than Firefox on my setup)
You may also try Gnash (flash player replacement)
# pkg_add -r gnash
Seems to work quite nicely in youtube with Firefox!

Email client : Sylpheed

# pkg_add -r sylpheed

Notepad

# pkg_add -r leafpad

PDF document viewer : epdfview

# pkg_add -r epdfview

Audio player : Audacious

# pkg_add -r audacious audacious-plugins
Note : on my setup, sound worked without any configuration. If it’s not your case, see : http://www.freebsd.org/doc/handbook/sound-setup.html

Video player

# pkg_add -r mplayer

htop (system monitoring)

# pkg_add -r htop
# mkdir -p /compat/linux/proc
# echo >>/etc/fstab "linproc /compat/linux/proc linprocfs rw 0 0"
# mount linproc
# /usr/local/bin/htop

A little bit of embellishment!

A lightweight launch panel : wbar

# pkg_add -r wbar
Launch wbar in an xterm, as a regular user, so that the .wbar config file will be automatically created
$ cd && wbar
Then quit (ctrl-c)
Now let’s edit our .wbar config file
$ chmod +w .wbar && nano -w .wbar
Note : there is a gui tool for wbar configuration : wbar-config
Here’s my .wbar contents
i: /usr/local/share/pixmaps/wbar/osxbarback.png
c: wbar --bpress --above-desk --vbar --pos left --grow --noreload
t: /usr/local/lib/X11/fonts/bitstream-vera/Vera/10
i: /usr/local/share/pixmaps/firefox.png
c: /usr/local/bin/firefox
t: Firefox
i: /usr/local/share/chromium/product_logo_48.png
c: /usr/local/bin/chrome
t: Chromium
i: /usr/local/share/pixmaps/sylpheed.png
c: /usr/local/bin/sylpheed
t: Sylpheed
i: /usr/local/share/pixmaps/audacious.png
c: /usr/local/bin/audacious
t: Audacious
i: /usr/local/share/pixmaps/leafpad.png
c: /usr/local/bin/leafpad
t: Leafpad
i: /usr/local/share/pixmaps/leafpad.png
c: /usr/local/bin/epdfview
t: epdfview
i: /usr/local/share/pixmaps/wbar/terminal.png
c: xterm
t: Terminal
TODO : wbar has an unwanted window decoration, when using wm2. How to disable it?

GTK theme

You will notice that GTK apps have the stock, (ugly) “raleigh” theme. Let’s change that.
# pkg_add -r gtkchtheme
(there are several tools like this, you may try another one)
Find, install a fine individual gtk theme and change it
# find /usr/ports/ -name “gtk-*-theme”
# pkg_add -r gtk-milk-theme
# /usr/local/bin/gtk-chtheme
(If you want the full bunch of usual themes, install the gnome-themes package – warning, heavier gnome deps!)

Set a wallpaper

# pkg_add -r feh
Then download a nice wallpaper ( http://www.interfacelift.com )
(as a regular user)
$ feh --bg-center 
will generate a ~/.fehbg
add the line to your .xsession or xinitrc :
eval $(cat ~/.fehbg)
before the final “exec” line.

Conky, a system monitor for X

# pkg_add -r conky
as a regular user
$ cp /usr/local/share/examples/conky/conkyrc.sample ~/.conkyrc
$ chmod +w ~/.conkyrc
$ nano ~/.conkyrc
alignment top_right
background yes
double_buffer yes
border_width 1
own_window_type override
own_window_transparent yes
gap_x 0
gap_y 0
cpu_avg_samples 2
default_color grey
default_outline_color black
default_shade_color black
draw_borders no
draw_graph_borders yes
draw_outline no
draw_shades no
use_xft yes
xftfont DejaVu Sans Mono:size=12
minimum_size 5 5
net_avg_samples 2
no_buffers yes
out_to_console no
out_to_stderr no
extra_newline no
own_window yes
own_window_class Conky
stippled_borders 0
update_interval 1.0
uppercase no
use_spacer none
show_graph_scale no
show_graph_range no
TEXT
$nodename - $sysname $kernel on $machine
$hr
${color khaki}Uptime:$color $uptime
${color khaki}Frequency (in MHz):$color $freq
#${color khaki}Frequency (in GHz):$color $freq_g
${color khaki}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}
${color khaki}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}
${color khaki}CPU Usage:$color $cpu% ${cpubar 4}
${color khaki}Processes:$color $processes  ${color khaki}Running:$color $running_processes
$hr
${color khaki}File systems:
 / $color${fs_used /}/${fs_size /} ${fs_bar 6 /}
${color khaki}Networking:
Up:$color ${upspeed em0} ${color khaki} - Down:$color ${downspeed em0}
$hr
${color khaki}Name              PID   CPU%   MEM%
${color lavender} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color lavender} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color lavender} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color lavender} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
Finally, add “conky” (no need for “&” since it is automatically forked in the background in our conkyrc) to your .xsession, before the final “exec” line.

 

My ~/.xsession finally looks like this :
eval $(cat ~/.fehbg)
conky
# with pekwm, wbar is started in ~/.pekwm/start
#wbar &
exec pekwm

Mandatory screenshot

freebsd9 minimal desktop

Bootloader customization

# man loader.conf
# nano /boot/loader.conf
# set autoboot delay to 2 secs, disable boot menu and set a splash screen
autoboot_delay=2
beastie_disable="YES"
vesa_load="YES"
bitmap_load="YES"
bitmap_name="/boot/splash.bmp"
splash_bmp_load="YES"
You have to create a splash.bmp (256 colors max) bitmap image (the vesa mode will adapt to your image resolution).

FreeBSD Tips

View boot messages (dmesg)
# more /var/run/dmesg.boot
Show loaded kernel modules
# kldstat
Add user “joe” to the “wheel” group (so he can su to root)
# pw groupmod wheel -m joe
Show installed packages
# pkg_info
Delete a package (any version)
# pkg_delete packagename\*
Search for a package name (in the ports tree)
# find /usr/ports -name "packagename"
or
# echo /usr/ports/*/*packagename*
Update system
# freebsd-update
Update Ports tree
# portsnap fetch && portsnap extract && portsnap update

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s