Stray Grub notes

Now, the use of NetBSD's normal boot code is recommended. This file exists to save stray text about grub. Note that it is far far easier to use the native boot code, and that you probably should not be reading this.

Converting from grub to /boot

These instructions are provided only to help people using grub, which used to be the normal approach.

These instructions were used to convert a system from grub to /boot. The system was originally installed in February of 2006 with a RAID1 setup and grub to boot Xen 2, and has been updated over time. Before these commands, it was running NetBSD 6 i386, Xen 4.1 and grub, much like the message linked earlier in the grub section.

# Install MBR bootblocks on both disks.
fdisk -i /dev/rwd0d
fdisk -i /dev/rwd1d
# Install NetBSD primary boot loader (/ is FFSv1) into RAID1 components.
installboot -v /dev/rwd0d /usr/mdec/bootxx_ffsv1
installboot -v /dev/rwd1d /usr/mdec/bootxx_ffsv1
# Install secondary boot loader
cp -p /usr/mdec/boot /
# Create boot.cfg following earlier guidance:
menu=Xen:load /netbsd-XEN3PAE_DOM0.gz console=pc;multiboot /xen.gz dom0_mem=512M
menu=Xen.ok:load /netbsd-XEN3PAE_DOM0.ok.gz console=pc;multiboot /xen.ok.gz dom0_mem=512M
menu=GENERIC:boot
menu=GENERIC single-user:boot -s
menu=GENERIC.ok:boot netbsd.ok
menu=GENERIC.ok single-user:boot netbsd.ok -s
menu=Drop to boot prompt:prompt
default=1
timeout=30

Install

If you plan to use the grub boot loader, when partitioning the disk you have to make the root partition smaller than 512Mb, and formatted as FFSv1 with 8k block/1k fragments. If the partition is larger than this, uses FFSv2 or has different block/fragment sizes, grub may fail to load some files.

You'll also need sysutils/grub from pkgsrc.

Grub config

#Grub config file for NetBSD/xen. Copy as /grub/menu.lst and run
# grub-install /dev/rwd0d (assuming your boot device is wd0).
#
# The default entry to load will be the first one
default=0

# boot the default entry after 10s if the user didn't hit keyboard
timeout=10

# Configure serial port to use as console. Ignore if you'll use VGA only
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1

# Let the user select which console to use (serial or VGA), default
# to serial after 10s
terminal --timeout=10 serial console

# An entry for NetBSD/xen, using /netbsd as the domain0 kernel, and serial
# console. Domain0 will have 64MB RAM allocated.
# Assume NetBSD is installed in the first MBR partition.
title Xen 3 / NetBSD (hda0, serial)
  root(hd0,0)
  kernel (hd0,a)/xen.gz dom0_mem=65536 com1=115200,8n1
  module (hd0,a)/netbsd bootdev=wd0a ro console=ttyS0

# Same as above, but using VGA console
# We can use console=tty0 (Linux syntax) or console=pc (NetBSD syntax)
title Xen 3 / NetBSD (hda0, vga)
  root(hd0,0)
  kernel (hd0,a)/xen.gz dom0_mem=65536
  module (hd0,a)/netbsd bootdev=wd0a ro console=tty0

# NetBSD/xen using a backup domain0 kernel (in case you installed a
# nonworking kernel as /netbsd
title Xen 3 / NetBSD (hda0, backup, serial)
  root(hd0,0)
  kernel (hd0,a)/xen.gz dom0_mem=65536 com1=115200,8n1
  module (hd0,a)/netbsd.backup bootdev=wd0a ro console=ttyS0
title Xen 3 / NetBSD (hda0, backup, VGA)
  root(hd0,0)
  kernel (hd0,a)/xen.gz dom0_mem=65536
  module (hd0,a)/netbsd.backup bootdev=wd0a ro console=tty0

#Load a regular NetBSD/i386 kernel. Can be useful if you end up with a
#nonworking /xen.gz
title NetBSD 5.1
  root (hd0,a)
  kernel --type=netbsd /netbsd-GENERIC

#Load the NetBSD bootloader, letting it load the NetBSD/i386 kernel.
#May be better than the above, as grub can't pass all required infos
#to the NetBSD/i386 kernel (e.g. console, root device, ...)
title NetBSD chain
  root        (hd0,0)
  chainloader +1

## end of grub config file.

Install grub with the following command:

# grub --no-floppy

grub> root (hd0,a)
 Filesystem type is ffs, partition type 0xa9

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/ffs_stage1_5" exists... yes
 Running "embed /grub/ffs_stage1_5 (hd0)"...  14 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd0) (hd0)1+14 p (hd0,0,a)/grub/stage2 /grub/menu.lst"...
 succeeded
Done.