pascal jungblut posts

You should try FreeBSD!

You have probably heard of FreeBSD (or any other BSD). Have you used it? If yes: stop reading right here. If no: read on, maybe you want to try it.

I know plenty of developers who feel very comfortable with Linux (especially Ubuntu is common these days). They have their developer server and probably production server running on Linux. But why Linux and not FreeBSD? There are several reasons, maybe one applies to you.

FreeBSD? What’s that?

To some developers FreeBSD is what Linux is to their parents: maybe they heard about it once but don’t know what exactly it is. Well, FreeBSD is an open source operating system that has its origins in the Berkeley Software Distribution. Because Linux was heavily influenced by BSD, Linux and the BSDs are pretty similar on the surface. When I say surface I mean that lots of commands and directories are the same as on a Linux machine. A really big difference is that FreeBSD is the kernel and userland together. In the Linuxworld however there’s plenty of vendors with distributions and own patchsets that are applied on the Linux kernel. Matthew Fuller wrote an excellent and not too opinionated comparison of FreeBSD and Linux. I highly recommend the read.

My Ubuntu server already works — why bother?

Yes, there are millions of Linux servers out there and they work well. Why would anyone ever look at something different? Never touch a running system, right? Well, first I don’t want you to throw your production boxes out of the window and replace them with FreeBSD servers. Just spin up a VM and install FreeBSD, it’s not that hard. But more importantly it is good to realize that there are more free operating systems out there than you might think. Getting to know them will probably change your perspective. At least that is what happened to me.

Stackoverflow’s answers assume I have apt-get installed

That’s actually true - come across an obscure error message of the calendar server you’re trying to install, google it and find instructions to fix it on Ubuntu/Debian only. If your understanding of the server OS does only allow you to copy/paste random strings from Stackoverflow, you might not really enjoy FreeBSD (or anything besides Ubuntu) — but then, why are you operating a server in the first place?

The good thing is: FreeBSD comes with an excellent handbook. It does not only provide practical advise but also describes the architecture, history and quirks of FreeBSD (and to some extend Unix in general). Even better: once you get the basics it’s really easy to go from there. One of the differences between Linux and the BSDs is that the BSDs are more structured, planned and clear. In contrast Linux is more grown and chaotic, partly because of the design to keep the kernel and userland separately and partly because of the many distributions that all have their own idea of how to do things. That’s not bad in itself (really cool things have developed around it) but sometimes it makes things more complicated than they need to be.

I like to compare FreeBSD to a really tidy room where you can find everything with your eyes closed. Once you know where the closets are, it is easy to just grab what you need, even if you have never touched it before. To give you an example: everything you install that is not part of the so called base system will be installed in /usr/local and only there. And while the basesystem’s configuration resides in /etc, everything you install will be configured in /usr/local/etc. Another good example is the /etc/rc.conf. When you need to configure something regarding the startup (network, services, swap) you can find it here, all in one place in a simple config file.

There is exactly one correct place for a given part of the system — it takes some time to get to know these places. But once you do, everything is exactly where you’d expect it.

Will program xyz work?

Almost certainly everything you use will also work on FreeBSD. Have a look at the ports tree. The ports system lets you install packages easily — it is the package management of FreeBSD. Installing a package is as easy as pkg install <pkgname> and ports makes it really easy to compile a package when the precompiled binary does not fit your needs.

That being said, there are some things that just won’t compile because of a Linux-specific include or something. In those cases it can be sufficient to comment out an include, but you might also need to invest weeks to patch something. However, that rarely happens. Everything in the ports tree (which is a lot) will run just fine out of the box. There are even compatibility packages for Linux binaries.

Is FreeBSD stable?

Yes, it’s rock solid. Many major companies like Google or Netflix use FreeBSD in production. FreeBSD people are conservative when it comes to changes to the system. They really don’t like surprises.

Developing and shipping the kernel and userland together eliminates one big source of errors.

A stable system is good. But are there any extras?

There are many details that are unique to FreeBSD but I’ll highlight two features that are really popular.

Obviously ZFS brings many people to FreeBSD. It is a file system and logical volume manager in one. Some of the really cool features are easy snapshotting (and handling them), storage pools, builtin compression, copy on write, data deduplication and many more. The best part is that it’s really stable plus FreeBSD can boot from ZFS. If you like to have your data in a safe place, you’ll love ZFS.

The other really cool thing that got me into FreeBSD are jails. A jail is a bit like chroot on steroids — and more. In a jail nearly everything looks like a normal installation of FreeBSD, but only processes, files and user accounts inside the jail are visible, although it runs the same kernel as the host system does. Have a wonky Wordpress installation? Put it in a jail and be sure that it won’t take your mail server with it when it gets compromised. Because jails use the same kernel as the host, they’re really lightweight and you can have many of them on one machine. They are like Linux containers but 15 years more stable.

Where to go from here

The FreeBSD website is an excellent resource. If you’re into pragmatic video tutorials: the Vimeo user ‘hukl’ has uploaded a series of videos that show the process from downloading FreeBSD to setting up jails with ZFS. The IRC channel #freebsd on Freenode is a really friendly and helpful place if you have any questions. The best thing to do is to download a FreeBSD image, fire up a VM and play around with it. Maybe you’ll like it as I do. I came for ZFS and stayed for FreeBSD.