Upgrading FreeBSD 9.1 to 9.2 with freebsd-update

By | February 15, 2014


Recommend running commands 1-5 at the bottom of this page prior to updating to avoid receiving errors¬†like “pkg: Warning: Major OS version upgrade detected. Running “pkg-static install -f pkg” recommended” thousands of times ūüôā

Upgrading Using ‚ÄúFreeBSD Update‚ÄĚ

The freebsd-update(8) utility supports binary upgrades of i386 and amd64 systems running earlier FreeBSD releases. Systems running 8.[34]-RELEASE, 9.[01]-RELEASE, 9.2-BETA[123], or 9.2-RC[1234] can upgrade as follows:

# freebsd-update fetch
# freebsd-update install

Now the freebsd-update(8) utility can fetch bits belonging to 9.2-RELEASE. During this process freebsd-update(8) will ask for help in merging configuration files.

# freebsd-update upgrade -r 9.2-RELEASE
# freebsd-update install

The system must now be rebooted with the newly installed kernel before the non-kernel components are updated.

# shutdown -r now

After rebooting, freebsd-update(8) needs to be run again to install the new userland components:

# freebsd-update install

Finally, reboot into 9.2-RELEASE

# shutdown -r now


If you get …

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.

... then ...

Using portmaster to do a complete reinstallation of all your ports

1. portmaster --list-origins > ~/installed-port-list-`date "+%Y-%m-%d-%H%M%S"`.txt
2. portsnap fetch update
3. portmaster -ty --clean-distfiles
4. portmaster --check-port-dbdir
5. portmaster -Faf
6. pkg delete -afy
7. rm -rf /usr/local/lib/compat/pkg
8. Back up any files in /usr/local you wish to save, such as configuration files in /usr/local/etc
# tar -zcvf ~/local-all.tar.gz /usr/local/
9. Manually check /usr/local and /var/db/pkg to make sure that they are really empty
# mv /usr/local/ /usr/local.bak
# mkdir /usr/local
10. Re-install portmaster
# cd /usr/ports/ports-mgmt/pkg && make install clean
# cd /usr/ports/ports-mgmt/portmaster/ && make install clean
11. Re-install previously installed ports
# portmaster --no-confirm -DG `cat ~/installed-port-list`

Explanation of above commands…

  1. Make a list of all the installed ports and save it in your home directory installed-port-list-*todays date *.txt
  2. Update ports tree
  3. -t recurse dependencies thoroughly, using all-depends-list. RECOMMENDED¬†FOR USE ONLY WHEN NEEDED, NOT ROUTINELY. When applied to the¬†–clean-distfiles option it allows a distfile to be kept if it¬†matches any up to date port, not just the ones that are installed.
  4. –check-port-dbdir¬†check for stale entries in /var/db/ports
  5. -F fetch distfiles only. -a check all ports, update as necessary. -f always rebuild ports
  6. Remove all packages,¬†don’t ask for confirmation


Getting your config files back…

1st attempt…

tar -zxvf local-all.tar.gz usr/local/etc
mv ~/usr/local/etc/openvpn /usr/local/etc/
mv ~/usr/local/etc/amavisd* /usr/local/etc/
mv ~/usr/local/etc/postfix/* /usr/local/etc/postfix/
mv ~/usr/local/etc/mail/spamassassin/* /usr/local/etc/mail/spamassassin/
mv ~/usr/local/etc/mail/* /usr/local/etc/mail/
mv ~/usr/local/etc/webmin /usr/local/etc/
mv ~/usr/local/etc/syslog-ng.conf /usr/local/etc/
mv ~/usr/local/etc/clam* /usr/local/etc/
mv ~/usr/local/etc/freshclam.conf /usr/local/etc/
mv ~/usr/local/etc/dovecot/* /usr/local/etc/dovecot/
mv ~/usr/local/etc/sqlgrey/* /usr/local/etc/sqlgrey/
mv ~/usr/local/etc/opendkim /usr/local/etc
mv ~/usr/local/etc/fail2ban/action.d/* /usr/local/etc/fail2ban/action.d/
mv ~/usr/local/etc/fail2ban/* /usr/local/etc/fail2ban/
mv ~/usr/local/etc/munin/* /usr/local/etc/munin/
mv ~/usr/local/etc/monit /usr/local/etc/
mv ~/usr/local/etc/monitrc /usr/local/etc/


2nd suggested attempt

Do this AFTER removing all packages, but BEFORE reinstalling them.. say step 9.5?

tar -zxvf local-all.tar.gz usr/local/etc

mv /usr/local/etc /usr/local/etc.orig

mv usr/local/etc /usr/local/etc

Then install packages…