# Grub legacy menu.lst to Grub2 grub.cfg



## edwinoakes (Jan 2, 2013)

I recently installed a freeBSD 9.0 system using an entire 2nd disk.  From various Internet sites, I found that Grub-legacy will not boot freeBSD 9.0. Following directions I found in the Grub documentation,  I have upgraded Grub to Groub2 such that I can now open Grub2 menu from the Grub-legacy menu.

The primary disk is a 1.0 tb disk, partitioned in 4 partitions. The first partition, with a ufs file system, contains freeBSD 8.2. The third partition is is an extended partition divided in two for Ubuntu. The Ubuntu partition is ext2.  Partition 2 is ufs, and partition 4 is ext2, both used for extra storage.

Grub is installed in /boot/Grub in the utuntu file system

I have been unable to boot the freeBSD 8.2 OS on the main disk using the Grub2 menu. It boots successfully from the Grub-legacy menu. The Ubuntu will boot successfully from either the Grub-legacy or Grub2 menu. When I change the boot order in the bios to the second disk, freeBSD 9.0 boots successfully using the freeBSD boot loader.

I expect that if and when I get the freeBSD 8.2 system to boot from the Grub2 menu, that getting the freeBSD 9.0 system to boot will be straight forward. 

The portion of the Grub-legacy menu.lst for booting the FreeBSD 8.2 is:

```
# For booting FreeBSD
     title  FreeBSD
     root   (hd0,0,a)
     kernel /boot/loader
```

The portion of the Grub2 grub.cfg that boots ubuntu isâ€


```
menuentry 'Ubuntu, with Linux 2.6.38-8-generic-pae' --class ubuntu --class gnu-linux --class gnu --class os {
	recordfail
	set gfxpayload=$linux_gfx_mode
	insmod part_msdos
	insmod ext2
	set root='(hd1,msdos5)'
	search --no-floppy --fs-uuid --set=root 34d13e9c-7bf7-4eda-aa21-d9461e6c2e12
	linux	/boot/vmlinuz-2.6.38-8-generic-pae root=UUID=34d13e9c-7bf7-4eda-aa21-d9461e6c2e12 ro   quiet splash vt.handoff=7
	initrd	/boot/initrd.img-2.6.38-8-generic-pae
}
```
I have found many sites on-line with solutions for booting freeBSD from Grub2, but none have worked for my case. I have tried many of these solutions by editing using the grub editor and/or changing the code in grub.cfg. I have the code in grub.cfg for test, not in  /etc/grub.d/40_custom. The solution in the Grub manual for freeBSD refers to file that are not in my freeBSD  8.2 /boot. I have received several different error messages, with different grub.cfg code. The current code gives a File not Found error. The current version of the Grub2 grub.cfg for booting freeBSD 8.2 is:

```
# For booting FreeBSD
     menuentry  "FreeBSD 8.2"  {
#	insmod part_msdos
   insmod ufs
     set root=(/hd1,msdos1)
 search --no-floppy --fs-uuid --set=root 34d13e9c-7bf7-4eda-aa21-d9461e6c2e12
    kfreebsd         /boot/loader
kfreebsd.vfs.root.mountfrom=ufs:ad4s1a
}
```
I think there must be something simple that I am missing, but have no idea what it is!  Any idea how to change things to make Grub2 to boot freeBSD 8.2?

Thanks.

NOTE:
I tried to send a similar post on the on the 31st , but it has not appeared on the forum. I must have done something so it went into a bit bucket.  If it should arrive at the forum, only one of these posts needs to appear.


----------



## Beeblebrox (Jan 2, 2013)

> Grub is installed in /boot/Grub in the utuntu file system


That's your mistake. You need a separate partition for grub (think of grub as a separate O/S whose job is just to chainload into the OS you actually want.
A sort-of tutorial is here.


----------



## ajith (Jan 8, 2013)

Have you tried 





> rescatux


 http://www.supergrubdisk.org/rescatux/.

It worked for me,when I had issues with boot loader.Boot from CD or USB stick.You can download it from here. 

http://www.supergrubdisk.org/category/download/rescatuxdownloads/


----------



## edwinoakes (Jan 16, 2013)

I finally found how to boot the freeBSD 8.2 OS with the Grub2 installed in ubuntu 12.10 installed on a separate partition of the same disk. The grub.cfg menuentry is:


```
menuentry "FreeBSD 8.2" {
        insmod ufs2
        set root='(hd0,msdos1)'
 #       search --no-floppy --fs-uuid --set  4c9511e4308fb60f
        kfreebsd /boot/kernel/kernel
 #       kfreebsd_loadenv /boot/device.hints
 #       kfreebsd_module /boot/splash.bmp type=splash_image_data
        set kFreeBSD.vfs.root.mountfrom=ufs:ad4s1a
}
```

I just kept changing things in the menuentry and finally found the right combination.

I have not been able to get the Grub2 version 2.00 to recognize the partitions on the second disk with the freeBSD 9.0 OS. Gparted from ubuntu sees them just fine. Three partitions of 64Kb, 145Gb, 4Gb, and unallocated of 51.82Mb.

The menu entry I tried last was:


```
[menuentry "FreeBSD 9.0"{
 insmod ufs2
    set root='(hd1,gpt2)'
   kfreebsd /boot/kernel/kernel
  set kFreeBSD.vfs.root.mountfrom=ufs:ad1p2
}
```
I have tried using in the menuentry both 
	
	



```
set root='(hd1,2)'
```
 and 
	
	



```
set root='(hd1,bsd2)'
```
 all of these give a "no such partition" error, or something with the same meaning. I also tried using

```
chainloader +1
```
 instead of trying to load the kernel.

If I switch the boot order the freeBSD 9.0 OS boots correctly.

Does the freeBSD 9.1 install program format the partition table differently than what gparted does?
Can I install freeBSD 9.1 to a disk that is partitioned with gparted using those partitions?

Should I be using a different filesystem type instead of ufs? What type? Would it help when using Grub2




 Thanks  Tom


----------



## edwinoakes (Jan 19, 2013)

*sort  of solved*

Solved (sort of)
I can now boot the freeBSD 9.1 from the second disk using GAG. I had to install the freeBSD 9.1 in a MBR partition, instead of the GPT freeBSD 9.1 default partition table. The entire Grub2 menu come up when I select Ubuntu to boot, but I have not worked on getting the freeBSD 9.1 OS to boot from there.

Thanks Tom


----------

