NetBSD OS Distribution

NetBSD is an open-source Unix-like operating system that descends from Berkeley Software Distribution (BSD), a Research Unix derivative developed at the University of California, Berkeley. It was the first open-source BSD descendant formally released after it was forked from 386BSD.1

Tornado VPS provides a netboot install for NetBSD.

For the rest of this document, we assume that you have a VPS in PV (paravirtualized) mode. PV and HVM are the two virtualization types supported by Xen. While it is possible to install NetBSD on an HVM VPS, it will not perform adequately for regular use.

Installation

Booting NetBSD installer

From the VPS console, select the option labeled “install new OS image.” Select the version of NetBSD you wish to install from the list of operating systems. Note that this doesn’t install the OS; it installs a kernel that will boot into the NetBSD installer. This also partitions your drive for use with pv-grub and adds a menu.lst. Once the install is finished, go back to the main menu, and use the option “create/start” to boot. Once the system is booted to a pvgrub menu, select the entry containing the word “install.”

Overall instructions

Before you perform the installation, you should disable privacy extensions for autoconfigured IPv6 addresses. Such temporary addresses are not usable on our network. From the utility menu, select Run /bin/sh. At the shell prompt, execute the following command: sed -i 's/^slaac private/slaac hwaddr/' /etc/dhcpcd.conf

The NetBSD website has a guide to the netbsd installer

When prompted, install to xbd0.

Partitioning for NetBSD 9.x+ (Grub 2)

Your root device should be on partition ‘a’. To our best knowledge, you may install with whatever options you choose as long as the first partition has room for the netbsd kernel (approximately 8MiB) and the file system is compatible with Grub 2.

Refer to the NetBSD installation guide for more information on partititioning.

Example of working partition scheme:

 We now have your BSD-disklabel partitions as:
 This is your last chance to change them.

    Start  MB   End  MB  Size  MB FS type    Newfs Mount Mount point
    --------- --------- --------- ---------- ----- ----- -----------
 a:         0      2815      2816 FFSv2      Yes   Yes   /
 b:      2816      3071       256 swap
 c:         0      3071      3072 NetBSD partition
 d:         0      3071      3072 Whole disk
 e:         0         0         0 unused

Partitioning for NetBSD 8.x (Grub 1)

pv-grub, also referred to as legacy Grub, requires a separate boot partition formatted as ext2 that contains the grub config file and the kernel to be booted. While seeming more awkward, pv-grub is the typical means of booting NetBSD 8.x.

When prompted, select ‘Use existing partition sizes’. Your root device should be on partition ‘a’. Refer to the NetBSD installation guide for more information on partitioning.

When editing partition ‘a’, the following is known to work:

This partition scheme should work and was made for a 4GiB disk:

 We now have your BSD disklabel partitions as:
 This is your last chance to change them.

    Start  MB   End  MB  Size  MB FS type    Newfs Mount Mount point
    --------- --------- --------- ---------- ----- ----- -----------
 a:        34      4095      4061 FFSv2      Yes   Yes   /
 b:         0         0         0 unused
 c:         0      4095      4096 NetBSD partition
 d:         0      4095      4096 Whole disk
 e:         3        33        30 Linux Ext2
 f:         0         0         0 unused
 g: Show all unused partitions
 h: Change input units (sectors/cylinders/MB)
>x: Partition sizes ok

You may choose whatever options you want as long as the Linux Ext2 partition is preserved as-is. If the boot partition is formatted or removed, however, you will be unable to boot.

Note that in the above example, the boot partition (e) is actually in lower-numbered sectors, with the NetBSD root partition (a) later in the disk. Also note that in addition to disklabel, there is an MBR partition table, with two “Linux” (sysid 131) partitions. The first is the boot partition, aliased by e above, and the second aliases the NetBSD a partition.

Continuing Install

Only choices that need to be a particular value are called out here.

NetBSD 8

Be sure to add at least one user account. On NetBSD 7, root login is disabled by default even if you set the root password. If you wish to log in as root you must specifically enable root login after you’ve logged in with the new user.

Fixing IPv6

You also need to disable SLAAC privacy addresses for the target system. From the utility menu, select “Run /bin/sh”, and run the following sequence of commands at the shell prompt:

$ mount /dev/xbd0a /mnt
$ sed -i 's/^slaac private/slaac hwaddr/' /mnt/etc/dhcpcd.conf
$ umount /mnt

Finishing install for NetBSD 9.x (Grub 2)

Using GRUB 2 requires a separate step at the end to download the Xen kernel and configure a grub config file. With GRUB 2, the grub process started from the dom0 reads the NetBSD root filesystem to find the grub config file and then the kernel. The advantage is that no separate boot ext2 partition is needed.

After finishing the install, you will need to manually add the Xen kernel. Go to the “Utility Menu” and Enter a shell. Perform the following:

$ mount /dev/xbd0a /mnt
$ chroot /mnt
# NetBSD 9 (amd64)
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-9.0/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-9.0/amd64/binary/kernel/MD5
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-9.0/amd64/binary/kernel/SHA512
# NetBSD 9 (i386)
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-9.0/i386/binary/kernel/netbsd-XEN3PAE_DOMU.gz
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-9.0/i386/binary/kernel/MD5
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-9.0/i386/binary/kernel/SHA512
# NetBSD 8 (amd64)
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/amd64/binary/kernel/MD5
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/amd64/binary/kernel/SHA512
# NetBSD 8 (i386)
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/i386/binary/kernel/netbsd-XEN3PAE_DOMU.gz
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/i386/binary/kernel/MD5
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/i386/binary/kernel/SHA512
# Do not use if this fails
# Replace XEN3_DOMU.gz with XEN3PAE_DOMU.gz if on i386
grep "$(/usr/bin/cksum -a md5 netbsd-XEN3_DOMU.gz)" MD5
# Do not use if this fails
# Replace XEN3_DOMU.gz with XEN3PAE_DOMU.gz if on i386.
grep "$(/usr/bin/cksum -a sha512 netbsd-XEN3_DOMU.gz)" SHA512
mkdir /grub
echo "set default=0
set timeout=5
menuentry 'NetBSD, with kernel netbsd-XEN3_DOMU.gz ' {
        linux /netbsd-XEN3_DOMU.gz
}" > /grub/grub.cfg
rm MD5
rm SHA512
exit
umount /mnt
exit

Select “Back to main menu” and then “Halt the system”. Wait for the VM to reboot.

Type ‘ctrl-]’ to exit back to the VPS console. From the VPS console, select

4. force power off (destroy/hard shutdown)

Select

set bootloader, rescue mode, or netboot installer

and select “GRUB2” as the bootloader. Go back to the main menu and select

2. create/start, opens OOB console (try this if the machine is not running)

to start your VM.

Rescuing NetBSD install

On the VPS console, there’s an additional option for rescuing that will work even if you’re using GRUB2, and should work even if you have broken your boot partition. Select “set bootloader, rescue mode, or netboot installer”. From the “BSD installers” menu, select the option corresponding to your version of NetBSD. You can then boot into that installer and use the shell for rescue purposes.