FreeBSD src via subversion

I always forget the exact command and URL to get a copy of the FreeBSD source using subversion. So here it is, for my convenience and yours!

To get Release 11.1 (includes bugfix and security patches; keeps you at 11.1):

cd /usr
svnlite co svn:// src

To get Stable 11 (includes general updates; updates you to the latest 11.x):

cd /usr
svnlite co svn:// src

To get ports:

cd /usr
rm -r /usr/ports
svnlite co svn:// ports

Older versions of FreeBSD might not have svnlite in base. In that case install svn and use that instead.

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"

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!

Getting FreeBSD onto a flash chip


I am setting up two Soekris net5501 boxes to use as routers. After you install FreeBSD to a directory (I chose /usr/net5501) this is how to get that installation onto a flash chip.

In this example my flash chip shows up as /dev/da1

You get the count for sectors/unit (in my case 31227840) by:

# bsdlabel -Awn da1 auto

Okay – so the old Ultradesic tutorial I was following was having you make a “dangerously dedicated” disk. Also, I left out the -B in the bsdlabel command below because I assumed -b implied -B but I do not believe it does.

Let’s use slices instead (the standard way).  `mkdir /mnt/flash` or choose your own mount directory.

# dd if=/dev/zero of=/dev/da1 bs=1k count=1
# fdisk -BI da1
# bsdlabel -B -b /usr/net5501/boot/boot -w da1s1 auto
# bsdlabel -e da1s1 # Don't need to edit anything for our purposes here but this is where you would add slices
# newfs -U /dev/da1s1a # -U enables soft updates
# mount /dev/da1s1a /mnt/flash
# (cd /usr/net5501 ; tar cPf - .) | (cd /mnt/flash ; tar xf - );
# umount /mnt/flash