How to install GRUB2 on NetBSD
This how-to explains the steps needed to install GRUB2 on an existing i386/AMD64 NetBSD installation. The steps should work on a properly chroot'ed system too. Tested on NetBSD 6.0 AMD64:
First of all, either download the package, using pkgin install grub2
, or build
it yourself from package sources (/usr/pkgsrc/sysutils/grub2
).
After that, generate a GRUB configuration file, which tells GRUB the positions of the operating system(s). The following command will generate such a file, while adding your NetBSD system into its list.
# grub-mkconfig -o /grub/grub.cfg
Now, install GRUB into your hard drive's master boot record (MBR).
You have to know its device name for this step (e.g. /dev/rwd0a
).
Exchange /dev/rwd0a
with your desired device name, then change /dev/rXXXa
to /dev/rwXXXd
to access the raw disk, as in the following example:
Device name : /dev/rwd0a
Direct access : /dev/rwd0d
The appropriate grub-install
command for this drive would be:
# grub-install --no-floppy /dev/rwd0d
Hopefully, it should return : Installation finished. No error reported.
If it does so, simply reboot the system and you should be greeted by a nice
OS-selector.
If not, recheck your device names, if that doesn't fix it, search the web for
the error message.
Even though there aren't that many resources about GRUB on NetBSD, you'll
find a lot of information at GNU/Linux-related sites which apply to this
scenario as well.