<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="generator" content="Website XSL Stylesheet V2.6.0">
<link rel="home" href="../." title="Welcome to The NetBSD Project: Of course it runs NetBSD.">
<link rel="up" href="../docs/." title="NetBSD Documentation">
<link rel="previous" href="../docs/software/." title="Application Software for NetBSD">
<link rel="next" href="../docs/vmware.html" title="NetBSD Documentation: Running VMWare on NetBSD">
<link rel="first" href="../docs/Hardware/." title="Hardware Documentation">
<link rel="last" href="../docs/x/." title="NetBSD Documentation: The X Window System">
<link rel="stylesheet" href="../global.css" type="text/css">
<title>Updating a stable NetBSD release</title>
</head>
<body class="website"><div class="webpage">
<a name="docs-updating"></a><div id="top"><a href="#mainContent" class="doNotDisplay doNotPrint">Skip to main content.</a></div>
<div id="header">
<div class="topNavigation">
<span>» </span><a href="../docs/guide/en/">
The Guide</a> |
<a href="http://man.NetBSD.org/">Manual pages</a> |
<a href="../mailinglists/">
Mailing lists</a> and
<a href="http://mail-index.NetBSD.org/">Archives</a> |
<a href="http://cvsweb.NetBSD.org/">CVS repository</a> |
<a href="http://www.NetBSD.org/cgi-bin/sendpr.cgi?gndb=netbsd">Report</a>
or
<a href="../support/query-pr.html">
query</a> a bug |
<a href="../docs/software/packages.html">
Software Packages
</a>
</div>
<div class="centralHeader">
<a href="../"><img alt="[NetBSD Logo]" width="506" height="90" src="../images/NetBSD-headerlogo.png"></a><div class="headerTools"><div id="headerSearch"><form method="get" action="http://www.google.com/custom">
<input class="whiteOnBlack" type="text" name="q" onfocus="if(this.value==this.defaultValue ) this.value='';" size="12" maxlength="255" value="Search"><input type="hidden" name="cof" value="L:http://www.NetBSD.org/images/NetBSD-smaller.png;LH:200;LW:200;AH:center;AWFID:4f6b0499f0f58d2c;"><input type="hidden" name="domains" value="NetBSD.org"><input type="hidden" name="sitesearch" value="www.NetBSD.org"><input type="submit" value="Search">
</form></div></div>
</div>
<div class="navBar">
<span class="doNotDisplay">
Navigation:
</span><a href="../">
Home</a> ü <a href="../about/">
About</a> ü <a href="../gallery/">
Gallery</a> ü <a href="../releases/">
Download</a> ü <a href="../docs/">
Documentation</a> ü <a href="../support/">
Support</a> ü <a href="../community/">
Community</a> ü <a href="../ports/">
Ports</a>
</div>
</div>
<div id="content"><div class="fullWidth"><div class="rowOfBoxes">
<h1>Updating a stable NetBSD release</h1>
<h3 class="title"><a name="top"></a></h3>
<ul>
<li><a href="#current">Tracking -current</a></li>
<li><a href="#update-src">Updating the sources</a></li>
<li><a href="#tools">Building the tools</a></li>
<li><a href="#kernel">Building a new kernel</a></li>
<li><a href="#userland">Building a new userland</a></li>
<li><a href="#installing">Installing the kernel and userland</a></li>
<li><a href="#parts">Updating only parts of the source tree</a></li>
<li><a href="#summary">Terse summary of an updating procedure</a></li>
</ul>
<hr>
<h3 class="title"></h3>
<h4 class="title">
<a name="current"></a>Tracking -current (<a href="#top">top</a>)
</h4>
<p>
See
<a class="ulink" href="current/" target="_top">this document</a>
for our documentation on how to track NetBSD-current.
</p>
<h4 class="title">
<a name="update-src"></a>Updating the sources (<a href="#top">top</a>)
</h4>
<p>
If you are running a stable NetBSD release (such as
<a class="ulink" href="../releases/formal-3/" target="_top">NetBSD 3.1</a>),
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.
</p>
<p>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 <code class="filename">/usr</code> 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 <code class="filename">/usr</code>,
but this can be changed by root. </p>
<p>
You can retrieve or update the sources for your
release using
<a class="ulink" href="current/#using-anoncvs-over-ssh" target="_top">anoncvs over
ssh</a>
by specifying the correct branch tag. For example, to
checkout the sources for the NetBSD 3.1 release, you
could use:
</p>
<pre class="programlisting">
$ cd /usr
$ export CVS_RSH=ssh
$ cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot co -r netbsd-3-1 -P src</pre>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
Be sure to take care in selecting the correct and desired branch tag so
you don't accidently <span class="emphasis"><em>downgrade</em></span> your source tree.
</div>
<p>To update an existing source tree, do:</p>
<pre class="programlisting">
$ cd /usr/src
$ export CVS_RSH=ssh
$ cvs update -dP</pre>
<h4 class="title">
<a name="tools"></a>Building the tools (<a href="#top">top</a>)
</h4>
<p>The next step is to build the toolchain. You need to
create an <code class="filename">obj/</code> and a <code class="filename">tools/</code>
directory, followed by a run of <span class="command"><strong>build.sh</strong></span>:</p>
<pre class="programlisting">
$ mkdir /usr/obj /usr/tools
$ cd /usr/src
$ ./build.sh -O /usr/obj -T /usr/tools -U -u tools</pre>
<h4 class="title">
<a name="kernel"></a>Building a new kernel (<a href="#top">top</a>)
</h4>
<p>
Building a new kernel pretty much follows the steps
as described in
<a class="ulink" href="kernel/#how_to_build_a_kernel" target="_top">this
document</a>.
</p>
<p>The steps to build the kernel are:</p>
<pre class="programlisting">
$ cd /usr/src
$ ./build.sh -O ../obj -T ../tools kernel=<KERNEL>
</pre>
<h4 class="title">
<a name="userland"></a>Building a new userland (<a href="#top">top</a>)
</h4>
<p>
Please always refer to <code class="code">build.sh -h</code> and the
files <span class="emphasis"><em>UPDATING</em></span> and
<span class="emphasis"><em>BUILDING</em></span> for details - it's worth
it, there are <span class="emphasis"><em>many</em></span> options that can
be set on the command line or in
<code class="filename">/etc/mk.conf</code>.
</p>
<p>The build the userland, do:</p>
<pre class="programlisting">
$ ./build.sh -O ../obj -T ../tools -U distribution</pre>
<h4 class="title">
<a name="installing"></a>Installing the kernel and userland (<a href="#top">top</a>)
</h4>
<p>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:</p>
<pre class="programlisting">
$ 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=/ </pre>
<p>If the new kernel <code class="filename">netbsd</code> does not boot
successfully, you can fall back on booting the
<code class="filename">netbsd.old</code> kernel.</p>
<h4 class="title">
<a name="parts"></a>Updating only parts of the source tree (<a href="#top">top</a>)
</h4>
<p>
If a security advisory has been issued, and you want
to just rebuild the necessary libraries and applications,
your best bet is to follow the instructions provided in the
advisory. An example is given below:
</p>
<pre class="programlisting">
$ cd src
$ export CVS_RSH=ssh cvs update -d -P -r netbsd-3-1 gnu/dist/sendmail/sendmail
$ cd gnu/usr.sbin/sendmail
$ make USETOOLS=no cleandir dependall
$ su
# make USETOOLS=no install</pre>
<h4 class="title">
<a name="summary"></a>Terse summary of an updating procedure (<a href="#top">top</a>)
</h4>
<div class="itemizedlist"><ul type="disc">
<li>
<p>Updating the sources:</p>
<pre class="programlisting">
$ cd /usr/src
$ export CVS_RSH=ssh
$ cvs update -dP</pre>
</li>
<li>
<p>Building the new kernel and userland:</p>
<pre class="programlisting">
$ cd /usr/src
$ ./build.sh -O ../obj -T ../tools tools
$ ./build.sh -O ../obj -T ../tools kernel=<KERNEL>
$ ./build.sh -O ../obj -T ../tools -U distribution</pre>
</li>
<li>
<p>Installing the new kernel and userland:</p>
<pre class="programlisting">
$ 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=/ </pre>
</li>
</ul></div>
</div></div></div>
<div class="navfoot"></div>
<div id="footer"><div id="footerContent"><center>
<span class="footfeed"><a href="http://www.NetBSD.org/cgi-bin/feedback.cgi">
Contact</a> |
</span><span class="footcopy"><a href="../about/disclaimer.html">
Disclaimer</a> |
<span class="copyright">Copyright 1994-2010 The NetBSD Foundation, Inc. </span>ALL RIGHTS RESERVED.<br>NetBSD<sup>/sup> is a registered trademark of The NetBSD
Foundation, Inc.</span>
</center></div></div>
</div></body>
</html>