Chapter 32. Updating an existing system from sources

Table of Contents

32.1. The updating procedure
32.1.1. Building a new userland
32.1.2. Building a new kernel
32.1.3. Installing the kernel and userland
32.1.4. Updating the system configuration files
32.1.5. Summary
32.1.6. Alternative: using sysinst
32.2. More details about the updating of configuration and startup files
32.2.1. Using etcupdate with source files
32.2.2. Using etcupdate with binary distribution sets
32.2.3. Using etcmanage instead of etcupdate

Note

Please remember to check src/UPDATING for the latest changes.

If you are running a stable NetBSD release (such as NetBSD 4.0), in a production environment, you should occasionally update your sources and rebuild the system or the kernel, in order to incorporate any security fixes that have been applied to the branch since its release.

Note

The update process is the same for NetBSD-current, therefore the following steps apply to -current systems as well.

Most of the following steps can be done as ordinary user. Only the installation of a new kernel and the userland will require root privileges. Although /usr is choosen as the working directory in the following examples, the procedure can also take place in a user's home directory. Ordinary users have normally not the permissions to make changes in /usr, but this can be changed by root.

Having up-to-date sources is a prerequisite for the following steps. Section 29.4, “Fetching by CVS” informs about the ways to retrieve or update the sources for a release, stable or current branch (using CVS).

Please always refer to the output of build.sh -h and the files UPDATING> and BUILDING for details - it's worth it, there are many options that can be set on the command line or in /etc/mk.conf

32.1. The updating procedure

32.1.1. Building a new userland

The first step is to build the userland:

$ cd /usr/src
$  ./build.sh -U distribution

32.1.2. Building a new kernel

The next step will build the kernel:

$ cd /usr/src
$ ./build.sh -O ../obj -T ../tools kernel=<KERNEL>
     

32.1.3. Installing the kernel and userland

Installing the new kernel, rebooting (to ensure that the new kernel works) and installing the new userland are the final steps of the updating procedure:

$ cd /usr/src
$ su
# mv /netbsd /netbsd.old
# mv /usr/obj/sys/arch/<ARCH>/compile/<KERNEL>/netbsd /
# shutdown -r now
 ...
$ cd /usr/src
$ su
#  ./build.sh -O ../obj -T ../tools -U install=/

If the new kernel netbsd does not boot successfully, you can fall back on booting the netbsd.old kernel.

32.1.4. Updating the system configuration files

Run the etcupdate script (etcupdate(8)) and follow the instructions in the output for fixing obsolete files:

# /usr/sbin/etcupdate -s /usr/src

Optionally reboot to ensure all running services are using the new binaries:

# shutdown -r now

32.1.5. Summary

  1. From the root of the source tree:

    $ cd /usr/src
  2. Build the userland:

    $ ./build.sh  -O ../obj -T ../tools -U -u distribution
  3. Build the kernel:

    $ ./build.sh  -O ../obj -T ../tools -U -u kernel=GENERIC
  4. Install the kernel:

    $ cd ../obj/sys/arch/<ARCH>/compile/GENERIC
    $ su
    # mv /netbsd /netbsd.old
    # cp netbsd /netbsd
  5. Reboot into the new kernel:

    # shutdown -r now
  6. Install the new userland:

    $ cd /usr/src
    $ su
    # ./build.sh -O ../obj -T ../tools -U install=/
  7. Update the system and configuration files;:

    #  /usr/sbin/etcupdate -s /usr/src

Note

In the procedure above, the -u option indicates an update process, and that a make clean operation should not be run before starting the build. This is useful when doing an update from a previous build and/or a fresh build. The -U option allows the entire build by a non-root user followed with an install by root.

32.1.6. Alternative: using sysinst

It is also possible to use sysinst to install a freshly built system. The steps are as follows:

  1. Build a complete release:

    $ ./build.sh  -O ../obj -T ../tools -U -u -x release

  2. The resulting install sets wil be in the /usr/obj/releasedir/ directory.

  3. Copy the install kernel to the root directory of your NetBSD system, reboot from it, and upgrade with sysinst (see Chapter 4, Upgrading NetBSD ).

32.2. More details about the updating of configuration and startup files

etcupdate is a script to help users compare, merge and install new configuration and startup files (files found in the etc.tgz distribution set) in /dev, /etc and /root after performing an operating system upgrade. The upgrade of the operating system could have been performed either by compiling sources or by extracting the distribution binaries.

32.2.1. Using etcupdate with source files

In case where the sources are in /usr/src the following command should be enough:

# etcupdate

But what if your NetBSD sources are in an alternative location, such as in /home/jdoe/netbsd/src? Don't worry, tell etcupdate the location of your source tree with -s srcdir and it will work just fine:

# etcupdate -s /home/jdoe/netbsd/src

32.2.2. Using etcupdate with binary distribution sets

Sometimes it's not possible have the sources around but you still want to update the configuration and startup files. The solution is to extract the desired distribution files (at least etc.tgz) and use the -b srcdir switch to tell etcupdate that we don't have the sources but only the official distribution sets.

# mkdir /tmp/temproot
# cd /tmp/temproot
# tar xpzf /some/where/etc.tgz
# etcupdate -s /tmp/temproot

32.2.3. Using etcmanage instead of etcupdate

The etcmanage perl script (available from pkgsrc/sysutils/etcmanage or as binary package) is an alternative to etcupdate. It should be used in the following way, in combination with postinstall(8):

# /usr/pkg/bin/etcmanage
# /usr/sbin/postinstall