NetBSD

From PrgmrWiki
Jump to: navigation, search

PV and HVM Virtualization

For the rest of this document, we assume that you have a VPS in PV (paravirtualized) mode. We have a page PV and HVM Virtualization describing the two virtualization types supported by Xen: PV and HVM. While it is possible to install NetBSD on an HVM VPS, at the present time we strongly recommend installing NetBSD on a PV VPS for performance reasons. Installing under HVM with a netboot installer is not yet documented.

Legacy Grub or Grub2?

Legacy GRUB requires a separate boot partition with ext2 on the boot partition. Using GRUB 2 requires a separate step at the end to download the Xen kernel.

Partitioning for use with pv-grub (legacy management console)

If you are on the new Management Console, you should skip this section. If you aren't sure which console you have, the new management console has an option labeled "install new OS image".

From the Management Console, to make accessing the live rescue image available verify you are using "pv-grub"

9. swap pvgrub/grub2 bootloaders currently "pv-grub"

Shut down your machine if it is running. Then select

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

This will bring up a menu resembling:

    GNU GRUB  version 0.97  (131072K lower / 0K upper memory)

 +-------------------------------------------------------------------------+
 | user bootloader configuration                                           |  
 | Debian GNU/Linux, kernel 3.2.0-4-amd64 Live Rescue                      |
 | Debian GNU/Linux, kernel 3.2.0-4-amd64 (single-user mode) Live Rescue   |
 | ubuntu-trusty-14.04-64 rescue                                           |
 | ubuntu-trusty-14.04-64 install                                          |
 | centos5-64 rescue                                                       |
 | centos5-64 install                                                      |
 | debian-wheezy-7.0-64 rescue                                             |
 | debian-wheezy-7.0-64 install                                            |
 | fedora20-64 rescue                                                      |
 | fedora20-64 install                                                     |
 | centos6-64 rescue                                                       | v
 +-------------------------------------------------------------------------+
    Use the ^ and v keys to select which entry is highlighted.
    Press enter to boot the selected OS, 'e' to edit the
    commands before booting, or 'c' for a command-line.

Boot Debian GNU/Linux Live Rescue from GRUB.

Log in as root.

Run the following:

wipe-and-reinstall /distros/<tab complete to desired distro>

This will create a boot partition and add the normal kernel, install kernel, and menu.lst to that boot partition. Next "reboot" the machine so that you can boot the NetBSD installer.

Installing

Booting NetBSD installer (new management console, PV)

From the Management 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 pvgrub 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".

Booting NetBSD installer (legacy management console)

From the Management Console, to make accessing the live rescue image available verify you are using "pv-grub"

 9. swap pvgrub/grub2 bootloaders currently "pv-grub"

Verify whether you are running in 32 bit (i386) or 64 bit (amd64) mode by looking at

    6. swap i386/amd64 bootloaders currently "i386"

and switch if desired.

Shut down your machine if it is running. Then select

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

This will bring up a menu resembling:

    GNU GRUB  version 0.97  (131072K lower / 0K upper memory)

 +-------------------------------------------------------------------------+
 | user bootloader configuration                                           |  
 | Debian GNU/Linux, kernel 3.2.0-4-amd64 Live Rescue                      |
 | Debian GNU/Linux, kernel 3.2.0-4-amd64 (single-user mode) Live Rescue   |
 | ubuntu-trusty-14.04-64 rescue                                           |
 | ubuntu-trusty-14.04-64 install                                          |
 | centos5-64 rescue                                                       |
 | centos5-64 install                                                      |
 | debian-wheezy-7.0-64 rescue                                             |
 | debian-wheezy-7.0-64 install                                            |
 | fedora20-64 rescue                                                      |
 | fedora20-64 install                                                     |
 | centos6-64 rescue                                                       | v
 +-------------------------------------------------------------------------+
    Use the ^ and v keys to select which entry is highlighted.
    Press enter to boot the selected OS, 'e' to edit the
    commands before booting, or 'c' for a command-line.

Boot netbsd install from GRUB.

Overall instructions

Before you perform the installation, you should disable privacy extensions for autoconfigured IPv6 addresses. Such temporary addresses are not usable for a Prgmr.com VPS. 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

A tutorial for the netbsd installer is at http://netbsd.org/docs/guide/en/chap-exinst.html

When prompted, install to xbd0.

Partitioning for pv-grub

When prompted, select 'Use existing partition sizes'. Your root device should be on partition 'a'. Please refer to http://netbsd.org/docs/guide/en/chap-inst.html#chap-inst-install-partition for more information on partitioning

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

  • Use 'FFSv2' for FStype
  • Set 'start' to e (for end of partition e)
  • Set 'end' to -1 (for full disk)
  • Set 'mount' to 'yes'
  • Set 'mount point' to '/'

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.

Partitioning for grub2

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 grub2.
Please refer to http://netbsd.org/docs/guide/en/chap-inst.html#chap-inst-install-partition for more information on partitioning

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

Continuing Install

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

NetBSD 6

  • For "Bootblocks selection" , select "Use existing bootblocks"
  • "Install from" FTP or HTTP
  • Press enter to use the xennet0 device
  • Press enter for the "Network media type"
  • Select "yes" for DHCP configuration
  • Select "no" for IPv6 autoconfiguration

NetBSD 7 and NetBSD 8

  • For "Bootblocks selection" , select "Use existing bootblocks"
  • "Install from" FTP
  • Select "Configure network"
  • Press enter to use the xennet0 device
  • Press enter for the "Network media type"
  • Select "yes" for auto configuration
  • Select "Get distribution"

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 grub2 bootloader only

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 7 (amd64)
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/amd64/binary/kernel/MD5
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/amd64/binary/kernel/SHA512
#NetBSD 7 (i386)
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/i386/binary/kernel/netbsd-XEN3PAE_DOMU.gz
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/i386/binary/kernel/MD5
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-7.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 management console. From the management console, select

    4. force power off (destroy/hard shutdown)

Select

    9. swap pvgrub/grub2 bootloaders currently "pv-grub"

to use grub2. Select

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

to start your VM.

Rescuing NetBSD install

For the legacy management console, the shell available from the NetBSD installer from the initial pv-grub boot menu may be used as a minimal rescue image.

If you are on the new management console, there's an additional option for rescuing that will work even if you're using GRUB2. 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.

Loadable kernel modules prior to NetBSD 8.0

For NetBSD 7.x and older, it seems that loadable kernel modules are not supported under Xen. See https://mail-index.netbsd.org/port-xen/2013/01/20/msg007876.html. Among other things, this renders pf firewalling unusable under the default NetBSD kernel, as loading the pf module (modload /usr/lkm/pf.o) does not work. Building a new kernel with pf built-in may work, see https://www.netbsd.org/docs/network/pf.html

However, for NetBSD 8.0, loadable kernel modules do work under Xen, so the above note no longer applies.