Let's talk FreeBSD (finally)
This week weâre joined by FreeBSD & OpenZFS developer, Allan Jude, to learn all about FreeBSD. Allan gives us a brief history of BSD, tells us why itâs his operating system of choice, compares it to Linux, explains the various BSDs out there & answers every curious question we have about this powerful (yet underrepresented) Unix-based operating system.
Matched from the episode's transcript đ
Allan Jude: ZFS and OpenZFS are licensed under the CDDL, which is a slightly modified version of the Mozilla Public License. And so the CDDL says - Iâm not a lawyer; donât take my legal advice. But in general, the license says that you can make a binary out of CDDL license code, and you can license that binary however you want, so that you can make a product out of it, or whatever. And so you can make a ZFS binary, a kernel module, or whatever, and license that even under the GPL, so itâd be compatible to integrate it into the Linux Kernel. But the GPL itself requires that any code you link into it has to be licensed under the GPL and the CDDL. It doesnât let you just change the license on that code to be under the GPL. And so thatâs where that kind of incompatibility comes in. But itâs not a very strong one, and Ubuntu is pretty sure that their legal way around it is working.
But because the FreeBSD license is literally two sentences, âDonât take off the copyrightâ and âReproduce the copyrightâ, it means that we could pull in all of ZFS, the codebase directly into FreeBSD. So if you go to the FreeBSD GitHub and the repo, under syscontrib thereâs a directory called OpenZFS that has a whole copy of the ZFS source code. So this means ZFS is completely just built into FreeBSD. So the FreeBSD bootloader has full support for reading from a ZFS pool, and so you can boot directly off ZFS, even if youâre using all the advanced features of ZFS. So this allows a feature called boot environments, where your root filesystem, if itâs ZFS, itâs actually a virtual file system, and you can have multiple different ones, or you can clone it and take snapshots. So when Iâm preparing to go to a conference or something, I have my laptop that runs FreeBSD, that I give my presentations off of, and I use a desktop most of the time when Iâm at home⌠So I havenât used my laptop much in the months between conferences. So Iâm going to update the OS, because itâs been a while, but thatâs when everything has the greatest chance to break, when youâre installing all these package updates, and so on.
So with ZFS I can take a snapshot of my root filesystem, and save that as âBefore I broke everything.â And then update stuff. And it all seems to work. And I check at home, and I can play stuff on the TV, so my HDMI is working, everythingâs fine. But say I fly to the conference, I get there, and something isnât working right. I can just reboot in the bootloader, say âHey, I want to use the image of before I broke everything, instead of the latest version of FreeBSD.â And it will roll back my root filesystem. But, importantly, it doesnât roll back my home directory. So I still have the latest version of my slides, but I have an older version of my OS that still works, because whatever latent problem I found, that ex Windows didnât want to support a certain resolution, or whatever broke. And so that can be really powerful.
Or if youâve ever tried to update the firmware or the OS on like a little router or something, they often have two images; they always have like the one-year update, and then thereâs like a spare one [unintelligible 00:31:15.20] switches to this, so that if you somehow botch the firmware update, they have a second firmware they can boot from in the meantime. So FreeBSD had a feature like that before it had ZFS called NanoBSD, that let you do that. Youâd partition up your disk into two big partitions and one little one. And the little one would hold the configuration, and the two big ones would be like version A and version B of whatever youâre trying to install, whether it was a firewall, or a router, or whatever. And youâd be running off A, so youâd update B, and the next time youâd boot youâd switch to B, and then you can ping pong between these two images. But ZFS allows you to do that with an unlimited number of images. Because each is just this virtual file system in the pool, you can have as many of these as you want, and you can access them directly from the bootloader and decide which one you want to use.
[00:32:01.16] And when youâre switching to one, it doesnât make the other ones go away. All the data is still there, because ZFS is copy on write, so only the bits you actually changed are taking space. So having seven copies of your operating system doesnât take that much space, because you only have to store the differences, not all of the data seven times. And so that allows much deeper integration.
But also, if we go back â when we talked about the fact that the base system utilities, like top, for example, are not a separate package that came from a different maintainer somewhere. That is part of the FreeBSD operating system. So when you start top on FreeBSD, under the line where it tells you about how much free memory you have, it has two lines about ZFS, telling you âThis is how much of your memory is being used by the [unintelligible 00:32:43.04] this much is for frequently used files, this much is for recently used files, and this much is data thatâs pending being written. Hereâs what your compression ratios are, and memoryâ, and all this other information that would only be there if you had ZFS. And because FreeBSD is integrated with ZFS, top can just be compiled against the version of ZFS [unintelligible 00:33:02.19] and be able to get that information all integrated.