The day I decided that I am going to submit a proposal for NetBSD for GSoC 2011, I installed it on one of my primary hard disk partitions to give it a try and have more solid understanding of the platform before I start to write my proposal. Installing NetBSD is a very easy thing to do, and the NetBSD guide [1] does a great job explaining the whole installation process in a very detailed manner.
However, It's not easy to just switch to a new OS all of a sudden, so I wanted to setup a dual boot system alongside with my existing Linux. Although the NetBSD guide does mention about setting up dual boot systems but it didn't discuss about the possible caveats that may crop up in the process, and as it turns out, setting up a dual boot of NetBSD + Linux can be a tough nut to crack for the newbies.
So, here I am writing this blog post after having fixed the problem. I hope this post will be useful for me in the future and to others who may also come across this not so rare problem.
The following guide assumes that you already have Linux installed on one of your partitions and you are installing NetBSD.
In the NetBSD partition manager screen where you need to select the partition to install NetBSD, let the 'd' and 'a' flags remain with the Linux partition and set the 'I' flag only for the NetBSD partition.
Do not install the NetBSD boot loader when sysinst (the NetBSD install program) prompts you to while installing NetBSD.
![]() |
Don't install the NetBSD bootcode in MBR |
After the installation of NetBSD finishes and you reboot, you will be directly booted into Linux (no surprises here), because we did not install the NetBSD boot loader in the MBR and GRUB didn't know about the existence of NetBSD so it directly booted Linux. Our next step will be to tell GRUB about NetBSD so that from the next time onwards it will give us a choice between NetBSD and Linux.
Note: These instructions are for GRUB2
- Create a file 06_netbsd in /etc/grub.d/ and write the following script in it to chain load the NetBSD boot loader:
#!/bin/sh -e
echo "Adding NetBSD 5.1 on sda1 to GRUB 2 menu"
cat << EOF
menuentry "NetBSD 5.1 on sda1" {
insmod bsd
set root=(hd0,1)
chainloader (hd0,1)+1
}
EOF
This script assumes that you have installed NetBSD in the Ist partition of your first hard disk. GRUB2 counts hard disks from 0 but partitions from 1, thus we have (hd0,1). If for example you had NetBSD in the 3rd partition, you would use (hd0,3).
- Make this script executable by the following command:
$sudo chmod a+x 06_netbsd
- After this, we need to tweak another file. Run the following commands:
$sudo gedit /etc/default/grub
- In this file you need to comment out the line saying:
GRUB_HIDDEN_TIMEOUT=0
To comment it out, simply put a # in front of this line in the file and save it.
- Now we need to run the 'update-grub' command and we are done. After running 'update-grub' , GRUB2 will add menu entry for NetBSD in it's configuration file (boot.cfg) and the next time you boot, you will be presented with the options to boot either into NetBSD or Linux.
For those using GRUB (not GRUB2), I believe they can simply add the menu entry in the menu.lst file and it should be ok (I am not sure, as I did not try). Also GRUB used to count partition numbers from 0, so if you had installed NetBSD in the Ist partition you would use (hd0,0)
[1]: The NetBSD Guide