2Apr il 2003, 17:00:47 The Complete FreeBSD (upgrading.mm), page 585
32
Updating the system
software
In this chapter:
• Upgrading ker nel and
user land
• Upgrading the ker nel
• Upgrading the boot
files
• Upgrading the
configuration files
• Merging /etc/group
• Mergemaster,
second time around
In this chapter:
• Upgrading ker nel and
user land
• Upgrading the ker nel
• Upgrading the boot
files
• Upgrading the
configuration files
• Merging /etc/group
• Mergemaster,
second time around
In the previous chapter,welooked at howtoget an up-to-date FreeBSD source tree.
Once you have the sources, you can build various components of the system. The main
tool we use for this purpose is make,which we looked at on page 167. The best way to
think of upgrading the system is that everything is a matter of changing files. Forthe
purposes of this discussion, you can divide the files on your system into the following
/bin Executable programs of general use. makeworld
/boot Files used when booting the system. makeinstall in /usr/src/sys.
/dev Directory of device nodes. System startup (devfs)
/etc Configuration files used at system startup. Install from CD-ROM only,
mergemaster,administrator
/sbin System executables needed at system
startup time.
makeworld
/usr/X11R6 The X11 windowing system. X-based programs in the
Ports Collection
/usr/bin Standard executable programs that are not
needed at system start.
makeworld
/usr/compat Adirectory containing code for emulated
systems, such as Linux.
Ports Collection
/usr/games Games. makeworld
/usr/include Header files for programmers. makeworld
/usr/lib Library files. makeworld
/usr/libexec Executable files that are not started direct-
ly by the user.
makeworld
/usr/libdata Miscellaneous files used by system utili-
ties.
makeworld
/usr/local Additional programs that are not part of
the operating system.
Ports collection
/usr/obj Temporary object files created when
building the system.
• It builds the rest of the system, with the exception of the kernel and the boot tools.
• It installs everything. You can omit this stage by building the buildworld target
instead of world.
It does this by building a number of subtargets. Occasionally,you might find it useful to
build them individually: makeworld can pose a chicken-and-egg problem. It creates the
userland, and makekernel makes the kernel. Userland and kernel belong together,and if
you upgrade the userland first, you may find that the newuserland takes advantage of
differences in the newer version of the kernel. A typical situation is when a newsystem
call is added to the kernel. In this case, you may find processes exiting with a signal 12
(invalid system call). If this happens, you may have toperform the upgrade with the
sequence:
# make buildworld
# make kernel
(reboot)
# make installworld
upgrading.mm,v v4.5 (2003/04/02 04:49:48)
Upgrading ker nel and userland 588
2April 2003, 17:00:47 The Complete FreeBSD (upgrading.mm), page 588
You’ll find information about such requirements in the file /usr/src/UPDATING.Table
32-2 givesanoverviewofthe more useful targets to the top-level Makefile.
Table 32-2: Targets for top-level Makefile
Target Purpose
buildworld Rebuild everything, including glue to help do upgrades.
installworld Install everything built by buildworld.
world Perform buildworld and installworld.
update Update your source tree.
most Build user commands, no libraries or include files.
installmost Install user commands, but not libraries or include files.
reinstall If you have a build server,you can NFS mount the source and object
directories and do a make reinstall on the client to install new
date of each program in the directories. Forexample, if you see:
$ ls -lrt /usr/sbin
-r-xr-xr-x 1 root wheel 397 Jul 14 11:36 svr4
-r-xr-xr-x 1 root wheel 422 Jul 14 11:29 linux
-r-xr-xr-x 1 root wheel 142080 Jul 13 17:20 sshd
...
-r-xr-xr-x 1 root wheel 68148 Jul 13 17:16 uuchk
-r-xr-xr-x 1 root wheel 6840 Jan 52002 ispppcontrol
-r-xr-xr-x 1 root wheel 27996 Apr 21 2001 k5stash
-r-xr-xr-x 1 root wheel 45356 Apr 21 2001 ktutil
-r-xr-xr-x 1 root wheel 11124 Apr 21 2001 kdb_util
-r-xr-xr-x 1 root wheel 6768 Apr 21 2001 kdb_init
It’sfairly clear that the files dated April 2001 have not just been installed, so theymust be
out of date. Youcan use a number of techniques to delete them; one might be:
# find . -mtime +10 | xargs rm
This command removesall files in the current directory (.)that are older than 10 days
(+10). Of course, this method will only work if you haven’tinstalled anything in these
directories yourself. Youshouldn’thav e done so; that’sthe purpose of the directory
hierarchy /usr/local,toensure that you keep system files apart from ports and private
files.
Be careful with /usr/lib:anumber of ports refer to libraries in this directory hierarchy,
and if you delete them, the ports will no longer work. In general there’snoproblem with
old libraries in /usr/lib,unless theytakeuptoo much space, so you’re safer if you don’t
clean out this directory hierarchy.
Note that you need to specify the KERNCONF parameter to all the targets relating to kernel
builds.
Upgrading the kernel
There are tworeasons for building a newkernel: it might be part of the upgrade process,
which is what we’ll look at here, or you may build a kernel from your current sources to
add functionality to the system. We’lllook at this aspect in Chapter 33.