Topic: Upgrading a release of NetBSD

I've recently seen slight confusion about how to upgrade NetBSD, so here's a guide on the commands you need to issue and in what order. I have given you an estimate of buildtimes, based upon my workstation - 1.3Ghz, 384MB RAM running nothing but the base system and the build commands.

The first step is to download the src you want. I'll assume you have no current src tree, if you do, you can just delete it. In this example, I'm using csh and will be downloading NetBSD 3.0:

# cd /usr
# env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot co -r netbsd-3 -P src

Next, we need to create some important folders else the build will fail:

# mkdir /usr/obj
# mkdir /usr/tools

NetBSD's build design allows gcc to be upgraded at the same time as a the rest of the system. It does this by first building all the tools required to build the rest of the OS, including gcc, released with the downloaded src. To build the tools, use this command:

# cd /usr/src
# ./build.sh -O ../obj -T ../tools -U -u tools

This took about 18 minutes. The next step is to build the userland. This is done with the following command:

# ./build.sh  -O ../obj -T ../tools -U -u distribution

This took about 2hrs 20 minutes. With the userland successfully built, we next build the kernel. I always recommend building GENERIC and using this before trying to build a custom version - this identifies whether the problem is with GENERIC or your custom file. We build GENERIC with:

# ./build.sh  -O ../obj -T ../tools -U -u kernel=GENERIC

This took 18 minutes. We now need to install the new kernel to boot into it. We do this with the following commands (replacing <ARCH> with your architecture, eg. i386):

# cd ../obj/sys/arch/<ARCH>/compile/GENERIC
# cp /netbsd /netbsd.old
# cp netbsd /netbsd

Now, reboot into the new kernel. Once reboot, we install the built world:

# cd /usr/src
# ./build.sh -O ../obj -T ../tools -U install=/

This took only a few minutes. There will be a message displayed onscreen regarding a command "postinstall" look for this and run the command given. For NetBSD 3.0 it was this:

# /usr/src/usr.sbin/postinstall/postinstall -s /usr/src -d // fix defaults gid makedev mtree named pam periodic postfix rc ssh x11 uid obsolete

Next we build our tmp etc with the following command:

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

Finally, we need to update etc itself. This is done using etcupdate. A file and it's etc differences are shown, if you wish to install the new file type "i" and if you don't type "d". To merge a file, you are show the differences side-by-side, simply issue "l" for the left side or "r" for the right side to use that half in the merged file.

A rule of thumb I use for etcupdate is "If I haven't heard of it, I probably haven't updated/touched it - so install the new version" - The exception is the passwd database, entries that need to be added here should be done using "vipw" after etcupdate.

To start etcupdate issue the following command, answering "yes" if you get asked to continue an aborted etcupdate. This occurs because etcupdate finds /tmp/tmproot which was created with the previous command:

# /usr/sbin/etcupdate

Now just reboot and you're done

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Upgrading a release of NetBSD

that's great Wintellect, the docs for updating NetBSD are pitiful.  I volunteered to update them if I had the time, but haven't really gotten around to it.

those are basically the same steps that my script executes.  one question though: why build the userland before building and installing the kernel?  it doesn't really make a difference, but I'd rather build and install a new kernel to make sure that works before building the userland.  just a thought smile.

Re: Upgrading a release of NetBSD

If you install and run a new kernel, you put things out of sync...

When you "build.sh tools" it uses the current kernel as a reference. if you were to build the kernel, install it and run it, when you came to build the userland, the tools would be deemed out dated and this would throw up issues (IIRC)

technically you can build the kernel then the userland - just don't install and run the kernel wink

BTW - all the info above is based upon "Tracking NetBSD-current" (http://www.netbsd.org/Documentation/current/) which can be found on the "Documentation" page, which is linked to on the main page under "Documentation and FAQs" smile

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

4

Re: Upgrading a release of NetBSD

Isn't it better to keep things out of sync for a while (just to see if the new kernel boots) and then install the userland? Otherwise if you have to revert to the old kernel you'd have and old kernel and a new userland...

Re: Upgrading a release of NetBSD

obviously no one is reading the page correctly.

It says:

Now, reboot into the new kernel. Once reboot, we install the built world

So, although you build everything before the reboot, you only "install" the new userland once you have reboot into the new kernel!!!

What you DON'T want to do is build the new kernel, reboot into it and then build the new userland!

Does that make more sense now? You build everything first, but install NOTHING until everything is built!

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Upgrading a release of NetBSD

makes sense, I'm just not sure you're right tongue.

I'll find the appropriate NetBSD mailing list and shoot them an e-mail right now.

Re: Upgrading a release of NetBSD

oh, and if you already have a src tree, and just want to update it, you can run

cd /usr/src
cvs update -r netbsd-3 -dP

Last edited by asemisldkfj (2005-12-27 00:44:43)

Re: Upgrading a release of NetBSD

I'd advise to run postinstall at least two times (had issues with PAM upgrade needing two steps).

I'm also a fan of build.sh release smile

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue

9

Re: Upgrading a release of NetBSD

WIntellect wrote:

obviously no one is reading the page correctly.

It says:

Now, reboot into the new kernel. Once reboot, we install the built world

So, although you build everything before the reboot, you only "install" the new userland once you have reboot into the new kernel!!!

What you DON'T want to do is build the new kernel, reboot into it and then build the new userland!

Does that make more sense now? You build everything first, but install NOTHING until everything is built!

That was what I said... or at least tried to say tongue

Re: Upgrading a release of NetBSD

ok, here's the official answer from the NetBSD lists:

> so over at bsdnexus forums, we're having a discussion about the proper
> order of the steps used to update an existing NetBSD system.
>
> http://forums.bsdnexus.com/viewtopic.php?id=678
>
> WIntellect claims that you should build tools, build distribution, build
> and install kernel, reboot, and install the userland.

Well, you should certainly install a new kernel before you install a
new userland, because the new userland might require the new kernel.

However, in build.sh land, the order in which some of this gets built
is more flexible than it used to be.

> as I've always understood it, you're supposed to build and install a new
> kernel before doing anything else, e.g. build tools, build and install
> kernel, reboot, build distribution, install the userland.

That's not necessary with build.sh -- you can build all the stuff and
then install it later.

> while both ways have always worked perfectly fine for me, and are only
> minutely different, to me it seems like a waste of time to run
> ./build.sh distribution before booting and testing a newly compiled
> kernel.  WIntellect however, told me that when you run ./build.sh tools,
> it uses your currently installed kernel as a reference,

As a reference for what? build.sh doesn't even care about what os it is
running on (it runs on things other than NetBSD). It pays no attention
to /netbsd, certainly.

> and if you built
> the distribution after installing a new kernel, the tools would be out
> of sync with the new kernel and could cause problems.

I have no idea what he means.

> so my question is, should you run ./build.sh distribution before or
> after building and installing a new kernel?

If you are building sets that you're going to install later, it makes
no difference. If you are installing in place during the build, you
obviously need the new kernel to be already installed or you'll get
into a bit of trouble if the new userland does new syscalls.

> and where could I find more
> info about building the tools?  there wasn't very much about it in
> /usr/src/BUILDING.

That's because it isn't terribly hard (or important -- if you don't
build the tools explicitly, build.sh in most cases just builds them
for you anyway.)

--
Perry E. Metzger                perry@piermont.com

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Upgrading a release of NetBSD

Well, you should certainly install a new kernel before you install a
new userland, because the new userland might require the new kernel

I also build and boot into the new kernel before installing the userland because rolling back to the old kernel is easy (if you have a problem) while rewinding userland isn't !

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue

Re: Upgrading a release of NetBSD

yeah, I think he meant to restart when he said "install", it wasn't very clear though.

13

Re: Upgrading a release of NetBSD

Great thanks WIntellect. I'll try that on another system today, my laptop just doesn't seem to like NetBSD but I'm happy with FreeBSD, now that I've fixed the battery status issue.