Upgrading FreeBSD is very easy. Thanks for the simple architecture design and the disconnection between the kernel and the applications (ports), the whole process takes around 15 to 45 minutes. The coolest thing is that the system down time is very short. In my case, the down time was only about 3 minutes.
This table will help you to estimate the whole process and system down time:
Action | Down Time? | Approximate Duration |
Download the update files | None | 5 to 15 minutes |
Installing the update | None | 5 to 15 minutes |
Helping FreeBSD to set up the system configurations | None | 1 to 3 minutes |
Reboot | Yes | 1 to 3 minutes |
Installing the update | None | 1 to 2 minutes |
Reboot (Optional) | Yes | 1 to 3 minutes |
Notice that this tutorial only works for i386 or amd64. For other CPU architectures such as Sparc, you will either reinstall the whole thing or rebuild the whole world (i.e., make buildworld). One way or the other, that’s a very time-consuming process.
First, I am assuming that your FreeBSD is up-to-date in your current version. You can do it by running the following command:
First, make sure that your ports are up to date.
#Download the latest ports sudo portsnap fetch update #Upgrade the old ports: sudo portmaster -Da
Next, we want to upgrade the FreeBSD. Currently, the latest version is 9.1:
sudo freebsd-update upgrade -r 9.1-RELEASE
FreeBSD will try to download files for you. Just say yes.
Looking up update.FreeBSD.org mirrors... 4 mirrors found. Fetching metadata signature for 8.2-RELEASE from update5.FreeBSD.org... done. Fetching metadata index... done. Fetching 1 metadata files... done. Inspecting system... done. The following components of FreeBSD seem to be installed: kernel/generic world/base world/manpages The following components of FreeBSD do not seem to be installed: src/base src/bin src/cddl src/contrib src/crypto src/etc src/games src/gnu src/include src/krb5 src/lib src/libexec src/release src/rescue src/sbin src/secure src/share src/sys src/tools src/ubin src/usbin world/catpages world/dict world/doc world/games world/info world/lib32 world/proflibs Does this look reasonable (y/n)? y
Next, it will download the patches. Depending on your internet connection speed, it may take 1 to 10 minutes:
... Applying patches... done. Fetching 1962 files... done. Attempting to automatically merge changes in files... done.
Now, FreeBSD will try to check whether your configuration is compatible with the new version or not. It may need your help to merge the configuration files manually. Notice that it uses VI, a standard (and very old, not really user-friendly) editor in Unix. If you’ve never used vi before, here are some simple commands:
#By default, a document is opened in read-only mode. To switch to a wrote mode: i #To set the mode to read only Press the ESC key #Delete a character x #Delete the whole line dd #Save a file :w #To quite vi :q #To save and quite :wq
After some file editing, FreeBSD will give you a summary of what files will be changed. Just hit either ESC or q to end the list.
... /usr/share/man/man3/lwres_addr_parse.3.gz /usr/share/man/man3/lwres_buffer.3.gz /usr/share/man/man3/lwres_buffer_add.3.gz /usr/share/man/man3/lwres_buffer_back.3.gz /usr/share/man/man3/lwres_buffer_clear.3.gz /usr/share/man/man3/lwres_buffer_first.3.gz /usr/share/man/man3/lwres_buffer_forward.3.gz /usr/share/man/man3/lwres_buffer_getmem.3.gz
At this point, FreeBSD finish the upgrade plan. (It hasn’t made any change to your system.) Now we need to give a green light to FreeBSD to start upgrade the system.
sudo freebsd-update install
...Please reboot and run "/usr/sbin/freebsd-update install" again to finish installing updates.
After the reboot, run the command again to update the userland components:
sudo freebsd-update install
Installing updates... Completing this upgrade requires removing old shared object files. Please rebuild all installed 3rd party software (e.g., programs installed from the ports tree) and then run "/usr/sbin/freebsd-update install" again to finish installing updates.
Reboot the computer again to finish the upgrade.
sudo reboot
Now, we need to upgrade all of the ports. Notice that this step is optional. You don’t need to do it unless you found any problem after the upgrade.
#Upgrade all the installed ports sudo portmaster -fa
Reboot the computer again to finish the upgrade.
sudo reboot
Make sure that FreeBSD is running on the latest version:
# uname -a FreeBSD 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec 4 09:23:10 UTC 2012 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64
Have fun with FreeBSD.
–Derrick
Our sponsors: