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!

Getting FreeBSD onto a flash chip

DRAFT

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

 

References:

http://www.freebsd.org/cgi/man.cgi?query=bsdlabel&sektion=8

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/boot-blocks.html

http://webfolder.wirelessleiden.nl/www.ultradesic.com/index06ef-2.html?section=125

Which package does this file belong to?

Need to know where a library or other file came from? Here are some I’ve used:

Redhat/SUSE/Fedora

# rpm -qf /path/to/file

 

Ubuntu/Debian

apt-file search /path/to/file

You may need to install by doing this (as root):

# apt-get install apt-file
# apt-file update

 

FreeBSD
If you are using the new pkgng:

pkg which /path/to/file

or if you are still using the old pkg_ tools:

# pkg_info -W /path/to/file

 

Gentoo / Funtoo

# equery belongs /path/to/file

 

Your distribution not included here? Usually you can just do a web search for something like “redhat which file package belong” without quotes to find it for a particular distro.