Hello everyone. Welcome to my setup for using FreeBSD as a desktop operating system with Nvidia graphics.
Let me begin by saying that unless you are looking to get into software development or systems administration, there isn’t any real benefit to using FreeBSD as a desktop over something like Linux or MacOS. There are a few “out of the box” features that I think make FreeBSD more ideal than a Linux operating system. I will discuss these during the installation and setup process as they arrive.
The installation process is very straightforward. When installing FreeBSD on bare metal, I prefer the .img download. When installing on a virtual machine, I will use the dvd.iso – Slight disclaimer for those that are looking to play with it in a VM, you’ll probably have an easier time with the .iso variants.
Upon booting the installation medium, you’re greeted by the coolest mascot/logo in OS history:
Let the time run out, which will select
1. Boot Multi user [Enter] by default, or press Enter. If you want to read the other options or explore a bit, press spacebar (or any other key).
At this point the
bsdinstall command runs.
Install is your best option.
Note, I have experienced some issue with Corsair keyboards being recognized. The K30 works fine on my system but the K70 does not. Your experience may vary.
The default keymap has always been correct during my installations. But, feel free to select yours if this isn’t the case.
Note, Test default keymap is useful if you want to verify the option you have selected is in fact identical to your keyboard.
Next, you’ll give a hostname to your computer. Pretty standard stuff, try and use something original to your network and avoid using weird characters and underscores.
You can also borrow from my creative genius when it comes to naming convention. Press Enter to continue.
Choosing optional system components is strictly based on user preference. If you plan on doing some development or contributing to the FreeBSD project, I recommend selecting all of the options. Use the arrow keys to move and spacebar to select entries. I would leave the defaults checked.
Pressing Enter at any time will move the installation forward.
Once you arrive at partitioning, you are now upon the precipice of what makes FreeBSD great: Native ZFS.
ZFS is a high performing file system initially developed at Sun Microsystems. The FreeBSD handbook describes three major benefits to using ZFS:
Taken here. What does this mean for you?
- Even with a failing hard drive, your data will remain intact.
- Ease of creating and tagging storage partitions.
- Very high performing read/write/mirror/striping.
The caveat to this is MEMORY. ZFS has a very high overhead, meaning it consumes a lot of resources, RAM in this case.
I am going to select ZFS for this installation, a pool type of stripe (since I only have 1 disk, definitely choose based on your use case. Stripe: data is spread across all disks in the array/pool. Mirror: data is the same across all disks in the array/pool. Plus variations, depending on the quantity of disks will have some for mirror and some for striping), and a 4GB swap size. I change the default swap from 2 to 4 at the recommendation of Michael Warren Lucas, infamous FreeBSD sysadmin, developer, and writer. 4GB is enough to hold a kernel dump.
Press Enter over Select, confirm your pool type, and press spacebar to select your disk. Use the arrow and spacebar to select multiple disks.
Confirm writing to disk(s).
Note, for experienced Linux users, look at the difference in naming scheme. My disk is da0.
After the disks are partitioned, the system will begin installing.
Once the system is installed, you will be tasked with setting a password for the root user.
Note, the password will not show up as *'s or any other symbol. Your keyboard is working just fine, if you’ve made it this far.
Select your network interface. Depending on what you’re using this computer for, you may not want a DHCP lease. If you are assigning a static IP, be sure to use the arrow keys to move down to subnet and gateway and not Tab or Enter.
I am using DHCP for IPv4 and IPv6. If you have a modern router, you should enable IPv6.
After the IP, subnet, and gateway information is configured, it’s time to setup your DNS information. Mine has auto-populated, but if yours does not, do not leave the Search blank! You can name it
no.search if you want but do not keep it blank, you may experience network issues.
Selecting the network time comes next. You may receive a warning about keeping the time at UTC or if you are not sure the message will tell you to select “No”. Select your country and timezone.
Note, you can press the number coinciding with your state multiple times if it is a higher ten. United States is 49, so I press 4 several times to arrive there.
After that, confirm the calendar date and time. Stop! For some reason the default highlight is set to skip. Be sure to left arrow over to actually set the date and time.
Next are the services starting at boot. I select
dumpdev. This is more of a preference. I’ve heard
powerd is useful if you’re running FreeBSD on a laptop.
Next is hardening the system. This, in my opinion, is where FreeBSD holds a benefit over Linux. No system is secure out of the box, but FreeBSD attempts to proactively protect the system during the installation compared to most Linux systems having you do this post-installation. I select every option.
Obviously change this based on your use case. My recommendation is enable them all by default and then learn the system by disabling the options that conflict what a service you may need later. Learn by breaking!
After hardening, you have the option to create additional users. I always create a user that is part of the
operator groups (more on that, later).
I change the shell to
tcsh. It’s grown on me, and
sh is kind of boring.
After adding users, you’ll have the option to make last minute changes. Or, you can just exit the installer and reboot.
Now that you have rebooted your fresh installation, let’s go ahead and login with the additional user you made.
Depending on how you’ve logged in, you may or may not receive a “message of the day” or “motd”. Your standard user will have limited privileges, so let’s
su into root.
Note, I always recommend using an escalation command rather than running everything as a root user. This comes recommended as a best practice by several professionals in the industry. However, on a fresh system, it may be necessary or useful to work as the root user until the system is configured.
Once at the root user, install some packages to get your system working. The FreeBSD package manager is
pkg. If you’re familiar with Linux, the
pkg command comes with several commands as a Linux package manager:
pkg install pkg remove pkg search man pkg
All of the above work when using or learning about
pkg. I want to install
sudo, so I don’t have to run everything as root,
vim, for a better editor, and
git, because I plan on doing some software development and prefer using
git for version control.
You’ll notice on first executing the pkg command, FreeBSD cannot find it, but it will offer to install it for you. After the installation of pkg, the rest of the packages you specified will be installed as well.
A note on doas, arguments, and ports
Some people prefer
doas instead of
sudo. I’ve read arguments for both, but don’t understand the controversy or fanboy attitude about either. Both do a great job, in my opinion. Use what you’re comfortable with. You can learn more about
If you have experience with Linux, you may run various arguments with your package manager or other applications. FreeBSD follows the Unix conventions. So, for example, if you want to automatically say “yes” to the “are you sure you want to install these packages” question, the
-y will go before the list of packages, not after.
sudo apt install openjdk vim git -y
sudo pkg install -y openjdk vim git
The order matters, in FreeBSD.
sudo pkg install openjdk vim git -y will not work.
FreeBSD has a Ports Collection with the package
portsnap. This is a way of having the source code for tools and utilities locally. Since I am not experienced enough to contribute back, I am not very familiar with this nor do I use this method. I much prefer using the package manager. However, if this is something you are interested, or if you prefer reviewing the source and compiling your own packages, you can learn more about this here. The Ports Collection is outside the scope of this write up.
Back to Post-Install
Remember when I added my user to the
wheel group and I said we’ll review this later? Well, the time is now!
sudo installed, enter
You are now in the sudoers file. Here we can add users and groups to have full or limited super user access.
If you’re not familiar with
vim, I’ll give you a quick cheat sheet:
l (lowercase L) - move one space right
h - move one space left
j - move one line down
k - move one line up
/ - search (Searching for “wheel” you would type /, type “wheel” (no quotes or spaces), and press Enter)
:w! - write to the file (include the colon( and exclamation point(!))
:q! - quit (include the colon( and exclamation point(!))
:wq - write to the file and quit (no exclamation point needed)
i - insert mode (from here, you can use the keyboard as you would in a word processor)
Esc - command mode (the mode when you first entered the file)
gg - go to the top of the file
G - go to the end of the file
A - append to the end of the current line
Note, “write to the file” is just a fancy phrase for “save”.
Let’s search for “wheel” in the sudoers file by entering a / and typing the word wheel. Press Enter. You can press the n key to move down to the next result of the search. Look for the lines:
## Uncomment to allow members of group wheel to execute any command # %wheel ALL=(ALL) ALL
You want to remove the comment (# symbol) from the second line. As an exercise, try to find out how to do this without using the backspace or delete keys while in insert mode. My answer will be below. Don’t worry if you mess something up, just quit the file with :q! and enter
The x key in command mode will remove the currently highlighted character.
After the edit, the lines should look like this
## Uncomment to allow members of group wheel to execute any command %wheel ALL=(ALL) ALL
Save the file with :wq (don’t forget to press escape if you’re in insert mode)
Congrats! Now the next time a user part of the wheel group logs in, they will have sudo permissions.
We’re almost to the good part, hang tight!
We need to edit our
/etc/fstab file to have some fancy kernel magic happen at boot.
proc is what’s known as a pseudo-filesystem and it’s used to interface with data structures in the kernel. This means that some of your commands with the system will not work without
You can use vim to edit the file.
This is what my file looks like after my changes:
The additions I made were as follows:
proc /proc procfs rw 0 0
You can use Tab to space over to the appropriate areas.
Save the file with :wq
Now, it’s time to get the graphics setup.
Xorg and your favorite desktop environment (DE) are necessary. Plus, we’ll need a login manager. I am going to use KDE for the DE and SDDM for the login manager. They’re both simple, fully functional on FreeBSD, and easy to use for most people.
pkg install -y xorg
This may take awhile depending on your network connection speeds.
Once Xorg is installed, go ahead and install the login manager and DE.
Note, during this write up, I experienced a mismatch size in a package, and the package would not install. I had not experienced this in the past, but if this happens to you, run
pkg update -f and attempt installing the packages again. This should clear it up. If not, let me know, and I may have another suggestion.
pkg install -y sddm x11/kde5
This is another “may take a while depending on network speeds” disclaimer. We’re almost there!
Now it’s time to install Nvidia. First, we need to load Linux binary compatibility, which is required to install and run Nvidia drivers.
kldload linux pkg install x11/nvidia-driver x11/nvidia-settings x11/nvidia-xconfig
The above command and three packages will get everything installed for you. Now it’s time to configure these to start at boot.
We need to edit the
/etc/rc.conf file. The rc.conf file is the FreeBSD systems configuration file. Everything that starts after the bootloader and kernel is setup in this file.
We need to add our libraries for Linux and Nvidia, D-Bus, and our login manager.
This is what I’ve added to the end of my
dbus_enable="YES" sddm_enable="YES" kld_list="linux64 linux nvidia nvidia-modeset"
linux64 likely isn’t required, but if you plan on experimenting with other packages or gaming, I would keep it on.
Save the file with :wq
Now, we want to have Xorg ready.
You may get a long, bizarre output, but that’s normal. Change into your root directory and you should see the xorg.conf.new file:
Move that into /usr/local/etc/X11/xorg.conf.d/xorg.conf
mv xorg.conf.new /usr/local/etc/X11/xorg.conf.d/xorg.conf
Now, reboot, and you should be greeted by a fancy GUI!
shutdown -r now
I only have one monitor displaying.
Xorg -configure while in the GUI and move the new file to
I have screen tearing
nvidia-settings as sudo and change your Advanced Settings under X Server Display Configuration to Force Full Pipeline Composition. When you save the file, save it as
/usr/local/etc/X11/xorg.conf.d/nvidia.conf This DOES NOT replace xorg.conf, they work together!.
Congratulations. You have installed one of the better, cleaner Unix operating systems. You are ready to tackle the most challenging system, network, and software engineering challenges. Something to consider is that FreeBSD has regular updates. You can check for this by running
freebsd-update fetch as sudo. If you have updates, run
freebsd-update install as sudo and your system will be patched.
Let me know if you run into any issues, have questions, or would like more content like this. Thanks for reading!