Building FreeBSD from Source

I'm not at all familiarabou building FreeBSD from source although I may have tried it once or twice over the last ten years, but I think I would like to become more familiar with the process and am trying to follow a guide:-


Does this guide look like something I should follow? Is there anything missing or assumed?
 
It's been a while since I did this, but that looks about right. If you're on ZFS, make sure to get a snapshot before installing anything. Don't go too crazy with optimization flags the first time you do it, you can always make customization on future runs, once you've had success.

The handbook has this as well and from what I can tell it's the same.
 
Looks good enough. It assumes a native reinstall. Use make installworld DESTDIR=<dir> to put everything somewhere else and not touch the host installation.
 
Doesn't the Handbook cover this?
At one time it was considered a right of passage to build from source.
It does. I'm not sure why OP is going with that page as the handbook page is the same information from what I can tell and probably easier to follow. I haven't personally bothered recompiling things in quite a while,, so I didn't realize that mergemaster is gone now.
 
Does this guide look like something I should follow?
Definitively not. First "buildworld", then "buildkernel" (not the other way around), to provide up-to-date tools to build the kernel.

The correct order to build from source is described in the FreeBSD handbook, chapter 26.6. Updating FreeBSD from Source. See also build(7), and src.conf(5), for source build options.

Furthermore, have a look at /usr/src/UPDATING, "COMMON ITEMS:"at the end of the file.

Take note of:
Code:
        General Notes
        -------------
        Sometimes, obscure build problems are the result of environment
        poisoning.  This can happen because the make utility reads its
        environment when searching for values for global variables.  To run
        your build attempts in an "environmental clean room", prefix all make
        commands with 'env -i '.  See the env(1) manual page for more details.
Pay also attention of the other notes.

You will also find examples of various use cases for compiling from source code.
 
Please read 'COMMON ITEMS: General Notes' in /usr/src/UPDATING.
If you are trying to build FreeBSD 9.0 i386, see the source from that time.
Edit: I think there was a warning before I posted that there was a new post, but it wasn't displayed.
 
Please read 'COMMON ITEMS: General Notes' in /usr/src/UPDATING.
If you are trying to build FreeBSD 9.0 i386, see the source from that time.
Edit: I think there was a warning before I posted that there was a new post, but it wasn't displayed.
Actually, my eventual aim is to try and build every release of FreeBSD.

At the end of this project, I may figure out how to build v1.0.
 
It's been a while since I did this, but that looks about right. If you're on ZFS, make sure to get a snapshot before installing anything. Don't go too crazy with optimization flags the first time you do it, you can always make customization on future runs, once you've had success.

The handbook has this as well and from what I can tell it's the same.
One of the problems I find with The Handbook, is that you never really know if it is uptodate with the the latest release.

FreeBSD has been around since 1993, that's 33 years, so there will be thousands of guides and you never really know if you have the most uptodate version.
 
I wouldn't use information I find from third-party sites for FreeBSD unless I was completely out of other options.

A lot of information is out of date and sometimes written by users who primarily use Linux or other UNIX systems. Sometimes they unknowingly bring their habits from that system where it might not be appropriate for FreeBSD.

Regarding whether the Handbook and official documentation is out of date, if it is, then you can be certain other resources will be as well.

If your goal is to build FreeBSD systems back to 1.x, you're going to need the Handbooks anyway.
 
Hi balanga!

Both the Handbook and Wisellama's post were helpful when I started self-compiling FreeBSD a few months ago.

A simple step to save potential trouble when self-compiling might be to use a separate machine that can be easily wiped and reinstalled, if needed, after problems occur. In other words, don't rebuild on your daily driver machine with all your important files.

Here are two tiny scripts which seem to have been working to self-compile FreeBSD on a remote machine. On a remote machine one idea is to use `nohup` to get a transcript of the terminal output and to allow the process to continue in case of disconnection.

Another idea is to use `tmux`. The terminal output can be followed as it is generated by detaching from tmux (Ctrl-b, d) and running `tail -f nohup.out` in the terminal.

With two separate connections, the first can start the nohup process and the second can watch the output.

From this thread I realized that I was skipping the EFI bootloader steps, so I have to add them. Surely there are several additional mistakes here! That's okay, it's just for fun, but hints would be greatly appreciated!

Thanks!

Tom

Code:
root@ultra:/usr/src # date
Wed Feb 11 04:57:08 UTC 2026
root@ultra:/usr/src # cat build-tm-1.sh 
#!/bin/sh

set -e
set -x

cd /usr/src

nohup date

nohup cat -n build-tm-1.sh

nohup echo nohup git pull
nohup git pull
nohup echo nohup ls -l UPDATING
nohup ls -l UPDATING 
nohup echo nohup make -j 20 cleanworld cleankernel
nohup make -j 20 cleanworld cleankernel
nohup echo nohup make -j 20 buildworld buildkernel installkernel
nohup make -j 20 buildworld buildkernel installkernel
nohup echo nohup shutdown -r now
nohup date
nohup shutdown -r now

root@ultra:/usr/src # cat build-tm-2.sh
#!/bin/sh

set -e
set -x

nohup cat -n build-tm-2.sh

nohup echo etcupdate -p
nohup etcupdate -p
nohup echo nohup make -j 20 installworld
nohup make -j 20 installworld
nohup echo nohup etcupdate -B
nohup etcupdate -B
nohup echo make -j 20 check-old
nohup make -j 20 check-old
nohup echo make -j 20 delete-old
nohup make -j 20 delete-old
nohup echo make delete-old-libs
nohup make delete-old-libs # Manual "y"es required.
root@ultra:/usr/src # # Reboot again; rebuild ports; reboot a third time.
 
that looks legit, but if the handbook is out-of-date that's a bug in the handbook and should be fixed
I'm setting up a FreeBSD on a spare laptop for the last few days, I can confirm there are a few things that are out of sync in the documentation. For example, the bsdinstall part on selecting components is missing a screen where you are to choose if you want to go with sets or individual packages (I can't remember the name used for "individual packages", but it was non obvious for someone not already knowing what we're talking about), I was left to wonder what those two options meant and had to query other sources (Gemini was greatly helpful to understand this, for the record).

I'm going to make several other installs in the coming year. Now that I have a bit of a better understanding of the basics, I'll make PRs on the docs for those when I see them.
 
I wouldn't use information I find from third-party sites for FreeBSD unless I was completely out of other options.
Sometimes somebody's personal perspective explains things in a different way which is easier to follow than a guide provided by The Handbook. I often find a blog a useful supplement to official guides when I don't understand them or when certain assumptions are made but not explained.
 
Sometimes somebody's personal perspective explains things in a different way which is easier to follow
This is true but individuals are more likely to show personal opinion than technical correctness and contain errors or information that's more outdated cause they never go back and update anything. At least the Handbook is overseen on some regular basis by people in the know and on the inside. I was tripped up more than once by following some well known blog instead of the Handbook and this forum.

What I'm saying is, follow the Handbook as the official source. If you get confused, ask questions here or Google/AI for answers but don't trust and definitely verify.
 
I'm going to make several other installs in the coming year. Now that I have a bit of a better understanding of the basics, I'll make PRs on the docs for those when I see them.

Building and installing are different topics. I've installed FreeBSD many times and now have developed my own method which consists of using Ventoy.

Ventoy itself needs two partitions. The second one which stores all the Ventoy system files only takes up 32M. The first partition is where you keep all the ISOs IMGs etc which you can boot from with the help of Ventoy. FreeBSD ISOs can be booted from without problem. If you have a spare 100GB disk you can leave 10GB for Ventoy and you are free use the remainder to create as many GPT partitions as you want. What I have learnt is that I can boot FreeBSD from the ISO and create a partition (5GB is sufficient) and the simply extract base and kernel txz onto that partition and then you can boot from that partition without any initial configuration. You will get a mountroot prompt because the installation does not have a /etc/fstab, so you have to remember which partition you created, eg ufs:/dev/ada0p3 but you should be able to get up and running without too much trouble. To be able to do this you need to create a ventoy_grup.cfg which is a basic grub menu for launching any OS which you have previously installed.

This may sound complicated, but once you have it mastered, installing a new Freebsd system literally takes seconds and does not need any manual intervention.
 
Does this guide look like something I should follow? Is there anything missing or assumed?
there is an excellent thread where you'll find some very informative answers:

If I can give you an advice, if possible take advantages of ZFS boot environment, especially after a make buildworld make buildkernel, in case of failure you don't want to recompile this again.
If you don't know where to start:
1.) take notes from what the Handbook says.
2.) read also the guide provided by T-Daemon from the thread above.
3.) write your own notes.

Personally I am not a compile guy, so after lurking here and there gathering information, I finally managed to upgrade from source a VM from 13.5 to 14.3 to 15.0.
So the rite of passage is accomplished, I am officially a daemon now 👿
While I've used freebsd-update since the beginning of my adventure with FreeBSD I suppose it's good to know also how to proceed with source, I imagine that in some cases it might be usefull.
 
Code:
mergemaster -Ui

Personally I am not a compile guy, so after lurking here and there gathering information, I finally managed to upgrade from source a VM from 13.5 to 14.3 to 15.0.
So the rite of passage is accomplished, I am officially a daemon now 👿
While I've used freebsd-update since the beginning of my adventure with FreeBSD I suppose it's good to know also how to proceed with source, I imagine that in some cases it might be usefull.

Hi gotnull!

Congrats on accomplishing your adventure upgrading from source and becoming a daemon! 👿

Please see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252417#c20 (mergemaster removed; replaced by etcupdate).

Going forward, it looks like we will need to use etcupdate instead of mergemaster.

Always best wishes!

Tom
 
Back
Top