Tải bản đầy đủ (.pdf) (14 trang)

Tài liệu Chapter-32-Updating the system software pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (137.75 KB, 14 trang )

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


categories:
• The userland,that part of the system software that is not the kernel. Unlikesome
other operating systems, FreeBSD expects to keep userland and kernel at the same
release level. We’ll look at the interaction between kernel and userland below.
• The kernel. You may build a newkernel without updating the sources, of course, if
you want to add functionality to the kernel. In this chapter we’ll look at upgrading
the kernel in the context of a complete system upgrade. We’llconsider building a
custom kernel in the next chapter,Chapter 33, Custom kernels.
• Support for booting the machine, which is currently performed as a separate step.
• Configuration files relating to your system. Some of them, such as /etc/fstab and
/etc/rc.conf,overlap with the previous category.
• The Ports Collection. This doesn’thav e to be done at the same time as userland and
kernel, though if you upgrade to a significant newversion of FreeBSD, it’sagood
idea to upgrade the ports as well. We looked at upgrading ports on page 178.
upgrading.mm,v v4.5 (2003/04/02 04:49:48) 585
The Complete FreeBSD 586
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 586
• Your own files. Theyhav e nothing to do with a software upgrade.
Youcan makeupgrading less onerous by planning in advance. Here are some
suggestions:
• Keep system files and user files on different file systems.
• Keep careful records of which configuration files you change, for example with RCS,
the Revision Control System.This provestobethe most complicated part of the
entire upgrade process.
The only files that are upgraded are on the traditional root file system and /usr.Noothers
are affected by an upgrade. Table 32-1, an abridged version of Table 10-2 on page 188,
givesanoverviewofwhere the system files come from.
Table 32-1: FreeBSD directory hierarchy
directory
name Usage Populated by

/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.

makeworld
/usr/ports The Ports Collection. sysinstall, cvs
/usr/sbin System administration programs that are
not needed at system startup.
makeworld
upgrading.mm,v v4.5 (2003/04/02 04:49:48)
587 Chapter 32: Updating the system software
2April 2003, 17:00:47 The Complete FreeBSD (upgrading.mm), page 587
directory
name Usage Populated by
/usr/share Miscellaneous read-only files, mainly in-
formative.
makeworld
/usr/src System source files. sysinstall, cvs
Upgrading kernel and userland
The core part of a system upgrade consists of a synchronized update of both kernel and
userland. It’srelatively simple to do, but depending on the speed of the machine, it may
keep the computer busy for several hours. In general, you build and install the userland
first, then you build and install the kernel.
The traditional way to build the userland is:
# cd /usr/src
# make world
This operation performs a number of functions, which can be influenced by variables you
pass to make.Without anyvariables, makeworld performs the following steps:
• It removesthe old build directories and creates newones. You can skip this step by
setting the NOCLEAN variable. Don’tset NOCLEAN unless you knowexactly whyyou
are doing so, since it can cause inconsistencies that come back to bite you later.In
particular,ifyou do have problems after building the world in this manner,you
should first go back and perform a complete rebuild without NOCLEAN.
• It rebuilds and installs build tools, including make,the C compiler and the libraries.

• 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

binaries from the most recent build on the server.
buildkernel Build a kernel for your architecture. By default, use the GENERIC
kernel configuration file. Youcan select a different configuration
file, say MYKERNEL,with:
# make buildkernel KERNCONF=MYKERNEL
By default, this target builds all the KLDs (Kernel Loadable
Modules), which significantly increases the time it takes. If you
knowthat your KLDs will not change, or that you won’tbeusing
any, you can skip building them by specifying the -DNO_MODULES
flag.
installkernel Install a kernel you have built with buildkernel.
reinstallkernel Install a kernel you have built with buildkernel.Don’trename
the previous kernel directory to kernel.old.Use this target when the
previous kernel is not worth keeping.
kernel Build and install a kernel.
Another issue is that the system configuration might have changed. For example, in early
2002 the default configuration for sendmail changed. The process added a daemon user
and group, both called smmsp.Toinstall the userland, this user already needed to be
present.
upgrading.mm,v v4.5 (2003/04/02 04:49:48)
589 Chapter 32: Updating the system software
2April 2003, 17:00:47 The Complete FreeBSD (upgrading.mm), page 589
The solution to this issue is called mergemaster,ascript that helps you to upgrade the
configuration files. We’lllook at it in more detail below, but at this point you should
knowthat you need to run it with the -p (pre-build)option:
# mergemaster -p
As we’ve seen in table 32-1, the installworld target changes a number of directories.
Sometimes, though, it leavesold binaries behind: it doesn’tremove anything that it
doesn’treplace. The result can be that you end up using old programs that have long
passed their use-by date. One solution to this problem is to look at the last modification

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.

One point to notice is that if you’re upgrading from an older custom configuration file,
upgrading.mm,v v4.5 (2003/04/02 04:49:48)

×