Tuesday, October 08, 2019

FreeBSD 12.0 Upgrade steps, because I'll forget.

This is pulled form https://www.freebsd.org/releases/12.0R/installation.html and the portmaster man page, an online version can be found here https://gsp.com/cgi-bin/man.cgi?topic=PORTMASTER

#Edited 10/09/19 with comments

#I'm not 100% sure why you do this first, but I guess its to make sure the system you're on is up to date before upgrading
freebsd-update fetch
freebsd-update install

#This part starts thea actual upgrade to 12.0 by fetching all the components needed for the upgraded
freebsd-update upgrade -r 12.0-RELEASE

#After fetching everything this does the actual install
freebsd-update install

#now we have to reboot into the newly installed system
shutdown -r now

#this finishes the first part of the upgrade
freebsd-update install

#now at this point you need to reinstall all the pkgs/ports to the new ABI
#I'm going to use portmaster to do this and this is more or less from their man page.
cd /root
portmaster --list-origins > ~/installed-port-list
#this is because we're going to install these manually
#screen is optional and only matters if you're going to use it
vi ~/installed-port-list #remove pkg, portmaster, and screen

#I don't know why I have to do this, but it made a bunch of errors go away so I'm adding it to the process
pkg bootstrap -f
portsnap fetch auto
portmaster -ty --clean-distfiles
portmaster -Faf
pkg delete -afy
rm -rf /usr/local/lib/compat/pkg

#the man page says to copy anything you need from /usr/local/etc so I just copied everything temporarily
mkdir /root/etc
cp -Rf /usr/local/etc/* /root/etc/

#I commented this out so you don't just copy and paste and run this like a moron
#Manually check /usr/local and /var/db/pkg to make sure that they are really empty
#cd /usr/local/
#ls
#rm -rf /usr/local/*
#cd /var/db/pkg
#ls
#rm -rf /var/db/pkg/*

#now we're going to reinstall pkg, portmaster and optionally, screen
cd /usr/ports/ports-mgmt/pkg
make install clean
cd /usr/ports/ports-mgmt/portmaster
make install clean
#now using screen is totally optional, but since I'm installing all the ports again I find it helpful in case I step away or fall asleep while they're compiling.
cd /usr/ports/sysutils/screen
make install clean

cd /root
screen

#so the -P says to use a pkg if one's available and you didn't need to customize the port install
#the -y answers yes to all prompts
#the --no-confirm doesn't ask the user to confirm the list of ports
#the -D doesn't clean the distfiles
#you can change these flags to your own needs just consult the man page
portmaster -P -y --no-confirm -D `cat ~/installed-port-list`

#in case you're not familiar with screen the main things you need to know are
#ctrl+a then d to leave session
#screen -r to rejoin session

#assuming your install went well you're supposed to do this one last time, again don't know why, but that's what they tell you to do
freebsd-update install

#now we're supposed to do one final reboot before using our system in production
shutdown -r now

#if you're using ZFS (and why wouldn't you be?) remember to do this
#you can probably do this earlier, but I forgot until I did a zpool status -v
zpool upgrade
Some of this can probably be changed, I don't know, but so far it has worked.

I don't have a clue

I'm so very tired. It's almost all the time now.