Upgrading NetBSD from source

I usually maintain a separate build system, and use rsync to “upgrade” other systems.

Upgrading the build system

Update from CVS:

    cd /usr/src
    cvs update >& update.$USER.out &

Rebuild everything:

    ./build.sh -U -u distribution

After a successful build, install for use:

    ./build.sh -U install=/

Consider rebuilding all packages:

    cd /usr/pkgsrc
    cvs update >& update.$USER.out &

    rm -rf /usr/pkg/* /var/db/pkg/*

    sh dopkgs.sh -a

Test and distribute.

Upgrading with rsync

XXX: Expand NB-SYNC here.

Preparing tar files for manual upgrade and cloning

Make sure you have enough disk space available and create the following tar files:

    cd /
    mount /dev/sd0h /mnt
    tar -czlf /mnt/root.tar.gz ./
    tar -czlf /mnt/usr.tar.gz ./usr
    tar -czlf /mnt/var.tar.gz ./var

Cloning a machine

Install a standard release or snapshot on the destination machine.

Update the passwd and group databases, so that file unpack with correct ownerships:

    ftp ftp.gw.fi
      cd /etc
      lcd /etc
      mget master.passwd group
    pwd_mkdb -d / /etc/master.passwd

Follow the manual upgrade procedure below.

Upgrading manually with tar

Boot from floppies and label the hard drive:

    disklabel -t wd0 > o
    vi o
    disklabel -r -w -f o wd0 IBM-DPTA-372050

Partition the disk with disklabel -i wd0 (assuming 9G or more):

  • R (for rounding)
  • c (to round in cylinders)
  • enter each partition by entering its letter (no colon)
    • a: root, 64M
    • b: swap, 512M
    • c: whole disk
    • d: whole disk (should be there already)
    • e: /usr, 4096M
    • f: /var, 4096M
    • g: /home, the rest of the disk
  • W (for write)

Create filesystems on the appropriate partitions:

    for i in a e f g
      newfs /dev/rwd0$i

Copy the prepared tar files from another machine:

    mount /dev/wd0h /tmp (or it will run out of space)
    cd /tmp
    ftp ftp.gw.fi
      get root.tar.gz
      get usr.tar.gz
      get var.tar.gz
    mount /dev/wd0a /mnt
    cd /mnt
    tar -xzpf /tmp/root.tar.gz
    mount /dev/wd0e /mnt/usr
    tar -xzpf /tmp/usr.tar.gz
    mount /dev/wd0f /mnt/var
    tar -xzpf /tmp/var.tar.gz
    cd /mnt/dev
    sh MAKEDEV all

Install boot blocks:

    cd /mnt/usr/mdec
    cp -p boot /mnt/boot
    installboot -v -o console=com0 /dev/rwd0a bootxx_ffsv1

Reboot to single user mode and fix the following files:

  • /etc/myname
  • /etc/mygate
  • /etc/ifconfig.*
  • /etc/resolv.conf
  • /etc/fstab (wd or sd disks)

Remove the following files:

  • rm /etc/ssh_host_*
  • rm -rf /etc/amd
  • rm /etc/skeykeys
  • rm -rf /var/httpd /var/log/OLD/* /var/cron/tabs/*

Empty this file:

  • cp /dev/null /etc/dumpdates

Copy the crontab for root from a suitable machine.

Reset all log files:

    cd /var/log
    for f in *
      test -f $f && cp /dev/null $f

Reboot to multi-user mode and enjoy!