how to upgrade from FreeBSD 6.1 to 6.4-RELEASE
February 10th, 2010 (as amended)

Below is an abridged/tweaked version of the instructions found here: http://www.daemonology.net/blog/2007-11-10-freebsd-minor-version-upgrade.html

  1. Login as root (single-user mode not necessary)

    Note: this procedure may be performed via an SSH session - but if your sshd_config needs manual merge (see below), and you screw it up, this could be problematic.

    Warning: freebsd-update creates creates a work directory in /var/db/freebsd-update. This can get large (approx 800Mb as of December 2014). Ensure to have at least 1Gb of free space on /var before using freebsd-update. If this is not feasible, it's possible to change the location of the work directory.

  2. Stop services, auto-updates, and cronjobs:

  3. Prepare, and grab the freebsd-update tarball:
    mkdir /var/db/freebsd-update
    mkdir /usr/upgrade
    cd /usr/upgrade
    fetch http://www.daemonology.net/freebsd-update/freebsd-update-upgrade.tgz 
    fetch http://www.daemonology.net/freebsd-update/freebsd-update-upgrade.tgz.asc 
    gpg --verify freebsd-update-upgrade.tgz.asc freebsd-update-upgrade.tgz
    

    Check the signature - do not continue if the signature does not verify. GPG must be installed to do this.

  4. Extract the tarball, and start freebsd-update:
    tar -xf freebsd-update-upgrade.tgz
    sh freebsd-update.sh -f freebsd-update.conf -r 6.4-RELEASE upgrade
    

    Note the -r parameter - this determines the distribution to upgrade to. It must exactly match the name of the target distribution (as seen on the FreeBSD website).

  5. If the output from freebsd-update looks reasonable, press Y and Enter to continue. Diffs will be calculated, magic will be performed, and updates downloaded.

    If the merge needs manual assistance, you'll end up in vi. This will happen for each file requiring a manual merge. For each conflict in each file (there may be more than one conflict, and/or more than one file), the old and new versions are shown. The lines between the "<<<<<<< current version" line and the line consisting of "=======" are the existing lines in the file which are in conflict; the proposed replacement for these lines is below the ======= line. Delete everything except those lines you wish to keep. Delete the "current version" line, the ======= line, and the ending ">>>>>>> 6.4-RELEASE" line. Ensure to locate and resolve every conflict. Failing to remove the "current version" line and other bits will leave them in the file, which may or may not affect things, depending on the file.

    In the example below, the line "#VersionAddendum FreeBSD-20050903" is in conflict with the line "#VersionAddendum FreeBSD-20061110":

    <<<<<<<  current version
    #VersionAddendum FreeBSD-20050903
    =======
    #VersionAddendum FreeBSD-20061110
    >>>>>>> 6.4-RELEASE
    

    To resolve this conflict, delete everything except the correct line:

    #VersionAddendum FreeBSD-20061110
    
  6. Confirm the changes for each configuration file that will be altered. Press Y and Enter to do this.
     
  7. Install kernel updates (don't skip the reboot):
    sh freebsd-update.sh -f freebsd-update.conf install
    reboot
    
  8. Login as root, then install userland updates:
    cd /usr/upgrade
    sh freebsd-update.sh -f freebsd-update.conf install
    

    If a message appears, "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 "freebsd-update.sh install" again to finish installing updates.", then do the following:

    cd /usr/ports/ports-mgmt/portupgrade
    make deinstall
    make install clean
    rehash
    portupgrade -af
    cd /usr/upgrade
    sh freebsd-update.sh -f freebsd-update.conf install
    

    Note: if, during the portupgrade install, autoconf fails with the error "Excess arguments to built-in `_m4_popdef' ignored", the fix is to install GNU m4 manually, then re-run the portupgrade install. This fix from here.

    Examine carefully the summary generated at end by portupgrade - if any ports failed to rebuild, these must be reinstalled manually (the port probably will no longer operate correctly).

    See also the portupgrade docs.

  9. Reboot (don't skip this):
    reboot
    
  10. Check all services are working, following the last reboot - they can fail to start due to incorrectly-merged config files, library issues, or other wierdness

Notes: