One of the best thing in NetBSD world is that is so well written that I'm still using same upgrade process as I was using in time when 1.6 was released.

And now I will use it again to upgrade machine on which this blog sits from 8.0 to 9.0 from 9.0 sources. Lets get started!

I will use CVS via SSH to fetch stable branch of 9.0

# export CVSROOT="anoncvs@anoncvs.de.NetBSD.org:/cvsroot
# export CVS_RSH="ssh"
Setting up CVS

Going to /usr and fetching source files. You can download any branch, and you can browse available branches on CVSWeb. You have to accept key from cvs server. Key from anoncvs.netbsd.org is already in your base system, but this server is in USA and its slow for EU users.

# cd /usr
# cvs checkout -r netbsd-9-0-RELEASE -P src
The authenticity of host 'anoncvs.de.netbsd.org (195.22.142.120)' can't be established.
ECDSA key fingerprint is SHA256:5Qzg5/4OqKeStnPAVRJ8/MvPD7jXsDgjU2fEnoCNsxc.
No matching host key fingerprint found in DNS.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'anoncvs.de.netbsd.org,195.22.142.120' (ECDSA) to the list of known hosts.
cvs checkout: Updating src
U src/BUILDING
U src/Makefile

[... SNIP ...]

cvs checkout: Updating src/x11/tools/rgb
cvs checkout: Updating src/x11/tools/ucs2any
cvs checkout: Updating src/x11/tools/xkbcomp
Downloading sources

You can check what version you have downloaded by going to /usr/src/sys/conf/ and running osrelease.sh script

# cd /usr/src/sys/conf/
# sh osrelease.sh
9.0
Version check

Now we need to make four directories that we use to build kernel and system

# mkdir 9.0 obj tools

Then we go to /usr/src and use build.sh script to build tools

# cd /usr/src/
# ./build.sh -T /usr/tools/ tools
===> build.sh command:    ./build.sh -T /usr/tools/ tools
===> build.sh started:    Thu Jun 18 12:30:07 CEST 2020
===> NetBSD version:      9.0
===> MACHINE:             amd64
===> MACHINE_ARCH:        x86_64
===> Build platform:      NetBSD 8.0_STABLE amd64
===> HOST_SH:             /bin/sh
===> No $TOOLDIR/bin/nbmake, needs building.
===> Bootstrapping nbmake
checking for sh... /bin/sh
checking for gcc... cc
checking for C compiler default output...

[... SNIP ...]

mkdir -p /usr/tools/bin
/usr/tools/bin/x86_64--netbsd-install -c  -r -m 555 config /usr/tools/bin/nbconfig
===> Tools built to /usr/tools
===> build.sh ended:      Thu Jun 18 12:54:20 CEST 2020
===> Summary of results:
         build.sh command:    ./build.sh -T /usr/tools/ tools
         build.sh started:    Thu Jun 18 12:30:07 CEST 2020
         NetBSD version:      9.0
         MACHINE:             amd64
         MACHINE_ARCH:        x86_64
         Build platform:      NetBSD 8.0_STABLE amd64
         HOST_SH:             /bin/sh
         No $TOOLDIR/bin/nbmake, needs building.
         Bootstrapping nbmake
         MAKECONF file:       /etc/mk.conf
         TOOLDIR path:        /usr/tools
         DESTDIR path:        /usr/src/obj/destdir.amd64
         RELEASEDIR path:     /usr/src/obj/releasedir
         Created /usr/tools/bin/nbmake
         Updated makewrapper: /usr/tools/bin/nbmake-amd64
         Tools built to /usr/tools
         build.sh ended:      Thu Jun 18 12:54:20 CEST 2020
===> .
#
Building tools

Then we can build a system

./build.sh -D /usr/9.0 -O /usr/obj -T /usr/tools -u build

[...SNIP...]

Build started at:  Thu Jun 18 14:05:23 CEST 2020
Build finished at: Thu Jun 18 19:00:48 CEST 2020
===> Successful make build
===> build.sh ended:      Thu Jun 18 19:00:48 CEST 2020
===> Summary of results:
         build.sh command:    ./build.sh -D /usr/9.0/ -O /usr/obj/ -T /usr/tools/ -u build
         build.sh started:    Thu Jun 18 14:05:22 CEST 2020
         NetBSD version:      9.0
         MACHINE:             amd64
         MACHINE_ARCH:        x86_64
         Build platform:      NetBSD 8.0_STABLE amd64
         HOST_SH:             /bin/sh
         MAKECONF file:       /etc/mk.conf
         TOOLDIR path:        /usr/tools
         DESTDIR path:        /usr/9.0
         RELEASEDIR path:     /usr/obj/releasedir
         Updated makewrapper: /usr/tools/bin/nbmake-amd64
         Successful make build
         build.sh ended:      Thu Jun 18 19:00:48 CEST 2020
===> .
#
Building the system

Finally we can build a kernel. I will build DOMU kernel as I'm using Xen as hypervisor. Same process can be used for building GENERIC or any other kernel.

./build.sh -O /usr/obj -T /usr/tools -u kernel=XEN3_DOMU

[...SNIP...]

NetBSD 9.0 (XEN3_DOMU) #0: Fri Jun 19 08:09:22 CEST 2020
   text    data     bss     dec     hex filename
4405052  203952 1626112 6235116  5f23ec netbsd
===> Kernels built from XEN3_DOMU:
  /usr/obj/sys/arch/amd64/compile/XEN3_DOMU/netbsd
===> build.sh ended:      Fri Jun 19 08:09:24 CEST 2020
===> Summary of results:
         build.sh command:    ./build.sh -O /usr/obj -T /usr/tools -u kernel=XEN3_DOMU
         build.sh started:    Fri Jun 19 08:03:46 CEST 2020
         NetBSD version:      9.0
         MACHINE:             amd64
         MACHINE_ARCH:        x86_64
         Build platform:      NetBSD 8.0_STABLE amd64
         HOST_SH:             /bin/sh
         MAKECONF file:       /etc/mk.conf
         TOOLDIR path:        /usr/tools
         DESTDIR path:        /usr/obj/destdir.amd64
         RELEASEDIR path:     /usr/obj/releasedir
         Updated makewrapper: /usr/tools/bin/nbmake-amd64
         Building kernel without building new tools
         Building kernel:     XEN3_DOMU
         Build directory:     /usr/obj/sys/arch/amd64/compile/XEN3_DOMU
         Kernels built from XEN3_DOMU:
          /usr/obj/sys/arch/amd64/compile/XEN3_DOMU/netbsd
         build.sh ended:      Fri Jun 19 08:09:24 CEST 2020
===> .
Building the kernel

Now we just need to switch kernel and reboot, keeping old kernel just in case.

# mv /netbsd /netbsd80
# cp /usr/obj/sys/arch/amd64/compile/XEN3_DOMU/netbsd /
# shutdown -r now

You can always go back in case of failure by typying boot netbsd80 in boot manager. But most likely system will boot with new kernel.

NetBSD 9.0 (XEN3_DOMU) #0: Fri Jun 19 08:09:22 CEST 2020

If so, now we can install built system. Again from /usr/src with build.sh

# cd /usr/src/
# ./build.sh -D /usr/9.0 -O /usr/obj -T /usr/tools -u install=/

[...SNIP...]

   ================================
make installworld started at:  Fri Jun 19 08:22:08 CEST 2020
make installworld finished at: Fri Jun 19 08:33:50 CEST 2020
===> Successful installworld to /
===> build.sh ended:      Fri Jun 19 08:33:50 CEST 2020
===> Summary of results:
         build.sh command:    ./build.sh -D /usr/9.0 -O /usr/obj -T /usr/tools -u install=/
         build.sh started:    Fri Jun 19 08:22:08 CEST 2020
         NetBSD version:      9.0
         MACHINE:             amd64
         MACHINE_ARCH:        x86_64
         Build platform:      NetBSD 9.0 amd64
         HOST_SH:             /bin/sh
         MAKECONF file:       /etc/mk.conf
         TOOLDIR path:        /usr/tools
         DESTDIR path:        /usr/9.0
         RELEASEDIR path:     /usr/obj/releasedir
         Updated makewrapper: /usr/tools/bin/nbmake-amd64
         Successful installworld to /
         build.sh ended:      Fri Jun 19 08:33:50 CEST 2020
===> .

Now it is time to do etcupdate, and upgrade is complete. Basically, run etcupdate, install all missing files, merge all files that was altered by you and have some new content.

File: /etc/autofs/include_nis_nullfs (missing)

Please select one of the following operations:

  d  Don't install the missing file
  i  Install the missing file
  v  Show the missing file

What do you want to do? [Leave it for later]i
EXAMPLE - Install missing files
--- /etc/bluetooth/btattach.conf        2017-03-11 19:45:44.000000000 +0100
+++ /tmp/temproot/etc/bluetooth/btattach.conf   2020-06-19 08:36:12.145546069 +0200
@@ -1,4 +1,4 @@
-#      $NetBSD: btattach.conf,v 1.1 2008/04/15 11:17:47 plunky Exp $
+#      $NetBSD: btattach.conf,v 1.3 2017/08/12 11:45:20 jmcneill Exp $
 #
 # Bluetooth serial devices configuration.
 #
@@ -10,3 +10,6 @@

 #btuart                /dev/tty00      115200
 #digi          /dev/tty01      57600
+
+# Raspberry Pi 3 Bluetooth UART
+#bcm43xx-3wire /dev/dplcom0    921600          -FPi 115200

File: /etc/bluetooth/btattach.conf (modified)

Please select one of the following operations:

  d  Don't install the new file (keep your old file)
  i  Install the new file (overwrites your local modifications!)
  m  Merge the currently installed and new files
  s  Show the differences between the currently installed and new files
  su  Show differences in unified format ("diff -u")
  sc  Show differences in context format ("diff -c")
  ss  Show differences side by side ("sdiff -w157")
  scommand Show differences using the specified diff-like command
  v  Show the new file

What do you want to do? [Leave it for later] i
EXAMPLE - Install exisiting files with new content if you didn't alter it by hand
--- /etc/master.passwd  2019-03-14 13:51:17.677648046 +0100
+++ /tmp/temproot/etc/master.passwd     2020-06-19 08:36:08.881950055 +0200
@@ -1,4 +1,4 @@
-root:SNIPPED:0:0::0:0:Charlie &:/root:/bin/ksh
+root::0:0::0:0:Charlie &:/root:/bin/sh
 toor:*:0:0::0:0:Bourne-again Superuser:/root:/bin/sh
 daemon:*:1:1::0:0:The devil himself:/:/sbin/nologin
 operator:*:2:5::0:0:System &:/usr/guest/operator:/sbin/nologin
@@ -23,8 +23,3 @@
 _nsd:*:33:33::0:0:& pseudo-user:/var/chroot/nsd:/sbin/nologin
 uucp:*:66:1::0:0:UNIX-to-UNIX Copy:/nonexistent:/sbin/nologin
 nobody:*:32767:39::0:0:Unprivileged user:/nonexistent:/sbin/nologin
-SNIPPED:SNIPPED:1000:100::0:0::/usr/home/SNIPPED:/bin/ksh
-www:*************:1002:1000::0:0:apache www user:/nonexistent:/sbin/nologin
-mysql:*************:1003:1001::0:0:MySQL database administrator:/var/mysql:/bin/sh
-zabbix:*************:1004:1002::0:0:Zabbix user:/nonexistent:/sbin/nologin

File: /etc/master.passwd (modified)

Please select one of the following operations:

  d  Don't install the new file (keep your old file)
  i  Install the new file (overwrites your local modifications!)
  m  Merge the currently installed and new files
  s  Show the differences between the currently installed and new files
  su  Show differences in unified format ("diff -u")
  sc  Show differences in context format ("diff -c")
  ss  Show differences side by side ("sdiff -w157")
  scommand Show differences using the specified diff-like command
  v  Show the new file

What do you want to do? [Leave it for later] d
EXAMPLE - dont install vanilla files over files that are altered during usage of system
--- /etc/group  2019-03-14 13:51:17.623212444 +0100
+++ /tmp/temproot/etc/group     2020-06-19 08:36:09.473404471 +0200
@@ -1,4 +1,4 @@
-wheel:*:0:root,user1,user2
+wheel:*:0:root
 daemon:*:1:daemon
 kmem:*:2:root
 sys:*:3:root
@@ -29,12 +29,10 @@
 guest:*:31:root
 _unbound:*:32:
 _nsd:*:33:
+nvmm:*:34:root
 nobody:*:39:
 utmp:*:45:
 authpf:*:72:
 users:*:100:
 dialer:*:117:
 nogroup:*:32766:
-www:*:1000:user2
-mysql:*:1001:
-zabbix:*:1002:

File: /etc/group (modified)

Please select one of the following operations:

  d  Don't install the new file (keep your old file)
  i  Install the new file (overwrites your local modifications!)
  m  Merge the currently installed and new files
  s  Show the differences between the currently installed and new files
  su  Show differences in unified format ("diff -u")
  sc  Show differences in context format ("diff -c")
  ss  Show differences side by side ("sdiff -w157")
  scommand Show differences using the specified diff-like command
  v  Show the new file

What do you want to do? [Leave it for later] m
EXAMPLE - merge files that you altered, but have some new content - in this example - keep group assigment, but add new nvmm group

At the end of etcupdate, you may have received message what was not finished

To fix, run:
    sh /usr/sbin/postinstall -s /usr/src -d / fix rc x11 ptyfsoldnodes obsolete
Note that this may overwrite local changes.
*** All done

Just run command proposed as fix

postinstall fixes passed: rc ptyfsoldnodes obsolete x11

And thats all, welcome to NetBSD 9.0.