PC-BSD Installation
How can I use Grub in PC-BSD to manage several operating systems?
Grub is one of the best boot loaders and allows you to have several operating systems on your computer. When you start your computer, Grub shows a list of the installed operating systems (ie: Microsoft Windows XP, PC-BSD, Linux, OpenBSD, etc...) that you can choose from and load.
To start off, we are going to install Grub. Open your terminal and issue the following commands:
$ su - # pkg_add -r grub # cd /boot && mkdir grub # cp -Rf /usr/local/share/grub/i386-freebsd/* grub # cd grub
Please note that starting from FreeBSD 5, Grub is not allowed to write raw data on a mounted partition, so we will use a floppy disk to do it before mounting the root partition. Insert a floppy disk into your drive and issue:
# dd if=stage1 of=/dev/fd0 bs=512 count=1 # dd if=stage2 of=/dev/fd0 bs=512 seek=1 # kdesu kwrite menu.lst
Then you will add your partitions into the Grub configuration file.
It's good to remind how Grub understands device naming. Remember that computers start counting from "0", so in the partition name hd0,1,a, Grub understands that the first "0" means "first master disk", the "1" means "second partition", and the "a" refers to the first "sub-partition" of the partition, in the case of BSD operation systems. So, in this case, hd0,1,a means "Master disk > First slice > First BSD partition". You can learn more about Grub on the GNU GRUB Manual. Back to our configuration file, here's an example that encompasses fairly well most systems where you have a Microsoft Windows partition, a PC-BSD partition and a Linux partition:
timeout=5 default=1 title MS Windows XP rootnoverify (hd0,0) chainloader +1 title PC-BSD rootnoverify (hd0,1) chainloader +1 title CentOS root (hd0,2) kernel /boot/vmlinuz-2.6.9-34.EL ro root=LABEL=/ rhgb quiet initrd /boot/initrd-2.6.9-34.EL.img
The above needs to be adapted according to your own system. Then restart your computer, boot using the floppy disk and type:
grub> find /boot/grub/stage1
Grub will show you the location of its Grub stage1, which is PC-BSD's partition:
grub> find /boot/grub/stage1 (hd0,1,a) (hd0,4)
In this case, we will choose the first location, the second location being from an old Linux partition that has Grub also. Choose the one that corresponds to the partition where PC-BSD is installed. Then, issue the following command accordingly:
root (hd0,1,a) setup (hd0)
Don't forget the space between the command and the device: root (hd0,1,a) and setup (hd0). It will install the Grub boot loader on your primary HDD. Type quit and reboot your computer. After a few seconds you should see a Grub menu with your operating systems listed.
The PC-BSD entry in the Grub configuration file reads rootnoverify (hd0,1), actually the following possibilities have been tested and work as well for PC-BSD:
rootnoverify (hd0,1,a) root (hd0,1,a) root (hd0,1)
The timeout option defines the number of seconds Grub will wait before booting the default operating system, whereas the default option tells Grub which operating system to load by default, 0 being the first one listed, 1 the second, and so forth. Both lines are optional.
If you have problems, please get in touch with me: charles_AT_pcbsd_DOT_org
Last update: 2006-09-09 22:16
Author: Charles-André Landemaine
Revision: 1.1
Print this record
Send to a friend
Digg it!
You can comment on this entry
Comment of Adder (2038-01-19 03:14:07):
This is a nonsense HOW-TO since it does not help one bit, it only refers to a third party site from where you can download GRUB. PLEASE, if you state that it is best to download through the ports, tell me how to do that, do not assume that this is obvious to everybody.
Comment of daigo (2038-01-19 03:14:07):
you can install this through ports by using the "pkg_add grub" in konsole/bash under root. Problem is that really won't work until you populate the ports tree. You can find the HOWTO here http://www.pcbsd.org/faqs/index.php?sid=&lang=en&action=artikel&cat=9&id=13&artlang=en&highlight=populate%20ports
Sorry for the length of that. there is one problem with that, when you open the file it specifies (and you have a later version of PC-BSD) it's actually CHANGE-THIS.FreeBSD.org (or similar) just type cvsup# there (# being an actual number it mentions).
After running pkg_add grub it 'should' install grub into the boot directory /boot/grub from that directory in knosole type grub-install hd0 or (hd0) ( /dev/hda doesn't work, seems to be a linus thing only) problem I've ran into here is even under su I get a disk write error 29, no idea how to fix this.