Updating FreeBSD in One Line

..and get an E-mail when it is done!

Okay, so you’ll see more than one line of code but here but the main thing is the single line with the make commands. As long as you are in /usr/src and run that you will probably be okay. Everything else is just recommended.

This is how I currently update world on FreeBSD. I recommend that you start a screen session before doing this. Let’s name our session “updating.”

screen -S updating

If you do not have screen I recommend installing it:

cd /usr/ports/sysutils/screen/
make install clean

If you haven’t updated the svn of the src, now is a good time to do it. If you have never downloaded src, here is how you check out a src repo for FreeBSD.

Now, let’s check the UPDATING file:

less /usr/src/UPDATING

Check for any important news there first (the first couple entries should be enough if you’ve updated recently but you can always check your current patchlevel first with a uname -a).

Go to the src directory and check if anything needs to be updated it /etc before we update by running mergemaster with the -p flag. Often you can skip this step, especially if it is only a minor update.

cd /usr/src
mergemaster -p

Then let’s rebuild and install everything in one line. Use your e-mail address instead at the end:

make -j4 buildworld && echo bw-done && \
make -j4 kernel && echo bkik-done && \
make -j4 installworld && echo iw-done && \
echo "install world done" | mail -s "iw done on $HOSTNAME" myemail@domain.com

It will start running with text streaming by.
If you ran screen at the beginning type Ctrl+a and then type d to disconnect from the session.
I like this because I start it in a screen session and immediately detach.
Once I get the e-mail (or if it has been a while and I haven’t received anything) I reconnect.

When you want to reconnect to check on it or after it is done do:

screen -r updating

Once done if everything looks like it ran fine do this:

mergemaster -iFU

If you want to save some space after you are done

rm -r /usr/obj

Restart the machine and you should be updated!

One thought on “Updating FreeBSD in One Line

  1. Also, every once in a while you might end up with a situation that the bmake program in /usr/obj is messed up (you get a core dump). And it won’t let you even do a “make clean” on the /usr/src.
    In this case just do the:
    rm -r /usr/obj
    And then do what you need to.

Leave a Reply

Your email address will not be published. Required fields are marked *

To see if you are a human *

This site uses Akismet to reduce spam. Learn how your comment data is processed.