Installing FreeBSD 9.1 in Virtual Box, and setting up a graphical desktop

Hello guys, it’s been a while since I last posted up a tutorial so here we go. I hope you have a downloaded FreeBSD 9.1 Release ISO and Virtual Box up and running. If you haven’t installed Virtual Box yet, do install it now, and install ALL components (networking, USB support, etc).

Create a new Virtual Machine in Virtual Box. I recommend 10 GB of a FIXED storage volume and 512 MB RAM.

1

Before we start, open the settings for this machine, and check Enable IO APIC option. Basically, what we need to enable is HPEC (high precision event timers). Without those, FreeBSD would not boot. Enabling this option will enable HPEC.

2

Start the machine. You will be asked to locate the drive to boot from

3

Locate the FreeBSD ISO.

4

Boot (make sure ACPI is enabled, other wise enable it using the ‘4’ or ‘A’ key.

5

When the kernel has booted, start the “Install”.

6

The steps are self explanatory. In the following, select ALL distributions. You will need src (the system source code) because in FreeBSD 9.1, there are no packages unfortunately. All has to be pulled off the online repository or compiled from source

7

In the partitioning, use GUIDED mode because it will create all three standard FreeBSD partitions on its own.

8

If you choose to do it manually though, remember the freebsd-boot partition should be no larger than 512 KB. freebsd-swap should be the size of the RAM, and devote the rest to the freebsd-ufs (with / as the mount point). The boot partition must be the first one.

9

After that, commit to the installation. You don’t have to worry about the warnings since this is a virtual machine.

10

After the install, do not configure the em0 interface at this point. Do not add users at this point either. A lot of work has to be done as root. You can add users later. Just Exit the installer and reboot.

11

If the machine reboots into the ISO image again, you will need to power off this machine after reboot. Use Machine > ACPI Shutdown. Then go to machine settings and in the storage tab, select the FreeBSD ISO. Remove it from the virtual drive as shown in the pic.

12

And then start the machine.

Log in as root and the password you set during install. The first thing you should do is to connect to the internet via NAT (Network Address Translator) of Virtual Box. NAT configures itself automatically. Make sure the host OS is online. Then issue this command:

# dhclient em0

Then since Google is always on,

# ping google.com

I deliberately used this syntax because most users don’t know how to exit from the ping command. Well, here you go, press CTRL + C to exit from ping when it has transmitted/received a few packets. CTRL + C will exit most commands.

Let’s move on and install X11.

# cd /usr/ports/x11/xorg
# make install clean

You are compiling from source. It may take a while. The dependencies will be downloaded from the internet also.

Alternatively you can run

# pkg_add -r xorg

To download precompiled packages directly and install them instead.

Once it is installed, I’d recommend you install nano text editor because we will need to edit a lot of files. The default editor, vi, is more fun to use but a bit complicated.

# pkg_add -r nano

Let’s move on to configure X11.

You need to edit /etc/rc.conf and place the following lines at the end:

hald_enable="YES"
dbus_enable="YES"

This is because Xorg uses HAL to autodetect mice and keyboards. That’s it, fire up X.

# startx

You will see TWM, the default X11 window manager. Then run this command to create a skeleton configuration file in /root

# Xorg -configure

Now test if Xorg is working on your hardware.

# Xorg -config xorg.conf.new -retro

If a black and grey grid and an X mouse cursor appear, the configuration was successful. To exit the test, switch to the virtual console used to start it by pressing Ctrl+Alt+Fn (F1 for the first virtual console) and press Ctrl+C.

Install the URW font collection (the default fonts shipped with X11 are less than ideal).

# cd /usr/ports/x11-fonts/urwfonts
# make install clean

Now make the X server detect these fonts. The following commands should be run in a shell in an X session:

% xset fp+ /usr/local/lib/X11/fonts/URW
% xset fp rehash

Last thing for today, install GNOME:

# pkg_add -r gnome2

or

# cd /usr/ports/x11/gnome2
# make install clean

Once that is done, add the following lines to /etc/rc.conf to make GDM start automatically at boot:

gdm_enable="YES"
gnome_enable="YES"

That’s it. Reboot and you will be greeted with a graphical login screen. Enjoy your FreeBSD experience!

Advertisements

7 responses to “Installing FreeBSD 9.1 in Virtual Box, and setting up a graphical desktop

  1. Very useful blog post. I spent ages looking for how to get my Xwindows running on FreeBSD in virtualbox under mac OS X. Thanks to your very straightforward walkthrough it’s now working.

  2. When I switch to full screen, I still have the same desktop screen size wrapped in a full screened widow. I read somewhere that it is because of guest additions not being installed properly and I actually get errors complaining so, any clues?

    • Hello!

      In general, whenever you switch to full screen in a VB window, you have to configure the screen resolution of the guest OS separately. I don’t have VB up at my system right now or I would have experimented on that myself. I say you need some tweaking with some X.org’s configuration files.

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