Make sure your existing ports are up to date
sudo portsnap fetch update
sudo portmaster -Da
Upgrade FreeBSD to 9.0
sudo freebsd-update upgrade -r 9.0-RELEASE
If all goes well then FreeBSD will start downloading the metapackages and files. If you are unlucky enough to see the error message:
The update metadata is correctly signed, but failed an integrity check. Cowardly refusing to proceed any further.
then the solution is to fix the error in freebsd-update package:
sed -i '' -e 's/=_/=%@_/' /usr/sbin/freebsd-update
This is recommended in the official release patch list and it is explained as:
...a minor change must be made to the freebsd-update code in order for it to accept file names appearing in FreeBSD 9.0 which contain the '%' and '@' characters; without this change, freebsd-update will error out with the message "The update metadata is correctly signed, but failed an integrity check".
After executing the above, run the freebsd-upgrade command again and everything will work.