PDA

View Full Version : DUAL BOOTING LINUX & FreeBSD - How to restore grub if Bootmgr wipes it out


gr1ml0ck
June 30th, 2009, 07:19
NOTE: THIS GUIDE ONLY APPLIES IF YOUR PRIMARY O/S IS LINUX!!!

If you have a linux machine and your wanting to try FreeBSD on a separate partion... you may encounter the problem where the bootmgr (if installed) will wipe out your grub boot loader who's menu.lst file is exists on your linux drive.

DONT PANIC!!!

There is a very simple fix to this problem. The easiest way to do this is to use a live cd/dvd distro (any distro will do)

If your live distro takes you directly to the command prompt then obviously skip this next stop (duh!)

If your live distro takes you to a window manager then load a terminal (duh!?*!)

sudo grub

This will take you to the Grub command prompt.

Then type:

find /boot/grub/stage1

This should bring you a result back similar to this:

grub> find /boot/grub/stage1
(hd0,0)

This tells us the location (by drive and partion) of the correct drive from which to launch our boot manager.

Now.. still at the grub> prompt, type:

root (hd0,0)

Obviously here replacing (hd0,0) with the returned result from the previous command.

Now type (also at the >grub prompt):

setup (hd0)

And thats the first part done! Now reboot and your original grub boot loader will be restored!! Yippie!!

But hang about... now you have no entry for your shiny new FreeBSD install?!?!

Simply boot into your Linux O/S and enter a terminal. Then find your menu.lst file (usually located in /boot/grub/).

Edit this file using your usual editing program and add and entry to the the file.

Here is an example for you.. obviously replace the partition number with the correct one that you installed FreeBSD on!!

title Ubuntu 9.04, kernel 2.6.28-13-generic (recovery mode)
uuid f452a305-bdba-4f83-97a3-f87ecfdfc34c
kernel /boot/vmlinuz-2.6.28-13-generic root=UUID=f452a305-bdba-4f83-97$
initrd /boot/initrd.img-2.6.28-13-generic

title Ubuntu 9.04, memtest86+
uuid f452a305-bdba-4f83-97a3-f87ecfdfc34c
kernel /boot/memtest86+.bin
quiet

title FreeBSD 7.2
root (hd0,2)
chainloader +1

Usually on a generic Linux install it will be the same as above as your main partion will be 0,0 your swap partition will be 0,1 and therefore your FreeBSD partition will be 0,2.


I hope that anyone attempting to move into FreeBSD from Linux will find this How To usefull. I'm still very much a noob at this FreeBSD stuff .. but would like to share my journey with others also wishing to do the same.

;)

skido
April 15th, 2010, 17:51
Thank u. I was searching this all the time. I want to move to FreeBSD too. But I don't have a clue, how to setup my wlan. And how to setup a gnome Desktop. Or the ports.....

PhenomII
June 7th, 2010, 03:54
Thanks, that's a good post. I went the other way 'round, and installed FreeBSD first. Then plugged in a spare drive and installed Fedora 13 for comparison. Frdora happily installed grub and an entry for Frdora. But I was disappointed to NOT find an entry for the OGIGINAL install on the first harddrive; FreeBSD - which Fedora fully recognized. This led to much unscheduled reading on how to configure grub. :(

Thanks again.

mechanic
August 19th, 2010, 18:08
For those with a more recent Linux distro with Grub2 rather than Grub-legacy, these instructions:
http://grub.enbug.org/Grub2LiveCdInstallGuide
work and are easy to follow.

Yampress
September 12th, 2010, 19:40
grub-install /dev/ad0 ...

Szputnik
October 12th, 2010, 01:28
Very useful post. Thanks!!
My entry for FreeBSD looks like this:


title FreeBSD 8.1
rootnoverify (hd0,a)
chainloader +1

Using chainloader was necessary, as my grub doesn't recognize UFS2.

sk8harddiefast
October 12th, 2010, 09:31
Well. I will not use it but I also believe that is a useful post :) Well done!

joba1984
July 17th, 2011, 09:44
Thanks for the post ive just started using linux too so i myself am a bit of a noob but i want to gice freebsd a go so i will print this guide off and keep it next to my computer. many thanks gr1ml0ck