dual boot FreeBSD with linux using grub2

Installing and upgrading FreeBSD.

dual boot FreeBSD with linux using grub2

Postby favor » 05 Dec 2009, 13:53

hi,

I first installed debian on my hard drive /dev/sda1, then I installed freebsd on /dev/sda4 on disk, when it ask me for selectiong boot mananger, I selected none, is this ok? later on, I login to debian OS, I updated grub to grub2, and I want to set grub2 to boot freebsd. I followed this method mentioned here:
edit /etc/grub.d/40_custom,

Code: Select all
menuentry "FreeBSD" {
   set root=(hd0,4,a)
   chainloader +1
}


and do update-grub2.

then I reboot and select my desired boot freebsd OS, but I can’t boot.

my freebsd os is installed on my disk partition four, on debian its partitions show like below:

Code: Select all
debian:/home/user# fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×00014522

Device Boot Start End Blocks Id System
/dev/sda1 1 1216 9767488+ 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 1217 1398 1461915 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 1399 6079 37600132+ 83 Linux
Partition 3 does not end on cylinder boundary.
/dev/sda4 * 6080 9730 29321176+ a5 FreeBSD
Partition 4 does not end on cylinder boundary.


what’s wrong with my daulboot system? how can I boot freebsd from grub2?

thanks
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby k1piee » 05 Dec 2009, 14:47

I'm not 100% sure, but I think that the second digit in:
Code: Select all
set root=(hd0,4,a)

should be 3 if its the fourth partition cause grub counts from 0. So partition 1 is 0, 2 is 1 and so on.
I could be wrong but you could try it.
k1piee
Junior Member
 
Posts: 88
Joined: 06 Apr 2009, 06:59

Postby favor » 06 Dec 2009, 03:20

I have tried that, but it didn't work either. I searched grub2 manual, I found that the note below:

http://ubuntuforums.org/showthread.php?t=1195275

Code: Select all
    Note the new partition naming convention. Devices start counting from "0" as done previously. sda is designated as "hd0", sdb is
"hd1", etc. However the first partition is now designated as sda1. Counting partitions does not start with "0". sda5 is "5".


so I think the right partition naming convention now should be sda4 as "(hd0,4), right?

howerver, I have tried to relace it with "(hd0,3,a), it didn't work either.

if I missed something when I installed the freebsd? As I searched from google, the "chainloader +1" will loader another loader which maybe installed on first sector of the partition. but when choose the boot manager, I choosed none when installing freebsd(the freebsd installing hints told me to do so), am I right to do so?

any suggestions is highly welcome.thanks
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby ericturgeon » 07 Dec 2009, 05:21

Try this:
Code: Select all
menuentry "FreeBSD" {
   set root=(hd0,4,a)
   kernel /boot/loader
}
[color="Red"]Where there is a shell, there is the way.[/color]
Unix Live Free.
User avatar
ericturgeon
Member
 
Posts: 338
Joined: 27 Dec 2008, 11:58
Location: Dieppe NB Canada

Postby favor » 07 Dec 2009, 06:02

ericturgeon wrote:Try this:
Code: Select all
menuentry "FreeBSD" {
   set root=(hd0,4,a)
   kernel /boot/loader
}


I also had tried this. when I choose FreeBSD, it hang on boot 'freebsd', and don't loader the kernel to move forward.

does someone have any idea?
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby favor » 07 Dec 2009, 08:41

what's the differences between "chianloader +1" and "kernel /boot/loader", or I also see someone suggested to use "freebsd /boot/loader".

In which case do they used respectively?
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby ericturgeon » 07 Dec 2009, 20:04

favor wrote:what's the differences between "chianloader +1" and "kernel /boot/loader", or I also see someone suggested to use "freebsd /boot/loader".

In which case do they used respectively?


were you write that?
[color="Red"]Where there is a shell, there is the way.[/color]
Unix Live Free.
User avatar
ericturgeon
Member
 
Posts: 338
Joined: 27 Dec 2008, 11:58
Location: Dieppe NB Canada

Postby favor » 08 Dec 2009, 04:14

I have tried many settings, but only got the same result,it is that the booting process hanged after displaying "loading freebsd" message.

and I reboot into grub2, and using ls to list all the partitions,it will show and hanged on:
Code: Select all
grub>ls
(hd0,1) (hd0,2) (hd0,3) (hd0,4)
[hanged on here]

grub> ls (hd0,1)  [this is ok]
grub> ls (hd0,4)  [will be hanged on]


is this problem related to this? can't the grub2 recognize freebsd partition?

I will very appreciate your help. thanks
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby zeiz » 08 Dec 2009, 06:32

Look here first.
Now, it smells like something is wrong with your grub2 or your FreeBSD installation, have you ever boot it by other means?
I don't know what do you have on your other partitions and do you have Live CDs for Debian and FreeBSD so facing such situation I would do the following:
1. Download GAG and burn it on CD.
2. Boot FreeBSD through GAG (without installing it to MBR).
3. If it's bootable - reinstall grub2.
4. If it's not bootable - reinstall FreeBSD :)
You may want of course just reinstall both grub2 and FreeBSD and try again. Grub2 boots FreeBSD for sure.
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby favor » 08 Dec 2009, 07:52

zeiz wrote:Look here first.
Now, it smells like something is wrong with your grub2 or your FreeBSD installation, have you ever boot it by other means?
I don't know what do you have on your other partitions and do you have Live CDs for Debian and FreeBSD so facing such situation I would do the following:
1. Download GAG and burn it on CD.
2. Boot FreeBSD through GAG (without installing it to MBR).
3. If it's bootable - reinstall grub2.
4. If it's not bootable - reinstall FreeBSD :)
You may want of course just reinstall both grub2 and FreeBSD and try again. Grub2 boots FreeBSD for sure.


I have reinstalled freebsd, and select to install freebsd boot manager(BootMgr), I think it overwrite original MBR. And when I reboot, it displays:

Code: Select all
F1 linux
F2 ??
F3 Linux
F4 FreeBSD

Default: F1



The end of the world is coming, I can't even boot up into debian, either freebsd, whatever I press F1/F2/F3/F4, not responding at all. I don't know anything what I have done wrong.

when the installing process go to Install a Boot Manager, there are three options to choose.

Code: Select all
Install a Boot Manager
BootMgr install the FreeBSD boot manager
Standard install standard MBR (no boot manager)
None  leave the Master Boot Record untouched


which one do you choose?
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby ikbendeman » 08 Dec 2009, 09:05

can you post your partition setup?
User avatar
ikbendeman
Member
 
Posts: 229
Joined: 01 Dec 2009, 17:05
Location: California, US

Postby favor » 08 Dec 2009, 14:28

sure. I'll describe the process of disk partition when installing FreeBSD.

before I got to Fdisk program, I got an warning as below:

Code: Select all
WARNING: It's safe to use a geometry of 155061/16/63 for ad4 on computers with modern BIOS versions. if this disk is to be used on
rather old machines, however, it's recommand to ensure that it does ont have moer that 65535 cylinders, or more than 255 headers or more than
63 sectors per track.

would you like that to keep using the current geometry?

I choose "YES" to keep my current geometry, I am afraid to modify this, in case I can't boot my debian system, that is my most reluctant to see.

After that, I got into the FDISK program, it shows me all the partitions I had. they are just like this:

Code: Select all
Disk name:ad4
Disk Geometry: 155061 cyls/16 headers/63 sectors = 156301488 sectors (76319 MB)

offset        size(ST)        End        Name        PType        Desc        Sub   
0             63              62          -          12            unused     0
63            19534977       19535039    ad4s1       4             ext2fs     131
19535040      2923830        22458869     ad4s2      4          linux_swap    130
22458870      75200256       97659134     ad4s3      4              ext2fs    131
97659135      58642353       156301487    ad4s4      8             freebsd    165


Then, I choose ad4s4 for installing FreeBSD, and press Q to enter partition for slice ad4s4. Because I will use all the entire ad4s4 slice, so I press A to auto divided into default partitions. at the end it something like the below:

Code: Select all
Disk: ad4  partition name: ad4s4 
part     mount      size          newfs          part
ad4s4a    /         512MB         UFS2            Y
ad4s4b   swap       2013MB        SWAP
ad4s4d   /var       2013MB        UFS2+S          Y
ad4s4e   /tmp       512MB         UFS2+S          Y
ad4s4f   /usr       23566MB       UFS2+S          Y


above it's all about my disk partition setup. I am hope I don't make any mistake.
is this infomation enough?

from my process do you get any clue? why is it happed that freebsd can't be booted from grub2?

I am waiting and would like to hear from you, thanks.
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby zeiz » 08 Dec 2009, 17:28

Your FreeBSD slice setup looks correct but...it's on 4th partition. Also my 1st partition stars from 63 and yours from 1.
I guess you have 80GB SATA HDD with 4 primary partitions:
1. Linux 9.5GB (what Linux?)
2. Linux Swap 1.5GB
3. Linux 36GB (Debian?)
4. FreeBSD 30GB
What Linux do you have on 1st partition? Is it valuable for you?
How about to wipe out everything and start from scratch?

I would partition my 80GB HDD like this:

ad4s1 (sda1) 1st primary partition 20GB FreeBSD (main OS)
ad4s2 (sda2) 2nd primary partition 8GB *BSD (openbsd, netbsd, pcbsd, another freebsd... OS to try)
ad4s3 (sda3) 3rd EXTENDED partition 34GB that contains:
[INDENT]1st logical drive 2GB -Linux Swap
2nd logical drive 20GB -Debian (main OS)
3rd logical drive 6GB -Linux2 (any to try)
4th logical drive 6GB -Linux3 (any to try)[/INDENT]
ad4s4 (sda4) 4th Primary partition 18GB - Data (docs, home, music etc) It's also handy for sharing files between FreeBSD and Linuxes. Format - fat32. It should be last (slowest) partition on the disk because docs doesn't need a lot of read/write.

Linux boots fine from extended partition (even from the very last one), *bsd - prefers primary partition. Linux is more flexible: you can shrink and grow your logical drives inside the extended partition.
Linux swap partition is recommended to be 1st on Extended partition. All the Linuxes there can share this only swap.

So, I would obtain tiny Daniel's ZAP utility that can erase first 64 sectors of HDD to wipe everything from there. It's not mandatory but it's better to start with "brand new" disk. I copy ZAP to DOS bootable floppy made in Widnows. It's also possible to zero everything with [CMD=" "]dd if=/dev/zero of=/dev/sda[/CMD] command under Parted Magic but I didn't try :).
I use Parted Magic to partition disks. It also has other disk utilities. It cannot format to ufs but you don't need it at this point. Of course FreeBSD fdisk will also do the job.
Partition your disk so that FreeBSD will be on 1st primary partition (Debian won't benefit from that). Install FreeBSD first, choose A (automatic labeling) and choose option1 - Install FreeBSD boot manager. Install packages you want (xorg, gnome, kde...whatever). Boot to FreeBSD to be sure it was installed correctly. F1 must boot FreeBSD.
Next install Debian on 2nd logical drive of your extended partition (1st is linux swap) and replace FreeBSD boot manager with Debian's Grub2. Boot to Debian and configure grub2 from there to boot FreeBSD (as described).
If you want more Linuxes install them paying attention not to wipe Debian's grub from MBR (choose their grubs on their own /boot partitions. Ignore their grub2 warnings. Configure grub2 from Debian to boot other Linuxes.
Have fun (mandatory).
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby viking » 08 Dec 2009, 21:02

Well, I have more or less the same setup, with some differences.

First, I still use GRUB legacy (0.97), and for FreeBSD and NetBSD works really fine on my laptop.

Anyway, these are my partitions:

hda1 (primary) - NTFS for Windows XP
hda2 (primary) - Ext3 for /boot (Linux, contains GRUB)
hda3 (extended) - Various logical units
hda4 (FreeBSD slice) - FreeBSD partitions
...

My GRUB entry for FreeBSD is the following:

Code: Select all
title   FreeBSD release 8.0
root    (hd0,3,a)
kernel  /boot/loader


During FreeBSD setup, the right choice for the boot manager is NONE if you want to boot FreeBSD via GRUB.

Hope this could help.

Bye
viking
Junior Member
 
Posts: 5
Joined: 08 Dec 2009, 12:32
Location: near Trieste, Italy

Postby favor » 09 Dec 2009, 11:42

You are right,I did have 80GB SATA HDD with 4 primary partitions:
1. Linux 9.5GB (but it's debian root /)
2. Linux Swap 1.5GB (debian swap)
3. Linux 36GB (Debian /home)
4. FreeBSD 30GB (installed here)

I think it's easy to boot FreeBSD via grub, just need only three lines (maybe more) to be setupped.

but I don't know what's going on with my disk? I just can't finger out what's the problem is.
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby zeiz » 09 Dec 2009, 16:12

For grub v.0.97 (grub1) viking's entry is correct and to boot FreeBSD last line is
[CMD=" "]kernel /boot/loader[/CMD]
For grub v.1.97~beta4 (grub2) it's different and last line is just
[CMD=" "]chainloader +1[/CMD]
in case of flavor's partitioning grub2 entry must be:
Code: Select all
menuentry "FreeBSD 8.0" {
set root(hd0,4,a)
chainloader +1
}


As I understood you've never seen your FreeBSD installation booted, right? You only see "booting freebsd.." (and no boot) that shows working grub.
So it could be just very simple reason: bad media.
What media did you use for installing of FreeBSD: CD1? DVD? FTP?
If CD/DVD did you verify .iso's checksum? Did you use 4x speed while burning your media? Did you check your CD integrity?

Eventually I would try reinstalling FreeBSD from FTP and install custom distribution set: base, kernel, docs and manpages.
No ports, no packages, no X11. It takes a few minutes to download.
Then I would choose boot manager (1st option) this time and try to boot freebsd to console.
If it's bootalbe then restore Debian's grub to replace FreeBSD bootmanager on MBR and configure grub2 as described above and finally install ports,
portupgrade, xorg, gnome2/kde4 etc also from FTP with [CMD=" "]pkg_add -r[/CMD]
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby viking » 09 Dec 2009, 22:03

Another possibility is using something like Super Grub, or Super grub disk, or something similar (google it) that use GRUB legacy / GRUB 1 / GRUB 0.97 / any-other-name-GRUB1-has. :h

Go to the command line and try to boot FreeBSD before overwriting your MBR with the FreeBSD bootloader.

Anyway, I usually don't recommend GRUB 1.97.
My friends and I are still fine with GRUB legacy. :h

Bye
viking
Junior Member
 
Posts: 5
Joined: 08 Dec 2009, 12:32
Location: near Trieste, Italy

Postby zeiz » 09 Dec 2009, 22:33

I had the same judgment: half baked promo... but after I set 1280x1024 splash on the fly I changed my mind :)
And actually...besides grub2 doesn't work (yet?) with GAG I've been using for years what else is annoying? Slightly different syntax, no direct editions to menu.lst and...that's it?
This looks even more promissing. Also I read that grub2 is able to boot iso image and more. Just time matter, it's still a baby...sorry, beta :)
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby favor » 11 Dec 2009, 03:06

Code: Select all
As I understood you've never seen your FreeBSD installation booted, right? You only see "booting freebsd.." (and no boot) that shows working grub.
So it could be just very simple reason: bad media.
What media did you use for installing of FreeBSD: CD1? DVD? FTP?
If CD/DVD did you verify .iso's checksum? Did you use 4x speed while burning your media? Did you check your CD integrity?


In brief, I install FreeBSD using DVD media.

yup, i never see freebsd installation booted, except that I repartition the disk and let BSD install on first primary partition.
I had used this media before, it could be installed successfully and ran well on my pc before, but that time BSD installed on entire disk.
I also recorded a new DVD media with lower speed, this new DVD installed ISO is downloaded from freebsd mirror site, aslo I checked its MD5/sha256 checksums, it has no problem. Then I repartition my disk and install it on the first primary partition, It can boot successfully again. so, I think the media's integrity is ok.

Until now, I doubt that it's the problem of my disk partition tables. (any different views are welcomed ;-) )
As I googled "Partition 1 does not end on cylinder boundary", all said it's about partition table error. please note the below message which is from debian fdisk output, it realize it's disk geometry as "255 heads,63 sectors/track, 9729 cylinders".

Code: Select all
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×00014522

Device Boot Start End Blocks Id System
/dev/sda1 1 1216 9767488+ 83 Linux
Partition 1 does not end on cylinder boundary.


but in freebsd's fdisk when partition the disk, it shows the disk geometry as:

Code: Select all
Disk name:ad4
Disk Geometry: 155061 cyls/16 headers/63 sectors = 156301488 sectors (76319 MB)


what do you think about it? The partition table is broken, is it the problem that I can't boot freebsd from original disk partitions?

Last night I didn't even sleep very well, because I would try many installing, disk partitions, booting and rebooting, etc....
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby zeiz » 11 Dec 2009, 04:45

A partition table is a subject to change on the fly while fixing faulty 80GB HDD is beyond my knowledge and interest.
I'd rather invest my time in learning FreeBSD :)
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby viking » 12 Dec 2009, 11:46

zeiz wrote:I had the same judgment: half baked promo... but after I set 1280x1024 splash on the fly I changed my mind :)
And actually...besides grub2 doesn't work (yet?) with GAG I've been using for years what else is annoying? Slightly different syntax, no direct editions to menu.lst and...that's it?
This looks even more promissing. Also I read that grub2 is able to boot iso image and more. Just time matter, it's still a baby...sorry, beta :)


Of course GRUB2 has some interesting feature and I think GRUB1 will disappear from distributions by two or three years.

I had very hard times when trying to install Ubuntu Karmic on pcs with Windows NT6.x or other OSs like *BSD.
Like me, several other users had the same problem.

I'll use GRUB2 when it will be a "release". I want to be an user, not a beta-tester. :e

Anyway, without going too much OT, dear favor, have you tried booting FreeBSD from supergrub or something else?

Just as an example, when I tried installing OpenBSD on my laptop, I wasn't able to boot it from GRUB in both ways. :(
But, when trying to boot it from the OpenBSD setup cd (with "b hd0a:/bsd" at the cd boot prompt), it boot(ed). And work(ed).

Computer's science is not exact...

Bye
viking
Junior Member
 
Posts: 5
Joined: 08 Dec 2009, 12:32
Location: near Trieste, Italy

Postby favor » 14 Dec 2009, 02:30

Good News;) I have booted FreeBSD successfully now.
it's sure that the grub can boot FreeBSD, no matter it's grub legacy or grub2. I have tried this:

Code: Select all
menuentry "FreeBSD 8.0" {
set root(hd0,1,a)
chainloader +1
}

and this:

Code: Select all
menuentry "FreeBSD 8.0" {
set root(hd0,1,a)
freebsd /boot/loader
}

Both options can works for me, but with much cost I had paid for it. I have repartitioned my disk, and put the FreeBSD on the first primary partition, when I installed it, I just pay attention to its disk geometry. FreeBSD recognize it disk geometry as:
Code: Select all
Disk Geometry: 155061 cyls/16 headers/63 sectors = 156301488 sectors (76319 MB)


when FreeBSD ask me if I would use the disk geometry recognized by default, I said no. and then FreeBSD recalculated a geometry which linux used by default.

Code: Select all
255 heads, 63 sectors/track, 9729 cylinders


I want to FreeBSD use this disk geometry when allocated its partitions.

That's the main thing what I pay attention when installing FreeBSD. after FreeBSD installed, I reinstall debian, let its grub legacy boot loader overwritten the origin on MBR.

then, I tried boot FreeBSD in grub legacy, it can be booted very well ;) after that, I tried grub2, I login to debian, and update grub legacy to grub2, and set the new entry menu for FreeBSD. Then, I back up the MBR, overwritten it with the new settings. The FreeBSD booted using grub2 with no problem.

In grub2, I can use "ls" to list all of its partitions, but at this time it wouldn't be hanged as like few days before(see the post which I had written few day ago).

I have tried many settings, but only got the same result,it is that the booting process hanged after displaying "loading freebsd" message.

and I reboot into grub2, and using ls to list all the partitions,it will show and hanged on:
grub>ls
(hd0,1) (hd0,2) (hd0,3) (hd0,4)
[hanged on here]

grub> ls (hd0,1) [this is ok]
grub> ls (hd0,4) [will be hanged on]

is this problem related to this? can't the grub2 recognize freebsd partition?


So, if your FreeBSD use a different disk geometry with linux, and partition disk under different disk geometry, I mean: allocate FreeBSD partitions using FreeBSD's default geometry, while allocate linux partitions using linux geometry. Maybe grub couldn't recognize it correctly, especially that grub is installed on linux, maybe it will use the linux geometry to find disk partitions. if I am wrong, welcome to correct me, I am not a specialist in this ;)

thanks all your help, I am really appreciated.
favor
Junior Member
 
Posts: 15
Joined: 17 Oct 2009, 06:52

Postby chrcol » 20 Jan 2010, 13:26

When I remote installed freebsd over debian, grub wouldnt boot with the chainloader, however it did work with the freebsd command to load the kernel.
chrcol
Member
 
Posts: 345
Joined: 17 Nov 2008, 12:31


Return to Installing & Upgrading

Who is online

Users browsing this forum: No registered users and 0 guests