How to Install FreeBSD: A Linux Alternative
advanced operating systems bsd unix cli installation freebsd howto linux alternative open source os operating systems unix like systemsWhile the world often looks towards Linux, those seeking a truly unified and battle-tested environment know that FreeBSD is in a league of its own. It isn't just a kernel; it is a complete, cohesive operating system that has powered the internet's most critical infrastructure for decades, offering a level of architectural elegance that every power user should experience.
Hi all, and welcome to MusaBase! In this guide, I will walk you through the installation of FreeBSD. If you are looking for a secure, rock-solid, and high-performance operating system that differs from the Linux kernel found in Arch Linux, then FreeBSD is an excellent choice.
While distributions like Gentoo offer high customization, FreeBSD provides a unified system where the kernel and base utilities are developed together. However, if your primary focus is extreme security and proactive cryptography, you might also want to check out my OpenBSD Installation Guide.
Whether you are a first-timer or an experienced power user, this step-by-step walkthrough will cover:
- Downloading the latest official FreeBSD installation ISO
- Creating a reliable bootable USB drive
- Navigating the FreeBSD (bsdinstall) menu-guided installer
- Custom disk partitioning for an optimized setup
- Installing the base FreeBSD system and essential components
- Configuring networking and setting up a user with doas or sudo privileges
By the end of this walkthrough, you will have a fully functional and secure FreeBSD system running on your hardware. Without further ado, let’s dive into the world of BSD!
What is FreeBSD?
FreeBSD is a free and open-soruce Unix-like operating system knwon for its security, performance and advanced networking feautres. FreeBSD is derived from the Berkeley Software Distribution (BSD), which itself is based on Research Unix.
What makes FreeBSD different from Linux?
Both FreeBSD and Linux are open-source operating system, but they are completely different in terms of how they are built and uses. Linux, with its huge list of distributions, is known for its compatibility with broad hardware support. FreeBSD, rooted in the original BSD UNIX, flexes stability, security, and a unified system.
Prerequisites
Before we begin, refer to the official FreeBSD Hardware Notes for compatibility details. This tutorial follows the Official FreeBSD Handbook for installation and configuration; make sure to double-check the commands if you encounter any issues. Below are the recommended system specifications for a fully-fledged FreeBSD system with a desktop or development environment on a modern release (FreeBSD 14.x):
System Specifications:
- Processor: Any AMD64 (x86-64 bit), ARM64 (AArch64), or i386 (32-bit) processor is supported.
- RAM: 8 GB+ is recommended for multitasking, server workloads, and compiling.
- Disk Space: 30 GB+ of available storage.
Step 1: Download FreeBSD ISO & Create Bootable USB
1.1: Download the FreeBSD Installer
- Go to freebsd.org/where.
- Select the ISO image that matches your CPU architecture (e.g., amd64 (for modern Intel or AMD processors) or i386 (for older 32-bit processors)).
- After downloading, you should see a file named similarly to FreeBSD-14.3-RELEASE-amd64-disc1.iso:
1.2: Create a Bootable USB Drive
1.2.1: Using Balena Etcher (GUI) on Windows/Mac/Linux
- Download Balena Etcher and install it.
- Run Etcher.
- Select your freebsd.iso file.
- Choose your USB drive in Etcher.
- Click Flash!. After flashing completes, your USB will be ready to boot FreeBSD.
1.2.2: Using dd (CLI) on Linux
Note: Be careful while using dd and selecting your USB drive, as dd will overwrite it.
- Plug your USB drive into your PC.
- Open a terminal and run the following command to identify your USB:
lsblk
- Look for your USB (e.g., /dev/sdb or /dev/nvme0n1). Note the name for your USB drive.
- Unmount the USB (if mounted) by running this command:
sudo umount /dev/sdX
Note: Replace X with your USB device (e.g., sdb1).
- Next, write the ISO to the USB by running this command:
sudo dd if=/mnt/sdc1/Downloads/freeBSD.iso of=/dev/sda bs=4M status=progress oflag=sync
Note: Replace /mnt/sdc1/Downloads/freeBSD.iso and /dev/sda with the actual path where the freeBSD.iso is located and your USB device.
- if=: Input file (ISO path).
- of=: Output device (USB, e.g., /dev/sdb).
- bs=4M: Block size for faster writing.
- status=progress: Shows progress.
- oflag=sync: Ensures data is written properly.
- After dd finishes writing the ISO to the USB, eject your USB by running this command:
sudo eject /dev/sdX
⚠️ Warning: Using dd incorrectly can overwrite your hard disk. Double-check if= and of= before executing.
Step 2: Boot into FreeBSD Installation Environment
- Reboot your PC.
- While your PC is turning on, press the F9, F10, F11, F12, DEL, or ESC key to open the UEFI/BIOS settings.
- Locate and disable the Secure Boot & Fast Boot options (usually under the Security or Advanced Settings tab).
- Save & Exit.
- Next, again press F9, DEL, or ESC key to boot from your USB stick.
- If everything goes right, you will be greeted by the FreeBSD installer menu.
- Press 1 to enter FreeBSD installation.
After a few seconds, you will be inside the FreeBSD live installation environment.
- Press ENTER to proceed with the settings for installing FreeBSD.
2.1: Navigate the FreeBSD Installation Environment
Since it's a text-based interface, we can't use a mouse to click through the presented options. But navigating this interface with a keyboard isn't difficult at all; just follow my lead and you will see how easy it is.
- Use your keyboard's UP () and DOWN () arrow keys to navigate upward or downward.
- Press SPACEBAR to select an option.
- Press ENTER to continue to the next prompt.
- Press TAB to navigate between decision options (e.g., Continue, Cancel, Select, etc.).
Step 3: Configuring Keymap & Hostname
In this step, we will set the basic settings for our system, such as configuring the keyboard layout and setting up our hostname.
3.1: Configure Keymap
The very first configuration in the FreeBSD live environment is setting our Keymap. A keymap defines how our keyboard's physical keys are interpreted by the operating system.
- The default keymap is "US". If you are comfortable with the default, press Enter to continue.
- If you want a different keymap, navigate the list, select it with SPACE, then press Enter to continue.
3.2: Set Hostname
A hostname is simply a label or name assigned to devices connected to a network, allowing other users to easily identify and communicate with your device.
- Type any hostname you want to label your system (e.g., MusaBase) and press ENTER.
Step 4: Select FreeBSD System Components
This step is optional and involves choosing additional components for our system. However, for most cases, we only need one system component named lib32. This component is needed for running older or legacy (32-bit) applications on a 64-bit system.
- Select or deselect components by navigating to them and pressing SPACE, then press ENTER to continue.
- For this guide, I am going only with lib32.
What are these components needed for?
base-dbg or Base system (Debugging)
Installs the core userland utilities, such as ls, vi, cat, with embedded debug symbols, making it easier to diagnose crashes in these tools.
kernel-dbg or Kernel (Debugging)
Installs the FreeBSD kernel and modules compiled with debug symbols. This might become handy if you're developing, debugging, or analyzing kernel modules or the kernel itself.
lib32-dbg or 32-bit compatibility libraries (Debugging)
Same as lib32, but with debugging symbols included.
lib32 or 32-bit compatibility libraries
Provides the 32-bit FreeBSD libraries required to run native 32-bit FreeBSD applications on a 64-bit system. Note: this is for native 32-bit FreeBSD binaries. It does not let us run Windows programs natively. To run Windows applications, we need Wine, a compatibility layer.
ports or Ports tree
Installs the entire FreeBSD Ports Collection. This is the framework we use to compile third-party software from source. It gives us full control over build and compile-time options (similar to Gentoo Linux's Portage system).
src or System source tree
Downloads the complete FreeBSD source code, the kernel and base system. This is needed for building custom kernels, modifying FreeBSD source, or compiling the system from source. (Somewhat like Gentoo Linux, but more structured).
tests or Test suite
Includes automated system test suites. Install if you are a developer or need to verify system stability or test specific components.
Step 5: Configure Network
- The next step is configuring networking.
- Choose your network controller if more than one is showing and press ENTER.
- I have only one network controller showing for my setup; this could be different for you.
- Next, the installer will ask whether to configure IPv4, IPv6, and use DHCP.
- You can skip these options by choosing [ No ].
- Or choose [ Yes ] to configure them.
- I chose [ Yes ] for IPv4, IPv6, and DHCP, so these are the settings showing for my configuration:
Step 6: Disk Partitioning
FreeBSD provides four options for partitioning our hard disk for a FreeBSD system.
- Auto (ZFS) Guided Root-on-ZFS
- Auto (UFS) Guided UFS Disk Setup
- Manual Manual Disk Setup (experts)
- Shell Open a shell and partition by hand
6.1: Partition with Auto (ZFS)
ZFS is a modern, enterprise-grade filesystem that combines volume management and data-integrity features like pooled storage, snapshots, and data compression in one package.
- Data Integrity: Auto-detects data corruption and repairs it if redundancy is present.
- Pooled Storage: Disks are grouped into a zpool, with datasets for each filesystem, meaning it can resize dynamically.
- Snapshots: Create instant, space-efficient snapshots and roll back when needed.
- Data Compression: Deduplication, caching (ARC, L2ARC), copy-on-write, and RAID-Z are supported.
- Trade-Offs:
- Higher memory usage if you have a low-RAM system.
- Disk layouts typically use the entire disk, though datasets are flexible.
The FreeBSD installer handles ZFS setup automatically. If you are okay with the default configurations, then hit ENTER on Proceed with Installation to continue.
6.1.1: Configure ZFS Pool Type
When we select Auto (ZFS) and reach the Pool Type menu, we're selecting the type of ZFS vdev layout to use. A vdev is a virtual device (a group of disks), and a zpool is made up of one or more vdevs. These vdevs or ZFS virtual devices are:
Pool Types
1. stripe (RAID-0 equivalent)
- No redundancy: Data is striped across all disks.
- Maximum performance and capacity, but a single disk failure will result in damaging or even destroying the entire pool.
- Use only for non-critical data or temporary scratch space.
- Can work with a single hard disk.
2. mirror (RAID-1 equivalent)
- Two or more disks hold identical copies of all data.
- If data loss happens on one disk, the other can still operate.
- Reading data can be faster, but if one disk has a slow writing speed, it will limit the speed for all other disks in the mirror.
- Requires at least two disks.
3. raid10
- This pool type uses mirrors and stripes data across multiple mirrored pairs.
- Provides high performance and good redundancy.
- Can survive one disk failure in each mirror pair, depending on which disks fail.
- Requires an even number of disks (e.g., 2, 4, 6, etc.).
4. raidz1
- Single parity is distributed across all disks in the vdev.
- Can survive one disk failure, but a second failure leads to data loss.
- Balances capacity and protection but is slower than the mirror pool type.
- Requires a minimum of three disks.
5. raidz2
- This pool type uses dual parity, allowing two disks to fail without data loss.
- It's a better option for larger pool setups but offers slower performance and higher overhead due to extra parity.
- Requires a minimum of four disks.
6. raidz3
- Triple parity, as the name suggests, can survive three simultaneous disk failures before data loss occurs.
- Highest redundancy but also the highest overhead and slowest among the ZFS parity options.
- Requires a minimum of five disks.
So Which One Should You Choose?
- If you need speed and efficiency, then mirror or striped mirrors are well suited.
- If you want maximum data protection, then raidz2 is a better option.
- For reliability where disk failures are critical, go for raidz3.
- Stripe is the fastest and most capacity-efficient, but the trade-off is that it has no protection whatsoever.
For more information on parity bits and RAID, please visit DiskInternals.
- Let's say we choose the Stripe Type with two disks.
- Now, it's going to create a storage pool with 2 hard disks.
- After configuring your pool type, choose Proceed with installation and press ENTER, and it will take you to the next step of the FreeBSD installation.
6.2: Partition with Auto (UFS)
The UFS is the traditional BSD filesystem, known for its simplicity and speed. This filesystem offers:
- Low overhead: Fast and efficient, ideal for systems with limited RAM or CPU.
- Simple Structure: Uses fixed partitions (e.g., root, swap), making it easy to manage and dual-boot with other OSes.
- Supports journaling for improved crash consistency after system crashes.
- Trade-Offs:
- No built-in checksums: Data corruption is possible unless backed by RAID or external integrity measures.
- No Rolling back: No snapshots, compression, or built-in encryption.
6.2.1: Partition Disk with UFS
- Choose Auto (UFS) and press ENTER.
- If your PC has multiple hard disks connected, select the disk where FreeBSD should be installed.
- Next, it will ask if you want to use the Entire Disk or Partitions:
- Choosing Entire Disk will erase all data on the selected disk.
- If you need a custom layout or are planning a dual-boot setup, choose the Manual Partition method for more control.
- Select GPT as the Partition Scheme (for UEFI systems). For BIOS/Legacy PCs, choose MBR.
- Review the layout, and here you can also adjust partition sizes. Choose [ Finish ] and press ENTER.
- On the next prompt, confirm to apply the changes and write them to disk. Choose [ Commit ] and press ENTER.
- The installer will write changes to disk and proceed to the next installation step.
6.3: Manual Partition
With manual partitioning, we have full control over how each partition is created, including how much space we want to allocate to each partition.
- Choose Manual and press ENTER.
- Next, select the disk for partitioning and choose [ Create ], then press ENTER. In this tutorial, I selected ada1 40GB.
- Choose GPT for the Partition Scheme and press ENTER.
- A message should prompt that states: Partition Table has been assigned to selected disk, please press on Create again.
6.3.1: Creating Boot Partition
- Choose [ Create ] again and press ENTER.
- Press the TAB key to navigate to the input fields.
- Fill in the following fields like this:
Type: freebsd-boot
Size: 512K
Mountpoint:
Label: Boot
6.3.2: Creating Swap Partition
- Select the disk and choose [ Create ], then press ENTER.
- Press the TAB key to navigate to the input fields.
- Fill in the fields like this:
Type: freebsd-swap
Size: 8GB
Mountpoint:
Label: swap
6.3.3: Creating Root Partition
- Select the disk again, choose [ Create ], then press ENTER.
- Press TAB to navigate to the input fields.
- Fill in the following fields like this:
Type: freebsd-ufs
Size: 19GB
Mountpoint: /
Label: root
- We can also add other partitions (e.g., /var, /tmp, /usr, etc.).
- Like this:
# for /var partition
Type: freebsd-ufs
Size: 2GB
Mountpoint: /var
Label:
# for /usr partition
Type: freebsd-ufs
Size: 2GB
Mountpoint: /usr
Label:
# for /tmp partition
Type: freebsd-ufs
Size: 6GB
Mountpoint: /tmp
Label:
- After creating all partitions, review the layout and choose [ Finish ], then press ENTER.
- The installer will ask for confirmation to write the changes to disk and create the partitions. Choose [ Commit ] and press ENTER, and it will start creating partitions and take you to the next step.
6.4: Partition with Shell
Disk partitioning with the FreeBSD Shell environment gives us full control over partitioning. We can precisely define the disk layout using commands like gpart, newfs, etc. It is ideal if you are creating a non-standard setup, mixed filesystems, encryption, custom alignment, or manual ZFS on a subvolume.
6.4.1: Partition with Shell
- Choose Shell and press ENTER. You will be in a CLI environment.
6.4.2: List All Connected Storage Devices
- First, identify the disk on which you want to create partitions.
- Run the following commands:
# for HDDs or list block devices (names)
sysctl kern.disks
# for SCSI/NVMe/USB devices and detailed list
camcontrol devlist
- For more information about storage drives, we can use the geom command:
geom disk list
6.4.3: Create Boot Partition
- First, we need to initialize our disk with the GPT partition scheme.
- Next, we will create the boot partition.
- Then, we will write the bootloader for MBR and GPT.
- Run the following commands:
gpart create -s gpt ada1
gpart add -t freebsd-boot -s 512K -a 1M ada1
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1
6.4.4: Create Swap Partition
- Run the following command:
gpart add -t freebsd-swap -s 8G -a 1M ada1
6.4.5: Creating Additional Partitions (/var, /tmp, /usr)
- To create /var, /tmp, and /usr partitions, run the following commands:
# for /var partition
gpart add -t freebsd-ufs -s 2G -a 1M ada1
# for /tmp partition
gpart add -t freebsd-ufs -s 2G -a 1M ada1
# for /usr partition
gpart add -t freebsd-ufs -s 10G -a 1M ada1
6.4.6: Create Root Partition
- For the root partition, I'm allocating the remaining space to it. If you plan on creating additional partitions, please do so as explained in step 6.4.5.
- To create the root partition, run:
gpart add -t freebsd-ufs -a 1M ada1
6.4.7: Format & Mount Partitions
For the boot partition, we don't have to mount it anywhere; FreeBSD manages it automatically. However, we need to format and mount the root partition, and for the swap partition, we just have to turn it on.
List Hard Disk with Its Partitions
- It's a good idea to list our hard disk with all its partitions. This way, we can easily format and mount each partition without accidentally formatting the wrong partition.
- Run:
gpart show ada1
Turn on Swap Partition
- Run the following command:
swapon /dev/ada1p2
Format & Mount Root Partition
- To format and mount the root partition, run:
newfs -U /dev/ada1p3
mkdir /mnt
mount /dev/ada1p3 /mnt
Format & Mount Additional Partitions (/var, /tmp, /usr)
- The additional partitions will be formatted and mounted in the same fashion as the root partition.
- Do the following:
# for /var partition
newfs -U /dev/ada1p4 # replace ada1 with your hard disk and p4 partition number
mkdir /mnt/var
mount /dev/ada1p4 /mnt/var
# for /tmp partition
newfs -U /dev/ada1p5 # replace ada1 with your hard disk and p5 partition number
mkdir /mnt/tmp
mount /dev/ada1p5 /mnt/tmp
# for /usr partition
newfs -U /dev/ada1p6 # replace ada1 with your hard disk and p6 partition number
mkdir /mnt/usr
mount /dev/ada1p6 /mnt/usr
Exit the Shell Environment
- After creating, formatting, and mounting each partition, exit the FreeBSD Shell environment.
- Run:
exit
- When we exit the shell environment, the installer will detect the layout and proceed with the installation from the mounted root.
Step 7: FreeBSD Base System Installation
After creating the partitions, the installer will take you to the mirror selection screen.
7.1: Select Mirror
- I'm going with the default selected mirror for my system, but I would highly recommend picking your closest mirror. It will help with faster downloads.
- Pick your mirror and press ENTER.
7.2: Installing FreeBSD Base System
- After fetching mirror information, the installer will automatically start downloading base system or distribution files, such as base, kernel, and files for additional components that we selected at the Additional Components step (e.g., lib32).
- After downloading the base system files, the installer will automatically start extracting them.
7.3: Set Root Password
- After downloading and extracting the base system files, the installer will prompt you to set a password for the root account.
- Enter and re-enter your password for root.
Step 8: FreeBSD Base System Configuration
Next, we have to configure our base installed system. This step contains:
- Set Timezone
- Add Boot Services
- Add System Security Hardening
- Add a User
8.1: Set Timezone
- Select your Region and press ENTER.
- Next, choose your Country and press ENTER.
- Next, confirm the abbreviation for your country by choosing [ Yes ] and press ENTER.
- Next, confirm that the date and time are set correctly. If not, adjust the date and time according to your local date and time.
8.2: Add Boot Services
- Next, FreeBSD's installer gives us the option to enable services that start at system boot.
- I'm going with the default selected services, but you can choose services by pressing SPACE and then pressing ENTER to continue to the next step.
Purpose of each Service?
1. local_unbound or Local Caching DNS Resolver
Check this option if you want local name resolution without depending on an external DNS server.
- Runs a lightweight recursive DNS resolver bound to 127.0.0.1 using the built-in Unbound in the FreeBSD base.
- This makes DNS lookups faster and validates DNSSEC.
2. sshd or Secure Shell Daemon
Check this service if you want remote access to your system.
- Enables remote secure shell logins (SSH), allowing encrypted remote access to your system.
3. moused or PS/2 Console Mouse Daemon
- This service enables mouse support on the text console, useful for BIOS/GRUB-like consoles or file managers in a non-GUI environment.
4. ntpd or Network Time Protocol Daemon
- Continuously synchronizes your system clock with internet time servers.
- This service is mostly for keeping time accurate for logs, certificates, cron jobs, etc.
5. ntpd_sync_on_start or Force Time Sync at Startup
- If this service is enabled, then ntpd will sync time immediately on boot, even if the time offset is large.
6. powerd or Power Management Daemon
- Adjusts CPU frequency dynamically to support power saving and thermal performance on laptops and desktops.
7. dumpdev or Kernel Crash Dump Support
- This service enables kernel crash dumps to be stored in /var/crash.
- Useful if you want logs or reports for your system crashes.
8.3: Add System Security Hardening
System hardening implements additional security layers and controls beyond the default system setup. Its role is to reduce attack vectors, protect data, and increase resistance against compromise. It's most important for servers, production systems, and internet-facing hosts.
- I'm choosing random_pid and clear_tmp for my system, but you can toggle other options as well according to your preferences and press ENTER to continue to the next step.
Purpose of each System Hardening
0. hide_uids or Hide Processes Running as other Users
- Check this hardening if your system is going to be used by multiple users.
- Prevents a regular user from seeing processes owned by different users via ps, top, etc.
1. hide_gids or Hide Processes Running as other Groups
- Same as hide_uids, but applies to group-based permissions.
2. hide_jail or Hide Processes Running in Jails
- Prevents visibility of jailed processes from the host.
3. read_msgbuf or Disable Reading Kernel Message Buffer for Unprivileged Users
- Enable this hardening if you have a multi-user system.
- Prevents users from reading kernel logs via dmesg. Only root can read logs.
4. proc_debug or Disable Process Debugging Facilities for Unprivileged Users
- Restricts access to debugging tools like ptrace() that can be used to snoop or manipulate processes.
5. random_pid or Randomize the PID of Newly Created Processes
- Makes it harder for attackers to guess the PID of sensitive processes.
6. clear_tmp or Clean the /tmp Filesystem on System Startup
- Wipes all contents of the /tmp directory every time the system boots.
- This prevents leftover temporary files from causing conflicts or leaking data.
7. disable_syslogd or Disable Opening Syslogd Network Socket
- This hardening is only useful for systems that do not need remote logging.
- Prevents syslogd from listening on the network.
8. secure_console or Enable Console Password Prompt
- Recommended for physical or remote server security.
- Requires a root password even for single-user mode.
9. disable_ddtrace or Disallow DTrace Destructive-mode
- Disables DTrace scripts that can modify system behavior.
8.4: Add a User
- Next, the installer will ask you if you want to add users.
- Choose [ Yes ] and press ENTER.
- Finally, we can add a user. Type your username and press ENTER.
- (Optional) Type your full name and press ENTER.
- For the third prompt labeled, Uid (Leave empty for default): press ENTER for default.
- Next, for the login group, type wheel and press ENTER. Adding your user to the wheel group is important; without it, the user won't be able to perform sudo tasks.
- On the next prompt for Inviting your user into other groups?, type video and operator and press ENTER.
- Next, leave the options for Login class and Shell (sh csh tcsh nologin) at default by pressing ENTER.
- Do the same for the next two options, Home directory [/home/username] and Home directory permission; leave these options at defaults by pressing ENTER.
8.4.1: User Password
- For the option Use password-based authentication? [ yes ], the default is yes, so press ENTER to set the user's password.
- Do the same for Use an empty password? (yes/no) [no]; the default option is no, so press ENTER.
- Again, repeat the same step as before for Use a random password? (yes/no) [no]; the default option is no, so press ENTER to set a password for your user.
- Next, enter and re-enter the password for your user.
- After setting the password for your user, the installer will ask for Lock out the account after creation? [no]; the default option is set to no, so press ENTER.
8.4.2: Confirm User Info
- After setting up your user with permissions and setting a password for your user, the installer will show detailed information about the user account.
- Confirm the settings by pressing ENTER if everything is right. If not, then type no and press ENTER to add the user again.
- After that, it will ask you if you want to add another user. You can add multiple users if you want; just don't forget to add them to the wheel, video, and operator groups if you want to give these users sudo privileges.
8.5: Confirm Configuration & Reboot
- Next, the installer will show you all your configured options for User, Root Password, Hostname, Services, etc.
- You can make changes here if you missed anything or couldn't configure any step correctly.
- Choose Exit and press ENTER.
- Next, the installer will ask if you want to open a shell and make any final manual modifications? Choose No and press ENTER.
- Finally, the installation is complete. Now choose [ Reboot ] and press ENTER on the last prompt.
- Your PC will reboot, and you should see the FreeBSD boot menu.
Step 9: Boot into Installed FreeBSD System
- If everything goes right, you should see the FreeBSD boot menu:
- Press 1 or ENTER to go into the installed FreeBSD system.
- After a few seconds, FreeBSD should prompt you for login with your username and password.
- Enter your username and password that you created during installation and press ENTER.
9.1: Resolve (mountroot>) Error
When you boot into your installed FreeBSD system after installation, you may get a mountroot> error. For now, this error may happen if you manually created partitions from FreeBSD's shell environment. This happens before the kernel reads /etc/fstab. It's the loader asking for the root device. To fix this, do the following:
9.1.1: Manually Mount the Root Partition & Login into your System
- At the mountroot> prompt, run:
ufs:/dev/ada0p3
- After the root filesystem is mounted, you will get to the login prompt.
- Enter your username and password that you created during installation.
- Next, we will make this process automatic by adding filesystem entries to fstab.
9.1.2: Auto Mount Filesystem
- If you don't add your partitions or filesystem entries to fstab, you have to do the above step at every boot.
- To make sure that the filesystem automatically mounts at every boot, do the following:
9.1.3: Change to Super User and Add Entries to Fstab
- Run the su command to change to the root user and enter your root password that you created during installation.
su
- Next, run the gpart command to verify and note the information about your partition numbers.
- Next, we'll add entries to fstab.
- Do the following:
cat > /etc/fstab << "EOF"
# Device Mountpoint FStype Options Dump Pass#
/dev/ada0p3 / ufs rw 1 1
/dev/ada0p2 none swap sw 0 0
EOF
- We can also read the content of fstab or other files with the cat command.
- Run the following command to make sure the entries have been added:
cat /etc/fstab
- Next, run:
reboot
- It will reboot the PC, and after boot, you should get straight to the login prompt.
Step 10: Configure Installed FreeBSD System
Now the FreeBSD system is installed, but it's a bare minimal system without essential tools. In this step, we will install necessary utilities and also enable doas or sudo for our user. But before we do anything, we need to change to the root user because at the moment the user doesn't have sudo privileges.
- To change to the root user, simply run:
su
- Enter your root password, which you created during installation, and press ENTER.
10.1: Switch Packages to Latest
FreeBSD offers two main package branches:
1. quarterly
2. latest
If you are looking for a stable FreeBSD system, then you don't have to do the switching. However, if you want up-to-date FreeBSD features or updated software, then you need to make the switch from the default quarterly branch to latest.
10.1.1: Update Packages
- First, we need to update our system packages.
- Run:
pkg update
- The system will tell you that The package management tool is not yet installed, do you want to install it now (y/N):.
- Type y and press ENTER, and the system will automatically download and install the package management tool and new updates if missing.
10.1.2: Switch Packages Branch
- Next, we need to create a directory for the package's repository and copy the default package config to the repo directory.
- After copying the package config, we need to modify it.
- Run the following commands consecutively:
mkdir -p /usr/local/etc/pkg/repos
cp /etc/pkg/FreeBSD.conf /usr/local/etc/pkg/repos/
- Next, we need to edit the FreeBSD.conf file in the repos directory.
- You can use vim to edit this file. I'm using ee.
- Run:
ee /usr/local/etc/pkg/repos/FreeBSD.conf
# OR
vi /usr/local/etc/pkg/repos/FreeBSD.conf
- The above command will open the FreeBSD.conf file.
- In the opened file, we simply replace the entry quarterly with latest and save & exit the file.
- Look for the line containing:
- url: "pkg+https://pkg.FreeBSD.org/${ABI}/quarterly",
- Replace quarterly with latest and save & exit the file.
- Next, we need to run the package update command so the FreeBSD system can re-configure packages for the latest branch.
- Run:
pkg update
10.2: Install Nano
Nano is a command-line text editor designed for Unix-like operating systems.
- In the next few steps, I am going to use nano for editing or creating conf files.
- It's more of a personal preference; you can use ee or vim if you prefer that.
- Run:
pkg install nano
10.3: Install and Configure DOAS
Doas is equivalent to sudo, but its installation and configuration is rather different.
10.3.1: Installation & Configuration of doas
Doas is a minimalist alternative to sudo ported to FreeBSD from OpenBSD. It is designed to provide essential privilege elevation with simpler configuration and a smaller codebase.
- To install doas, run:
pkg install doas
- After calculating package dependencies, the installer will ask to confirm the installation.
- Type y and press ENTER, and it will start installing the package.
- Next, we need to configure the doas.conf file so our user can perform tasks and run commands with elevated privileges.
- Do the following:
cd /usr/local/etc
nano doas.conf
- The above command should open the doas.conf file in nano.
- The file will contain data like permit, authorization, etc.
- Delete all lines in the file by pressing the DEL key.
- Next, we are going to add our custom permission for the user.
- Add the following line in the doas.conf file.
permit nopass keepenv :wheel
- Press CTRL + O to save the changes, then press ENTER to apply the changes, then press CTRL + X to exit the file.
- Next, switch back to the user to verify doas is working correctly.
- Run:
exit
10.4: Install and Configure SUDO
- Now, we will install sudo as our user.
- Run the following command as a user:
doas pkg install sudo
- After fetching sudo, the package installer will ask for confirmation of installation.
- Type y and press ENTER.
- Next, we need to configure the sudoers file.
- Basically, we need to open visudo and edit the line for the wheel group.
- Run the following commands:
export EDITOR=/usr/local/bin/nano
visudo
10.4.1: Edit sudoers
- In the sudoers file, navigate to the bottom with the keyboard's Down () key.
- Look for and delete the # from the beginning of the line which contains:
# %wheel ALL=(ALL:ALL) ALL
- Press CTRL + O to save the changes, then press ENTER to apply the changes, then press CTRL + X to exit the file.
- Now, you can use both doas and sudo for your user to perform tasks as root.
10.5: Installing Neofetch
- Next, we will install neofetch with sudo.
- Run:
sudo pkg install neofetch
- Run neofetch:
neofetch
🎉 Congratulations! Your FreeBSD system is now up and running!
You have successfully installed and configured the base FreeBSD system. If you are coming from a Linux background, you might want to install familiar shells like bash and bash-completion to make yourself feel at home. Now, it is time to transform this powerful base into a complete workstation.
If this guide helped you conquer the Power to Serve, subscribe to our newsletter for more BSD and Linux tutorials.
101 out, I’ll see you in the next one! 🚀

![FreeBSD Installer Boot Menu The initial FreeBSD boot menu showing options: 'Boot Multi user [Enter]', 'Boot Single user', 'Escape to loader prompt', and 'Reboot'.](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi06buAvGtDjzQq-6kSINHiygyyfR94OyVVtXpKN9I0ZTTYB1BDubFzHobGl6QpPbPw3jAIDUmeJJBmAnLpWxweJ23kLLWaPUy_o75pGxacY0kpWDla3rVFs_CrXM4NN3pU5EpqyRl3PjkyjToecQF1_UpOG50KEvOCkj12JwacwFS9Y3Hkc5rNfJN-tuU/s1600-rw/bsd-installer-boot-menu.png)






























