DEV Community

Cover image for FreeBSD for Devs #02
Vitor Lobo
Vitor Lobo

Posted on

FreeBSD for Devs #02

Estimated Read Time: 13–16 minutes

Content table

Image description

Introduction

Embarking on installing FreeBSD marks the beginning of a transformative journey in setting up your personal computing environment. While some might compare its complexity to Linux distributions such as Arch Linux or Slackware, FreeBSD distinguishes itself with a more straightforward installation process.

Unlike these distributions, FreeBSD's bsdinstall provides a guided setup, helping users through partitioning and network setups—a blessing for those new to Unix-like systems or those who prefer not to delve deep into command-line right off the bat.

In the post-installation phase, FreeBSD's adaptability truly shines. It offers users the freedom to tailor the system precisely to their needs. Whether you're a developer or a system administrator, the rich assortment of applications available through FreeBSD's Ports Collection and pkg system allows for a highly customized and controlled environment, turning system setup from a task into a craft.

Here's How to Start:

Step 1: Booting Up

When you boot from the FreeBSD installation media, you'll be greeted with the FreeBSD boot menu. You have options like "Boot Single User" or "Escape to loader prompt", but as a developer, you typically want to dive straight into the installation. So, choose "Boot Installer."

Image description

The screen you're seeing is the FreeBSD bootloader menu. Here's what each option does:

  • Boot Installer [Enter]: This option starts the FreeBSD installation process. It's typically the default choice and the one you'd select for a standard installation on a desktop or server.
  • Boot Single User: This mode is mainly for troubleshooting and maintenance. In single user mode, only the root file system is mounted, and it's mounted in read-only mode. This is not typically used for standard installations but is helpful if you need to recover from a system crash or perform maintenance tasks that can't be performed while the system is running normally.
  • Escape to loader prompt: This takes you to the 'OK' prompt, where you can enter boot loader commands. This is for advanced users who need to set kernel variables or load kernel modules before booting.
  • Reboot: This option restarts your computer. Use this if you need to abort the boot process and start over or if you need to change your BIOS/UEFI settings.
  • Cons: Dual (Video primary): This option is for configuring console settings, particularly useful if you have a system with more than one video output and you want to select which one FreeBSD uses for console display.

Options:

  • Kernel: default/kernel (1 of 1): FreeBSD allows you to select from multiple kernels if they are available. The 'default/kernel' is the standard kernel that comes with FreeBSD. Unless you have custom-compiled a new kernel with different configurations, this is the one you'll use.

  • Boot Options: This takes you to a submenu where you can set various boot options, like booting into safe mode, disabling ACPI, etc. These are typically used for troubleshooting hardware compatibility issues.


Step 2: Welcome Screen

You'll see a welcome prompt asking if you want to install, shell, or live CD. Since we're setting up a desktop environment, go for "Install."

Image description

This screen presents you with three options for proceeding with FreeBSD:

  • [Install]: Selecting this option will start the FreeBSD installation process on your system. This is the choice you would make if you want to install FreeBSD to your hard drive or SSD to use as your operating system.

  • [Shell]: Choosing this option will drop you into a single user root shell. This is useful if you need to perform troubleshooting or advanced system configuration before installing FreeBSD. It's also used for manual installation or disk partitioning using command-line utilities.

  • [Live CD]: This option boots into a live environment where you can use FreeBSD without installing it to your hard drive. This is helpful if you want to test FreeBSD compatibility with your hardware or if you need to rescue data from a system without installing a new OS.

To proceed with a standard installation on a desktop or for general use, you should choose [Install]. This will guide you through the process of setting up FreeBSD on your computer, including partitioning the disk, selecting packages, and configuring system settings.


Step 3: Keyboard Layout

As a developer, you might be using a particular keyboard layout that fits your coding needs. You'll have the option to choose your preferred keyboard layout from a list—pick what's comfortable for you.

Image description

Step 4: Set Hostname

A hostname is like your computer's name. You can stick with the default "localhost" or choose something that will make your machine easily identifiable on a network.

Image description

Step 5: Distribution Select

The screen you're looking at presents a list of optional system components that can be installed with FreeBSD. Here's what each of them is for:

Image description

  • base-dbg: Debugging symbols for the base system. This is useful if you plan to debug the base system and need to have detailed information available when things go wrong.

  • kernel-dbg: Debugging symbols for the kernel. This is similar to base-dbg but specifically for the kernel. It's useful if you're developing or debugging kernel modules.

  • lib32-dbg: 32-bit compatibility libraries with debugging symbols. This would be necessary if you are running 32-bit applications on your 64-bit FreeBSD system and need to debug them.

  • lib32: These are the 32-bit compatibility libraries without debugging symbols. This is needed if you want to run 32-bit applications on your FreeBSD system but do not need to debug them.

  • ports: The FreeBSD ports collection. This is a vast collection of software that can be compiled and installed directly from source. It's very useful if you want access to additional software not included in the base system.

  • src: The system source tree. This includes the full source code for the FreeBSD operating system. It's useful if you want to read or modify the system source code or compile the entire system from source.

  • tests: The test suite for FreeBSD. This includes utilities to test the functionality and stability of the system.

Considering the installation is for a desktop development environment, it would be appropriate to install all listed components. This will offer a wide range of tools and features to support a variety of development needs. Check all options and confirm to proceed with the complete installation.


Step 6: Partitioning

For the file system, you'll have options like UFS and ZFS. ZFS is robust and includes features like snapshots, which can be great for development. However, it's a bit heavier on resources.

Image description

For a dev setup, I'd lean towards Auto (ZFS). It's a good mix of easy setup and advanced features. Plus, with ZFS's snapshots, if you mess something up, you can roll back to when things were working — that's pretty sweet for development work. Just hit "OK" on that option, and you'll be set!


Step 7: ZFS Configuration

If you opt for ZFS, you'll configure things like disk encryption and swap size. The settings below are merely a demonstration. Configure this part according to your context.

Image description

When you're at the ZFS configuration menu, you've got some options to consider based on your specific needs:

  • Install/Pool Type/Disks: This is where you confirm the disks you're installing to and select the type of ZFS pool you want. The default, a basic stripe (think of it as a single-layer cake of disks with no redundancy), is fine for most users, but tweak it if you have multiple disks and want mirroring or RAID-Z for data protection.

  • Force 4K Sectors: If your disk uses 4K sectors, you should say 'Yes' to this to optimize performance. If you're not sure, check your disk's specs.

  • Partition Scheme: GPT is the modern standard for partition tables, and it's what you want for a new system, especially if your system is UEFI-based.

  • Swap Size: This is like a safety net for your RAM. If you run out of memory, the system uses this space on the disk. 2 GB is generally okay, but if you plan on running heavy applications or virtual machines, consider bumping this up.

  • Mirror Swap: If you're setting up a system with redundancy in mind and have multiple disks, mirroring your swap can be a good move. Otherwise, you can leave this set to 'No'.

  • Encrypt Swap: This is about security. If you're working with sensitive data and you opt for encrypting your filesystem, you might want to encrypt the swap as well. But remember, this can impact performance.

Every user's situation is unique, so while these are general guidelines, you should tailor each setting to fit your workflow and requirements. When in doubt, you can often stick with the defaults, which are designed to meet the needs of most users. Just navigate through the options using the arrows and select the ones you want to tweak.


Step 8: Root Password

Next, you'll be asked to set a password for the root (system administrator) account. Choose a strong, memorable password—this account has control over the entire system!

Image description

NOTE: In FreeBSD the root group is called wheel


Step 9: Network Configuration

The installer will prompt you to configure your network interfaces. This is crucial for your desktop to connect to the internet or local network. Typically, you'd pick the relevant network interface and proceed with the default options unless you have specific network settings in mind.

Image description

You'll be asked if you want to configure IPv4 and IPv6 for your network interface. For most users, enabling IPv4 and using DHCP (Dynamic Host Configuration Protocol) allows your system to automatically obtain an IP address. If you're also using IPv6, you might want to configure that as well—though not all networks support it.

DNS (Domain Name System) settings come next. If you're in a company or have specific DNS servers you want to use, input them here. Otherwise, the defaults provided by DHCP usually work just fine.

Step 10: Time Zone Selection

It's important to set the correct time zone for your system. This affects not only the system clock but also time stamps on files and scheduled tasks. Select the region that applies to you.

Step 11: Time Zone and Date Setup

After selecting your country or region to set your time zone, you will confirm the abbreviation for your local time. For example, if you're in Japan, the installer will suggest "JST" for Japan Standard Time, and you would confirm this. Next, set the current date and time, ensuring that your system's clock is accurate.

System Configuration and Hardening

Configuring your system services is next. Services like SSH (for secure remote connections), NTP (for time synchronization), and crash dump handling are standard choices.

After services, you’ll be offered security hardening options. These include settings that increase your system's security posture, like disabling remote syslog, restricting debugging features, and ensuring secure temp file handling. Developers may opt for a balanced approach to security versus convenience.

Image description

Adding Users

Adding a non-root user is a must for daily operations. This step involves setting the username, password, and other options like whether this user can assume superuser rights with sudo. Fill in these details as prompted, and your user account will be ready.

Final Configuration and Exit

Once you've added users and configured services and security settings, you'll be presented with a "Final Configuration" menu. Here you can apply your configuration choices and exit the installer, or dive into manual configurations using a shell if you need to tweak any advanced settings.

Manual Configuration and Reboot

The installer will ask if you'd like to open a shell to make any last manual changes. This is handy if you're an advanced user needing to edit configuration files directly. Otherwise, you can skip this step.

Installation Complete

Finally, the installer will confirm that the installation is complete and ask if you'd like to reboot into your new system, shut down, or return to the live CD environment. Choose to reboot, and your system will start with all your selected options in place, ready for you to install your development tools and get coding!

Image description

In the next article, I'll describe all the necessary configurations for a clean and lightweight development environment. Stay tuned for more insights and tips!

Top comments (0)