How To Install FreeBSD on VirtualBox with KDE, GNOME, XFCE [2021]

How To Install FreeBSD on VirtualBox with KDE, GNOME, XFCE [2021]

In this guide, we are going to install FreeBSD on VirtualBox. You will also be able to install KDE, GNOME, or XFCE desktop environments at your choice by following a step-by-step guide [with pictures]. 

Let’s get to work.

Step 1: Download and Install VirtualBox. 

Head over to the VirtualBox Download page and click to download the VirtualBox package for your operating System.

VirtualBox Download Page

Once the download is completed, install VirtualBox and launch the application.

Step 2: Download FreeBSD image

In this guide, we will be using the RELEASE branch. At the time of writing this guide, the latest stable release is FREEBSD 12.2-RELEASE. The same installation procedure works for any new releases in case you read this guide in the future. 

Head over to The Free BSD Download page. Under the release section, click on the amd64

Install FreeBSD on VirtualBox Select Architecture leonardcucos.com
Download FreeBSD Install Image (Architecture).

Next, click on FreeBSD-12.2-RELEASE-amd64-dvd1.iso to start downloading the installation .iso.

install freebsd on virtualbox - download freebsd
Download FreeBSD RELEASE image

The download might take a while, depending on your Internet speed. 

In the meantime, continue with the next step.

Step 3: Setup VirtualBox

First, we will need to create a new virtual machine. On VirtualBox, click on New

install freebsd on virtualbox - create new
Create New Virtual Machine.

Give a name to your new virtual machine. I will call mine FreeBSD. Click Next

install freebsd on virtualbox - name
Create FreeBSD virtual machine.

Next, allocate the amount of RAM for this virtual machine. 

If you plan not to install any graphical desktop environment, the default 2 GB RAM is enough. However, if you want to install KDE, Gnome, or XFCE, I suggest you allocate a minimum of 4 GB RAM. Click Next

install freebsd on virtualbox- RAM
FreeBSD on VirtualBox memory size

On the Hard Disk window, leave the default settings and click Next.

install freebsd on virtualbox HDD size
FreeBSD on VirtualBox File location and size

On the Hard disk file type window, leave the defaults and click Next

install freebsd on virtualbox HDD file type
FreeBSD Hard disk file type

On the Storage on physical hard disk window, leave the defaults and click Next

FreeBSD on VirtualBox – Create Virtual HDD

On the File location and size window, increase the size to a more decent value – depending on what you plan to do with this virtual machine. 

I will give mine 15GB. 

Click Create to finish the virtual box setup process.

FreeBSD on VirtualBox – File location and size

Now, click on the Settings button on top of the VirtualBox window.

install freebsd on virtualbox settings
FreeBSD on VirtualBox Settings

Click on the System and select the Processor(s) tab. Allocate 2 CPUs for your FreeBSD virtual machine. 

Note that this step is not mandatory. However, if you want your FreeBSD virtual machine not to take forever to boot, I highly suggest you allocate at least 2 CPUs.

install freebsd on virtualbox CPU settings
FreeBSD on VirtualBox – System settings

Next, click on Display, and move the slider for Video Memory to the max. 

install freebsd on virtualbox settings graphics
VirtualBox – Display settings

Click on Storage, select Empty. Click on the little CD-like icon next to the Optical Drive and select Chose a disk file… 

Browse to the location where you downloaded the FreeBSD iso image, and select it. 

To start your virtual machine, click the Start button on the top of the VirtualBox window. 

install freebsd on virtualbox Start virtual machine.PNG
VirtualBox – Start VM

Step 4: Install FreeBSD

If everything goes well, you should be greeted with the FreeBSD installation Welcome screen. 

freebsd installer boot menu
FreeBSD on VirtualBox – Welcome

On the FreeBSD installer screen, select Install.

freebsd installer welcome
FreeBSD Installer

On the Keymap Selection, use the arrow keys to select your keyboard layout [Enter]. I am using a US keyboard, so that I will choose the United States of America keymap. Once you set your keymap, click on Continue with <your keymap> then [Enter].

install freebsd keymap selection
FreeBSD Installer – Keymap Selection

In the Set Hostname window, type your wanted hostname and choose OK [Enter].

install freebsd set hostname
FreeBSD – Set Hostname

Choose the optional system components to install in the Distribution Select window, such as 32-bit libraries, ports, system resource tree, System & kernel debugging, and test suite. Let’s select the 32-bit supportports, and source tree for this install.

install freebsd distribution select
FreeBSD on VirtualBox – Distribution Select

Disk Partitioning

In the Partitioning window, we have four options: 

  • Auto (UFS) – Guided Disk Setup will automatically format your disk using the Unix File System.
  • Manual – Manual Disk Setup (experts) will allow you to partition your disk manually using a GUI interface. This option assumes that you already know what you’re doing.
  • Shell – Open a shell and partition by hand. Again, this implies you are a noob at manual partitioning, and you know what you are doing.
  • Auto (ZFS) – Guided Root-on-ZFS if you want to use pooled Storage via multiple discs. You can read more about the Z File System (ZFS) in this excellent post.
install freebsd disk partitioning
FreeBSD – Partition

Let’s keep things exciting and select the last option: Auto (ZFS) – Guided Root-on-ZFS [Enter].

install freebsd partitioning ZFS
FreeBSD – Partitioning

On the ZFS Configuration window, you can increase the Swap Size and enable Disk Encryption if you need it. I will proceed with the defaults. Select >>> Install [Enter].

install bsd zfs configuration
FreeBSD – ZFS Configuration

You can configure mirroring or RAID on the ZFS Configuration (Virtual Device type) window if you use multiple disks. We use only one disk; therefore, we will select Stripe – No Redundancy for this install. Select OK [Enter] to continue.

install freebsd partitioning ZFS
FreeBSD on VirtualBox – Partitioning

Select the disk you want to install FreeBSD. Most likely, you will have only one disk option here. Choose it and click OK [Enter]

install freebsd ZFS Configuration
FreeBSD – ZFS Configuration

You will be warned that this is the Last Chance to review your settings before proceeding with disk partitioning. Since this is a brand new virtual machine, we don’t have to be afraid of losing our disk data. Go ahead and choose YES [Enter].

install freebsd
FreeBSD – Archive Extraction

The FreeBSD installer will proceed with disk partitioning and system installation.

Setting The ROOT Password

You will be prompted to type a password for the system management account (root). Please choose a password and retype it to confirm.

freebsd root password
FreeBSD – Create root account

Network Configuration

On the Network Configuration window, select which network your interface wants to use. Most likely, you will have your virtual network adaptor listed here. Select Yes [Enter] when asked to configure the IPv4  interface.

install freebsd ipv4 setup
FreeBSD on VirtualBox – Network Configuration

Select Yes [Enter] to configure the DHCP settings for your interface.

install freebsd DHCP
FreeBSD – Network Configuration

If you don’t plan to use the IPv6 interface, No [Enter].

The FreeBSD Resolver Configuration will automatically set up the network interface with the appropriate IPv4/DNS settings. Click OK [Enter]

On the Time Zone Selector, choose your regioncountry, and city. Click OK [Enter].

install freebsd Timezone Selection
FreeBSD on VirtualBox – Time Zone Selector

Skip [Enter] the Time & Date configuration as we will set up this later.

System Configuration

On the System Configuration, choose which services you prefer to start at boot or leave the defaults – you can change this later. Click OK [Enter].

install freebsd system configuration
FreeBSD – System Configuration

In the System Hardening window, you can select additional security options to reduce any system vulnerabilities. This is a virtual machine, so I will harden might system lightly but feel free to choose all hardening settings if you plan to use this VM for more than testing. Click OK [Enter].

install freebsd system hardening
FreeBSD – System Hardening

Add User Accounts

Next, we are asked to add a new user to our System. 

Select Yes [Enter] when prompted.

Here, we only need to fill a few fields – marked with bold text below. For the rest, you can leave the defaults by just pushing the [Enter] key.

Username: <your username

Full name: <your full name>

UID (Leave empty for default): [Enter]

Login group: [Enter]

Login group is <xyz>. Invite <xyz> into other groups? [ y]: wheel

Login class [default]: [Enter]

Shell (sh csh tcsh nologin) [sh]: [Enter]

Home directory [/home/<xyz>]: [Enter]

Home directory permissions: [Enter]

Yous password-based authentication? [Yes]: [Enter]

Use and empty password? [no]: [Enter]

Use a random password? [no]: [Enter]

Enter password: <enter your user password>

Enter password again: <confirm your password>

Lockout the account after creation? [no]: [Enter]

[…]

OK? (yes/no): Yes

Add another user? (yes/no): No

install freebsd new user creation done

FreeBSD – Create new user

Final Configuration

On the Final Confirmation window review your settings and select OK [Enter] to complete the installation. 

install freebsd apply
FreeBSD – Final Configuration

Chose No [Enter] in the Manual Configuration window when prompted to do additional changes via shell. 

Your FreeBSD installation in VirtualBox is now completed. Click Reboot when prompted and remove the FreeBSD disk from the virtual machine. 

install freebsd on virutalbox - Remove disk
FreeBSD on VirtualBox – Remove Optical Drive

Your VirtualBox FreeBSD installation is now completed. 

FreeBSD on Parallels Welcome
FreeBSD Boot Multi user [Enter]

Once you rebooted your FreeBSD VM, you will be greeted with a command prompt login and no graphical interface. This is perfectly normal in FreeBSD.

Login using your root account and password you set up during the installation.

FreeBSD Login prompt
FreeBSD login

Step 5: Update FreeBSD

The first thing we need to do is to update the freshly installed FreeBSD system.

First, let’s inspect the FreeBSD system and fetch the necessary updates by using the following command:

freebsd-update fetch

A list with files to be updated will be shown in the terminal. Press the [Enter] key until you reach the list’s bottom and press the q key to quit the list.

freebsd system update
FreeBSD update fetch

To update the FreeBSD system, use the following command:

freebsd-update install

Once the above commands are executed, the FreeBSD is up-to-date.

Step 6: Install A Desktop Environment in FreeBSD

However, unless you want to play with the command prompt only, I suggest installing a desktop environment such as KDE, GNOME, or XFCE and explore FreeBSD’s full potential.

I covered the FreeBSD desktop environment in detail in the following guides. If you decided which desktop environment you want to use on your FreeBSD virtual machine, follow the installation guides for FreeBSD with KDE, GNOME, or XFCE bellow:

If you have any questions or suggestions on improving this article, drop me a comment below. I hope you will enjoy your newly installed FreeBSD system as much as I do. 🙂

Stay safe!

Leonard

Call me Leo. I'm a technology addict and passionate engineer. If you can't find what you're looking for, drop me a message, and you'll have your step-by-step guide here in no time - I promise!

Leave a Reply