FreeBSD, from CD-ROM to Cloud

Illustration for FreeBSD, from CD-ROM to Cloud

I’ve been using Open Source for 25 years (man, what a depressing way to start this article). Linux has taken over the world, but I still have a soft spot for the BSD family in general and for FreeBSD in particular. Blame it on the colourful cast of characters who build the BSD OSes: Bill Joy, Kirk McKusick and so on. And yeah, blame it on the Daemon t-shirts ;)

So, for the sake of having fun and perpetuating the legacy, how about we start a FreeBSD instance on AWS and see where this could lead us?

The good news is that it couldn’t be easier. Just log in to your AWS account and head for the AWS Marketplace: in a couple of clicks, you’ll find images for FreeBSD 10 & 11. Kudos to Colin Perceval for maintaining them.

Step 3 screenshot from Freebsd  From Cd Rom to Cloud

Next, we need to pick an instance type. One of the perks of working for AWS is not paying for infrastructure, so why not pick something really large, like i2.8xlarge: 32 vCPUs, 244GB RAM, 8x800GB local SSD storage, 10Gb networking. I’d have gone for the i3 family, but for reasons unknown to me, the FreeBSD AMI doesn’t support it. Probably a driver issue, I’ll look into it.

A few minutes later, the instance is ready.

Screenshot from Freebsd  From Cd Rom to Cloud tutorial

What now? Back in the day, I loved rebuilding everything from source. It was a great way to learn and that mystical “make world” command fascinated me. It would be fun to do that again, hey? Let’s go!

First things first: storage. The source distribution is pretty large and building it requires even more space of course. Well, this instance does have an EBS volume attached, but it also has a ton of ultra-fast local storage (aka instance store in AWS terminology). Isn’t this a great opportunity to use ZFS (another one of my obsessions)? Of course it is.

This is how these 8 disks appear on the instance:

Step 5 screenshot from Freebsd  From Cd Rom to Cloud

Let’s switch to root and initialise them with a single slice. First, I need to run an arcane ‘sysctl’ command allowing me to do this without having to drop to single-user mode (yes, I’m lazy…and I want to keep this short!).

Step 10 screenshot from Freebsd  From Cd Rom to Cloud

Now we can create our ZFS storage. Let’s use 4 disks for source files and 4 disks for object files. This is all it takes:

Step 2 screenshot from Freebsd  From Cd Rom to Cloud

Let’s now fetch all FreeBSD 11 sources and extract them:

Step 8 screenshot from Freebsd  From Cd Rom to Cloud

We’re ready to build. This instance has 32 vCPUs, so let’s take advantage of them and run a parallel build:

Step 9 screenshot from Freebsd  From Cd Rom to Cloud

While we wait for this to complete, ‘top’ is interesting to look at. All cores busy, 96% user time, 0.1% idle (instance store FTW). Perfect!

Step 4 screenshot from Freebsd  From Cd Rom to Cloud

And the result is…

Step 6 screenshot from Freebsd  From Cd Rom to Cloud

17 minutes. Back in the day, this would take 12+ hours on my high-end PC. I would leave it on all night, only to find out at breakfast that the goddamn build had failed in the middle of the night. And yes, that would ruin my day.

Now, thanks to Moore’s Law and to Cloud computing, I can get the same work done about 50 times faster. Ain’t life grand!

Of course, there would plenty more to explore — and maybe we’ll dive deeper in future stories — but that’s it for now. Thanks for reading.