Rebuilding world on FreeBSD

To upgrade FreeBSD between versions, I generally rebuild world with the latest sources. You can easily get the –RELEASE tarballs using fetch.
I generally remove the old /usr/obj and /usr/src completely before I start.

# cd /usr
# rm -R obj
# rm -R src
# fetch ""
# tar -x -C / -f src.txz

Obviously, for a different architecture or a different version, you’d use a different url.

Next we need to build world, build a new kernel, install the new kernel and then install the new world. There are some extra intermediate steps. This process is described very accurately in the FreeBSD Handbook, but it’s scattered all over the page. It’s also a highly interactive process, which annoys me (I don’t like pressing ‘yes’ repeatedly for no obvious reason). By now I’ve figured out the flags for each command so they’ll require the least amount of user intervention.

When there are no special circumstances, these should be the commands that get it all done with the lease amount of hassle:

# cd /usr/src
# make buildworld
# make buildkernel KERNCONF=GENERIC
# make installkernel KERNCONF=GENERIC
# reboot

After reboot, in the loading screen, indicate that you want to boot in single-user mode. After it has finished loading (it will ask you which shell to use, just use the default), continue with:

# mount -u /
# mount -a -t ufs
# swapon -a
# adjkerntz -i
# cd /usr/src
# mergemaster -piFU
# make installworld
# mergemaster -iFU
# make -DBATCH_DELETE_OLD_FILES delete-old
# reboot

This time, you can let FreeBSD boot normally. After the reboot, it’s generally wise to rebuild all your ports, to make sure they use the latest libraries:

# portmaster -af -dB --delete-build-only
# make -DBATCH_DELETE_OLD_FILES delete-old-libs

Note that the above commands are selected to make everything as automatic as possible. Mergemaster will only ask about files you have changed, and the make delete-old and delete-old-libs will assume you have no reason to keep old libraries.

I use portmaster to maintain my ports tree, and the above flags are once again set to minimize user interaction, as well as keeping the system clean of unneeded leaf ports.

Let me finish by stretching that this is an easy process, but can also be used to easily destroy your server. Don’t use the above commands unless you’re clear about their purpose! Usual disclaimers apply.

Final note: I generally use a bunch of tricks to speed up the build process, like storing /usr/obj and /usr/src on memory disks and using the –j flag for make. I’ll go deeper into those another time.

5th Company Dreadnoughts

I recently picked up an old hobby again: Warhammer. I own quite extensive forces for both Warhammer Fantasy and Warhammer 40k, but to my shame, appallingly little of that is painted. I’ve now set upon a quest to remedy that, and will try to post updates here on my progress, with pictures of my conversions […]

Images are back up

It recently came to my attention that a recent plugin update had broken all images on the website. It basically meant I had to go over everything I’ve ever written and fix the links. Thankfully, I don’t update often. Images should be back up now. If I’ve missed something, don’t hesitate to let me know.

Growing a ZFS pool — Update

In an earlier post I described how you can grow an existing ZFS pool by replacing all the disks with bigger ones. That article was written several years ago, for FreeBSD 7.2. Currently we’re at FreeBSD 9.2, and the ZFS implementation has evolved somewhat, making that article no longer accurate. Most importantly, this concerns the […]

Using GMirror as a rollback tool.

On Thunderflare, which predates affordable solid-state drives, the OS is run from two small laptop drives in RAID 1. The RAID 1 is there so that if one of them crashes, I won’t have to do a complete reinstall. I’m lazy, sue me. Besides, a reinstall would take a lot of time, while setting up […]

Machine army and Penelope timeline

I’ve updated the Machine Army page with a list of my current and past machines. I’ll expand this page further as I have the time. I’ve also published the full upgrade timeline for Penelope, my main workstation.

SSH connections without a password

One of the basic ways of connecting to a FreeBSD server is through a secure shell, commonly referred to as ssh. The most basic usage of an ssh connection is to give you a full-fledged command prompt on the remote machine. However, the ssh connection can also be used as a tunnel for countless other things, […]


Once again, I’d like to wish all my readers (there’s more than one, right?) a very happy new year. My resolution is to keep using this place as a drop-off for stuff I need to store outside my own head.

Hitman Absolution

Rant power: Activated! I just finished playing Hitman Absolution, the latest installment in the Hitman series. I’ve been a big fan of the series since the beginning, and eagerly pre-ordered it when it was announced. I must say that after the first few missions, I was disappointed, but now that I’ve finished it all the […]

Expanding a ZFS pool

In an earlier post, I explained how it was possible to grow a ZFS pool by replacing all disks one-by-one. In that post, I also mentioned that if you have enough spare connectors available, you can easily expand the pool by adding another array of disks. A while back, I had replaced a bunch of older […]