How to Install FreeBSD: A Linux Alternative

How to Install FreeBSD: A Linux Alternative

how-to-install-freebsd-a-open-source-unix-like-operating-system

Hi all, and welcome to MusaBase! In this article, I'll install FreeBSD, if you are looking to install a secure, high-performance system, this guide is for you. Whether you're a first-timer or an experienced user, We'll cover:

  • Downloading the latest FreeBSD installation ISO
  • Creating a bootable USB stick
  • Booting into the FreeBSD installer
  • Disk Partitioning for a custom Setup
  • Installing the base FreeBSD system
  • Configure networking and adding a User with doas or sudo

By the end, you'll have a fully functional FreeBSD system up and running on your PC. So without further ado, let's get started!







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 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 issue. Below are system specs for a fully fledged FreeBSD system with Desktop or Development Environment on a modern release like (FreeBSD 14.x):

System Specs:




Step 1: Download FreeBSD ISO & Create Bootable USB

1.1: Download FreeBSD Installer
  • Go to freebsd.org/where.
  • To Download the ISO image according to your PC's CPU architecture, click on the provided images. (e.g., amd64 (for Modern Intel or AMD Processors) or i386 (for older 32-bit processors)).
  • After the download is complete you would have file similar to this:
1.2: Create a Bootable USB Drive

1.2.1: Using Balena Etcher (GUI) if using Windows/Mac/Linux

  • Download and install it.
  • Run Etcher.
  • Select your freebsd.iso file.
  • Choose your USB drive from Etcher.
  • Click Flash! and after a few minutes your USB will be booted with FreeBSD ISO.

1.2.2: Using dd (CLI) if using 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 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 USB by running this command:
sudo dd if=/mnt/sdc1/Downloads/freeBSD.iso of=/dev/sda bs=4M status=progress oflag=sync
Note: Replace the /mnt/sdc1/Downloads/freeBSD.iso and /dev/sda with your actual path where the freeBSD.iso is located and to your USB.
  • 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 ISO to USB, eject your USB by running this command:
sudo eject /dev/sdX
⚠️ Warning: Using dd incorrectly can overwrite your hard disl. Double-check if= and of= before executing.



Step 2: Boot into FreeBSD Installation Environment

  • Reboot your PC.
  • While your PC is turning on press F9, F10, F11, F12, DEL, or ESC key to open UEFI/BIOS settings.
  • Locate and disable Secure Boot & Fast Boot option (Usually its under 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 then you would be greeted by FreeBSD installer menu.
  • Press 1 to enter FreeBSD installation.
freebsd-installer-boot-menu

After a few seconds you will be inside FreeBSD live installation environment.

freebsd-live-installation-env

  • Press ENTER to go into settings for installing FreeBSD.
2.1: Navigate FreeBSD Installation Environment

Since it's a text-based interface, we can't use mouse to click thorugh presented options. But navigating this interface with 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 () keys to navigate upward or downward.
  • Press SPACE BAR to select.
  • Press ENTER to continue to next prompt.
  • Press TAB to navigate decisions options. (e.g., Continue, Cancel, Select, etc).



Step 3: Configuring Keymap & Hostname

3.1: Configure Keymap

The very first FreeBSD live installation system configuration we get is setting our Keymap. A keymap defines how your keybaord's physical keys are interpreted by the operating system.

  • The default keymap is set to "US", if you are comfortable with the defualt one then press Enter to continue.
  • If you want to select keymap according to your preferences then navigate the list and select with SPACE then press Enter to continue.
freebsd-keymap

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.
setting-hostname-for-freebsd-system




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 only needed for running older or legacy (32-bit) applications on a 64-bit system.

  • You can select/unselect each components by navigating to them and pressing SPACE then press ENTER to continue.
  • For this guide i am going only with the 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, make it easier to diagnose crashes in these tools.


kernel-dbg or Kernel (Debugging)

Installs the FreeBSD kernel and modules compiled with debug symbols. 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 libraries needed to run 32-bit applications on a 64-bit system. If you intend to run legacy 32-bit applications, such as, WinZip, PaintShop Pro (older editions) or COBOL-based tools, FoxPro, etc, you need this component.


ports or Ports tree

Install the enitre 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 developer or needs to verify system stability or test specific components.




Step 5: Configure Network

  • Next up is configuring networking.
  • Choose your controller if more than one are showing and press ENTER.
  • I have only one network controller showing for my setup, this could be different for you.
choose-network-controller

  • Next, it will ask you to whether to configrue 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 for me these are the settings for these configurations are showing like this:
configuring-network-with-dhcp-ipv4-ipv6



Step 6: Disk Partition

FreeBSD provides us four options to partition 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
5.1: Partition with Auto ZFS

ZFS is a modern, industry-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 supported.
  • Trade-Offs:
    • Higher memory usage if you have a low RAM system.
    • Disk Layouts typically uses the entire disk, though datasets are flexible.

For ZFS configuration we don't have to do much, because it is being automatically handled by the FreeBSD Installer, if you are okay with the default configurations then hit ENTER on Proceed with Installation and it will take you to next step of the installation.

install-freebsd-with-auto-zfs-default-configuration-partition

5.1.1: Configure ZFS Pool Type

When we choose 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 (group of disks), and a zpool is made up of one or more vdevs. These vdevs or ZFS virtual devices are:

Pool Type
1. stripe (RAID-0 equivalent)
stripe-pool-type

  • No redundancy data is striped across all disks.
  • Maximum performance and capacity, but a single disk failuer will result in damaging or even destroying the entire pool.
  • Use only for non-critical data or temporary scratch space.
  • Can work with single hard-disk.
2. mirror (RAID-1 equivalent)
mirror-pool-type

  • Two or more disks can hold same copies of all data.
  • If data loss happen at one disk the other can still operate.
  • Reading data in the disks could be faster but if one disk has slow writing speed it will limit it for all other disks.
  • Requires two hard-disks.
3. raid10
raid10-pool-type

  • This pool type mirrors and stipes data across multiple mirrored pairs.
  • Provides high performance, good redundancy.
  • Can survive one disk failure in each mirror pair.
  • Requires even number of hard-disks. (e.g., 2, 4, 6, etc).
4. raidz1
raidz1-pool-type

  • Data + single parity is distributed across all disks in the vdev.
  • Can survive one disk failure, but a second failure leads to data loss.
  • Balances capcity and protection, but slower than mirror pool type.
  • Requires minimum three hard-disks.
5. raidz2
raidz2-pool-type

  • This pool type uses dual parity, it allows two disks to fail, but without data loss.
  • It better option for larger pool setups, but offers slower performance and higher overhead due to extra parity.
  • Requires minimum four hard-disks.
6. raidz3
raidz3-pool-type

  • This pool type as the name suggests can survive three simultaneous disk failures before data loss happen.
  • Highest redundancy, but also the highest overhead and slowest among the ZFS parity options.
  • Requires minimum five hard-disks.
So which One should You Choose?
  • If you need speed and efficieny then Mirror or RAID10 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 fastest and capacity-efficient, but the trade-off here is, it has not protection.

For more information on parity bits and RAID please visit DiskInternals.

  • Let's say if we choose Stripe Type with two hard-disks.
  • Now, it's going to create a storage pool with 2 hard-disks.
  • After configuring your pool type, choose Proceed with isntallation and press ENTER and it will take you to the next step of FreeBSD installation.
5.2: Partition with Auto UFS

The UFS is the traditional BSD filesystem, known for 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 OS.
  • Supports journaling for improved crash consistency.
  • 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.

5.2.1: Partition Disk with UFS

  • Choose Auto (UFS) and press ENTER.
  • Next, if you have multiple hard-disks connected to your PC then select one in which you want to make partitions for FreeBSD installation.
  • Next, it will ask if you want to use the Entire Disk or Partitions, I'm choosing Entire Disk. (It will erase all data on the selected disk, if you want to create partition then do it with the Manual Partition method, because doing it with manual gives us more control and freedom to choose filesystem).
  • Next, select GPT for Partition Scheme.
  • Next, confirm the layout and also here you can modify or change each partition allocated space. Choose [ Finish ] and press ENTER.
  • On the next prompt it will ask you for confirmation to apply the changes and write the changes to disk. Choose [ Commit ] and press ENTER.
  • It will start writing changes to disk and move you to the next step of the installation.
5.3: Manual Partition

With manual partition we have full control over how each partition is created. Also how much space we want to allocate to each partition.

  • Choose Manual and press ENTER.
freebsd-manual-partition
  • Next, select disk for partitioning and choose [ Create ] and press ENTER. I'm choosing my first hard-disk ada1 40GB.
  • Choose GPT for Partition Scheme and press ENTER.
  • A message should prompt that will states Partition Table has been assigned to selected disk, please press on Create again.

5.3.1: Creating Boot Partition

  • Choose [ Create ] again and press ENTER.
  • Press TAB key to input data in the configruation fields.
  • Fill the following fields something like this:
Type: freebsd-boot
Size: 512MB
Mountpoint:
Label: Boot

5.3.2: Creating Swap Partition

  • Again select your hard-disk and choose [ Create ] and press ENTER.
  • Press TAB key to get to input fields.
  • Fill the fields like this:
Type: freebsd-swap
Size: 8GB
Mountpoint: 
Label: Swap

5.3.3: Creating Root Partition

  • Select you hard-disk again and choose [ Create ] and press ENTER.
  • Press TAB key to enter input in input fields.
  • Fill the following fields like this:
Type: freebsd-ufs
Size: 19GB
Mountpoint: /
Label: Root
  • We can also add other partitions as well, (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 all your partitions are created, confirm the partition layout and choose [ Finish ] and press ENTER.
  • The Installer will ask you for confirmation on writing the changes to disk and create partitions. Choose [ Commit ] and press ENTER and it will start creating partitions and take you to next step.
5.4: Partition with Shell

Disk partitioning with FreeBSD Shell environment gives us full control over partitioing, we can precisely define the disk layout using commands like gpart, newfs, etc. It is unique if you are creating a non-standard setup, mixed filesystem, encryption, custom alignment, or manual ZFS on a subvolume.

5.4.1: Partition with Shell

  • Choose Shell and press ENTER. You will be in a CLI environment.

5.4.2: List All Connected Storage Devices

  • First identify the hard-disk in which you want to create partitions.
  • Run the following command:

#for HDDs

sysctl kern.disks

# for SCSI/NVMe Disks

camcontrol devlist
  • For more information about storage drives, we can use the geom command:
geom disk list

5.4.3: Create Boot Partition

  • First we need to initialize out disk with GPT partition scheme.
  • Next, we will create the boot partition.
  • Next, 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

5.4.4: Create Swap Partition

  • Run the following command:
gpart add -t freebsd-swap -s 8G -a 1M ada1

5.4.5: Creating Additional Partitions /var /tmp /usr
  • For creating /var, /tmp, /usr, do the following:

#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

5.4.6: Create Root Partition

  • Now for root partition, I'm allocating my remaining space to it. If you plan on creating additional partitions then please do as explained in the step 5.4.5.
  • To create root partition, run:
gpart add -t freebsd-ufs -a 1M ada1

5.4.6: Format & Mounting Partitions

For boot partition, we don't have to mount it anywhere, the FreeBSD manage it automatically. However we need to format and mount the root partition and for swap partition we just have to turn it on.

List Hard-disk with its Partitions
  • Its a good idea to list our hard-disk with all its partitions. This way we can easily format and mount over each partition without accidentally formatting the wron partition.
  • Run:
gpart show ada1
listing-out-hard-disk-with-all-its-partition-in-freebsd-shell-env
Turn on Swap Partition
  • Run the following command:
swapon /dev/ada1p2
turning-on-swap-partition-for-freebsd-system-in-shell-env

Format & Mount Root Partition
  • To mount 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 format and mount in the same fashion as 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/adanpn /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's Shell environment.
  • Run:
exit
  • When we exit the shell environment, the installer will detect the layout and proceed with installation from the mounted root.



Step 7: FreeBSD Base System Installation

After creating the partitions, the installer will take you to 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 in the faster downloads.
  • Pick your mirror and ENTER.

7.2: Installing FreeBSD Base System

  • After fetching mirror information, the installer will automatically start downloading/fetching base system or distribution files. such as, base, kernel, and files for additional components that we selected at Additional Components step lib32, etc.
  • After downloading 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 to set the password for root or root access.
  • Enter and re-enter your password for root.



Step 8: FreeBSD Base System Configuration

Next up, 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 is set correctly, if not then adjust date and time according to your local date and time.
8.2: Add Boot Services
  • Next, FreeBSD's installer gives us the services to start with system boot.
  • I'm going with default selected services, but you can choose service by pressing SPACE then press ENTER to continue to next step.
freebsd-services-start-at-boot
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 FreeBSD base.
  • This makes the DNS lookups faster and validate DNSSEC.
2. sshd or Secure Shell Daemon

Check this Service if you want remotely 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 text console, useful for BIOS/GRUB-like console or file managers in a non-GUI environment.
4. ntpd or Network Time Protocol Daemmon
  • Continously 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
  • Adjust CPU frequency dynamically to support power saving and thermal performance on latops and desktops.
7. dumpdev or Kenrnel 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 crash.
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 mostly 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 ENTER to continue to next step.
choosing-freebsd-system-hardening
Purpose of each System Hardening
0. hide_uids or Hide Processes Running as other Users
  • Check this hardening if you 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
3. read_msgbuf or Disable Reading Kernel Message Buffer for Unprivileged Users
  • Enable this hardening if you are having a multi-users System.
  • Prevents users from reading kernel logs via dmesh. Only root can read logs.
4. proc_debug or Disable Process Debugging Facilitites 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 attacker to guess the PID of sensitive processes.
6. clear_tmp or Clean the /tmp Filesystem on System Startup
  • Wipe all contents of /tmp directory every time system boots.
  • This prevents leftover temporary files from causing conflicts or leading data.
7. disable_syslogd or Disable Opening Syslogd Network Socket
  • This hardening is only useful for systems that are not needing 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 users. Type your username and press ENTER.
  • (Optional) Type your Full name and press ENTER.
  • For third prompt labeled, Uid (Leave empty for default): pree ENTER for default.
  • Next, for login group, type wheel and press ENTER. Adding your user to wheel group is important, without it user won't be able to do 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 next two options, Home directory [/home/username] and Home directory permission, leave these options at defaults by press ENTER.

8.4.1: User Password

  • For option Use password-based authentication? [ yes ], the default is yes so press ENTER to set 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 password for your user.
  • Next, enter and re-enter password for your user.
  • After setting your 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 password for your user, the installer will show the detailed information about the user account.
  • Confirm settings by pressing ENTER if everything is right, if not, then type no and press ENTER to add user again.
  • After that it will ask you, if you want to add another user, you can add mutliple user if you want just don't forget to add them in wheel, video and operator groups if you want to give these users the 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 the changes here if you miss anything or couldn't configured any step correctly.
  • Choose Exit and Press ENTER.
freebsd-final-configuration
  • Next, the installer will ask if you want to open 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 then, you should see the FreeBSD boot menu:
installed-freebsd-boot-menu
  • Press 1 or ENTER to go into installed FreeBSD system.
  • After a few seconds FreeBSD should prompt your for login with your username and user password.
  • Enter your username and password that you created during installation and press ENTER.
freebsd-login-into-system
9.1: Resolve (mountroot>) Error
freebsd-mountroot-error-after-installation

When you boot into your installed FreeBSD system after installation, you may get mountroot> error. For now this error may happens, 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>, run:
ufs:/dev/ada0p3
  • After the root filesystem is mounted you will get to login prompt.
  • Enter your username and password that you created during installation.
  • Next, we will make this process automatic by adding filesystem entries in fstab.

9.1.2: Auto Mount Filesystem

  • Next, if you don't add your partitions or filesystem entries at fstab you have to do the above step at every boot.
  • To make sure that the filesystem automatically mounted at every boot do the following:

9.1.3: Change to Super User and Add Entries to Fstab

  • Run the su command to change root user and enter your root password that you created during installation.
su
freebsd-change-to-super-user
  • Next, run the gpart command to verify and note the information about your partition's numbers.
freebsd-gpart-show-ada0
  • Next, we'll add entries in 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
adding-filesystem-entries-to-fstab
  • We can also read the content of fstab or other files with cat command.
  • Run the following command to make sure the entries has been added:
cat /etc/fstab
freebsd-verifying-fstab-entries
  • Next, run:
reboot
  • It will reboot the pc, and after boot you should get straight to login prompt.
freebsd-login-prompt



Step 10: Configure Installed FreeBSD System

Now FreeBSD system is installed, but its bare minimal system without essentials 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 user to root because at the moment the user don't have sudo privileges.

  • To change user to root, simply run:
su
  • Enter your password for your root which you created during installation and press ENTER.
freebsd-changing-user-to-root

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 leave the 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 default quarterly changes 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 package management tool and new updates if missing.

10.1.2: Switch Packages Branch

  • Next, we need to make directory for 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/
freebsd-creating-directory-for-repos-and-copying-default-package-conf-file
  • Next, we need to edit the FreeBSD.conf at repos.
  • 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 just replace the entry quarterly to latest and save & exit the file.
  • Look for 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 latest branch.
  • Run:
pkg update

10.2: Install Nano

Nano is a command-line text editor designed for Unix-like operating systems.

  • In next few steps i am going to use nano for editing or creating conf files.
  • Its more of a personal preferences you can use ee or vim if you perfer that.
  • Run:
pkg install nano

10.3: Install and Configure DOAS

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 smaller codebase.

  • To install doas, run:
pkg install doas
  • After calculating package dependency, the installer will ask to confirm the install.
  • 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 as well.
  • Do the following:
cd /usr/local/etc
nano doas.conf
  • The above command should open doas.conf file in nano.
  • The file will be filled with data like permit, authorization etc.
  • Delete all lines in the file by pressing DEL key.
  • Next, we are going to add our custom permission for user.
  • Add the following line in doas.conf file.
permit nopass keepenv :wheel
freebsd-editing-doas-conf-file
  • Press CTRL + O to save the changes and then press ENTER to apply the changes, then press CTRL + X to exit the file.
  • Next, switch back to user to verify doas is working correctly.
  • Run:
exit
freebsd-switch-back-to-user

10.4: Install and Configure SUDO

  • Now, we will install sudo as our user.
  • Run the following command as user:
doas pkg install sudo
  • After fetching sudo, the package installer will ask for confirmation of installtion.
  • Type y and press ENTER.
  • Next, we need to configure a sudoers file.
  • Basically, we need to open the visudo and edit lines for wheel.
  • Run the following commands:
export EDITOR=/usr/local/bin/nano
visudo

10.4.1: Edit sudoers

  • In sudoers file, navigate to bottom with keyboard's Down () key.
  • Look for and delete the # from the starting of the line which contains:
# %wheel ALL=(ALL:ALL) ALL
  • Press CTRL + O to save the changes then press ENTER to apply the changes, press CTRL + X to exit the file.
  • Now, you can use both doas and sudo for your user perform tasks as root.

10.5: Installing Neofetch

  • Next, we will install neofetch with sudo.
  • Run:
sudo pkg install neofetch
  • Run neofetch:
neofetch
freebsd-neofetch



Afterwards

Now that your FreeBSD is successfully installed and configured for next steps. You can also install bash, bash-completion, or familiar shells if you're coming from Linux. I will also upload a follow up guide on installing Desktop Environment and utilities essentails for a fully fledged desktop pc.
If you hit any error following this guide, please let me know in the comments, i will be more than happy to help.
1o1 out, I'll see you in the next one!

Load comments