If you have been messing around with servers for a while, you must have heard of FreeBSD, or any BSD at some point. It is similar to Linux in that in many cases you have only command line access with no GUI at all, and also commonly used on servers. But why is it different?

Why use FreeBSD instead of Linux? (or even Windows)

FreeBSD has been a mainstay operating system in servers and can be just as effective as Linux when it comes to server usage (actually more effective IMO). Many components are made to be easy to service:

  • The OS has a clear distinction between base system (everything shipped as part of FreeBSD) and third-party apps (anything you install on your own). This way it’s easy to update manually-installed apps without messing with the base system, you can get the latest applications without having to upgrade the OS, and unlike Linux, there is a lot less fragmentation compared to different Linux distros, since you just track FreeBSD’s version number.
  • Thanks to the port tree (just change directory to /usr/ports and you will see countless apps to choose from), it’s very easy to install an app by compiling from source. Type make install in that directory and you have a terminal GUI to select the available options to install what you want. There is also a text file containing important changes that you should be aware of in /usr/ports/UPDATING.
  • This port tree also contains messages about important changes in new versions, so you can be better prepared.
  • It has ZFS, the part-file-system part-volume-management tool that has some great features like snapshots and data integrity, despite being a memory hog. Also noteworthy is jail, an operating system-level virtualization that is isolated from the host.
  • The installation process for an application is more detailed, unlike Linux’s apt-get and yum, and you can learn a lot more about how they run in the process.
  • Each flavor of BSD (FreeBSD included) has its own official documentation that are also easy to understand, something that cannot be said about Linux distros. Even the man pages are more descriptive. This is a big help if you’re just starting out with sysadmin.
  • It’s a lot easier to learn Linux after FreeBSD than vice versa. Plus FreeBSD positions generally command more salary ūüėČ

Still with me? Now it’s time to install it ūüôā

Before we start

Determine which platform the computer you’ll be using is, as you need to download the correct installation file for your platform. General computers are either i386 (aka x86 or 32-bit) or amd64 (aka x86-64 or 64-bit, recommended for 4GB RAM or more, as long as your processor supports it). SPARC64 is a computer platform made by Sun Microsystem, while PowerPC is for¬†older Macs made before the transition to Intel processors in 2006.

You should also have at least 4GB RAM if you want to use ZFS, taking into account that you need 1GB RAM for every 1TB of storage, or even further if you want ZFS’s compression feature (at least 5GB RAM per 1TB of storage), or you will see serious performance issues. Hardware RAID controllers are also not recommended since¬†ZFS is software RAID anyway.

Installing FreeBSD

Simply head to the FreeBSD download page to get the installation file. You can run it on many platforms, even SPARC64 and Raspberry Pi. Remember to choose the UEFI version if you plan to install in UEFI mode. If you don’t have real hardware, just deploy it in your favorite hypervisor, namely VirtualBox ūüėČ

Next, burn that installation file to CD, flash drive, network boot, or any of your favorite method, then boot the computer from that media. This official page has some guides on how to burn to USB drive.
Note: use the .img file if you do plan to burn to flash drive.

Much of the installation process is already detailed in the official FreeBSD handbook, so I won’t repeat everything here, although I will¬†add some tidbits below:

When you’re asked about partitioning (see screenshot below),¬†I recommend using the Guide option as it is simple to understand and use for beginners. Keep in mind that it will format the entire drive in the process however, so make sure the drive is empty and/or you have already backed up.

bsdinstall-part-guided-manual

There are 4 options to choose, but we’ll focus on only two, Guided and ZFS.¬†Guided¬†will format the entire drive using the UFS file system, while ZFS will format the drive using the ZFS file system. Make sure that you meet the requirements before using ZFS, as there will be performance issues if you don’t. Note that you also have the options to use RAID or drive mirroring in ZFS.

FreeBSD partitioning

Choices available for partitioning

In the ZFS menu, select Disk to use and tick all the drives (press the spacebar) that you want to use in the RAID array (select only 1 drive if you want a single-disk setup), then move to ZFS VDev Type and select the type of RAID you want:

  • stripe¬†is equivalent to RAID0, meaning that performance is multipled by the number of drives, but the entire RAID will become corrupted if any of the drives fails. Not for redundancy.
  • mirror¬†is equivalent to RAID1, meaning that all the drives in the RAID array carry identical data. Good for redundancy, but the drawback is you can use only 1/n of the entire array’s combined capacity, where n is the number of drives. Recommended only for 2-drive array.
  • raidz1 is equivalent to RAID5, requiring at least 3 drives and allows 1 drive failure without corrupting the array.
  • raidz2¬†is similar¬†to RAID6¬†but¬†requires¬†at least 5¬†drives and allows 2¬†drive failures without corrupting the array.
  • raidz3 is similar to the two RAIDZ above but requires¬†at least 8¬†drives and allows 3¬†drive failure without corrupting the array.

Set the name so you can identify that this is the root filesystem. You can change the swap size, but the default value of 2GB is pretty adequate. (You should add more RAM instead of adding swap!) Also optional is disk encryption, and a passphrase to unlock the array is required (make sure you remember it too!). Other options such as Partition scheme and Force 4K Sectors¬†can be left as is. Once you’re really sure you’ve set everything correctly, go ahead and commit¬†the installation.

Next up, set the password for root user. This root user is the user that has the right to do anything, even making the system unbootable. You definitely¬†don’t want its password to be known to others. You will also be asked if you want to create other users on the system, which you should. While creating new users, make sure that you add this user to the wheel group if you want this user to have administrative access. The best practice is to use normal users and switch to root only when required.

You will be asked to reboot after the installation is complete. Stay tuned for more on FreeBSD usage.

Leave a Reply

Your email address will not be published. Required fields are marked *