help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Default Grub legacy menu.lst to Grub2 grub.cfg solved (sort of)


From: Tom Oakes
Subject: Re: Default Grub legacy menu.lst to Grub2 grub.cfg solved (sort of)
Date: Sat, 19 Jan 2013 11:17:58 -0700
User-agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.13) Gecko/20110202 Thunderbird/3.1.7

Hi,
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, of the second disk, instead of the GPT freeBSD 9.1 default partition table. The entire Grub2 menu comes 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

On 01/08/13 10:26, Tom Oakes wrote:
I have appended my original email to the end of this message as I think it is necessary for understanding my problem if others have suggestions.

My Disk does have a MBR with Grub 1.98 installed to access the /boot/grub directory of the ubuntu system installed in /dev/sdb5, which is in the extended partition /dev/sdb3. The ubuntu boots with no problem from the installed Grub2 system.

I have two basic questions:
1. Is correct that it necessary for the Grub2 MBR to be access Grub files installed in a separate partition in order for it to boot freeBSD?

2. If it is necessary, can it be a partition in an extended partition?

A third question is what code needs to be in grub.cfg for booting the freeBSD?


On 01/07/13 14:05, Chris Murphy wrote:
I'm not sure about Ubuntu 12.10 (current) but 12.04 and Linux Mint 13 have a positively ancient version of GRUB2, it's not the release 2.00. So I suggest you get a release version of 2.00, either building it yourself from current source or snag the RPM from Fedora 18.

Maybe what's confusing are the parts of grub. There's a grub package that includes a bunch of scripts and .mod files, which are platform specific. When you run grub-install, it causes the *.mod files to be created/replaced, a new core.img created, which is then placed into one of three locations.

Is the partition scheme MBR or GPT? I'm going to guess this is BIOS, not UEFI, hardware in which case the default is probably MBR. If the 1st partition start sector is 2048 you have a ~1MB gap between the MBR at LBA0, and LBA2048 where the first partition starts. And GRUB's core.img goes in that gap. If you're using GPT, you need a 1MB BIOS Boot partition into which GRUB's core.img will go. For UEFI, it'll go on the EFI System partition. In any case, these locations are found automatically by grub-install.

For BIOS, technically there are two parts: the part that fits into the first 440 bytes of LBA 0, which is merely code to jump to, load, and run core.img which is in the MBR gap, or the BIOS Boot partition on GPT disks. That core.img code has a PREFIXED baked into it, so it can find the rest of GRUBs modules, the *.mod files, and also the grub.cfg. At that point is when you see the menu.

So this statement:
Quote:
Grub is installed in /boot/Grub in the utuntu file system
is true, and fine. It's not a mistake.

If you are going to use GPT, I suggest using gdisk (atp-get gdisk I'm guessing for Ubuntu). It doesn't matter where the 1MB partition is for BIOS boot, it's identified by grub-install by its GUID. The gdisk type code for this is EF02. If you use parted, you set a bios_grub flag on the 1MB partition to do the same thing.

This idea of a 512MB partition for GRUB makes no sense to me. This partition for GRUB only doesn't contain anything but GRUB's core.img which is usually around 32KB. It's tiny. If you use LVM or Btrfs then it gets bigger, but still way less than 100KB. So 1MB is recommended for padding and to keep subsequent partitions aligned in the event they're 512e AF disks with 4K physical sectors.

As for the FreeBSD menu entry, I'm pretty sure the current GRUB 2 release's grub-mkconfig will find it, and create the proper menu entry in the grub.cfg.

Now, it's not exactly obvious how you install grub if you're not already booted from the disk you're going to install it to, i.e. if you've booted from a live cd or something. You need to mount that OS's partitions, and I use mount -o bind for /proc, /sys, and /dev. I always forget which two are needed by grub-install so I just do all three. Then chroot that. Then 'grub-install /dev/sda' or whatever; then 'grub-mkconfig -o /boot/grub/grub.cfg'. Done.


Chris Murphy
I posted the following to the freeBSD forum and received a single reply shown below the original post.

The reply said that I need to install Grub in a separate partition. Will that really fix the problem? Can the separate partition be in an extended partition containing Ubuntu 12.04?

I don't understand why a separate partition will fix the problem. The Grub manual says that Grub runs before the OS starts. It also says in the instructions for installing grub in a separate partition to format the partition with a file system.  The advantage for installing Grub in the separate mentioned is that it does get messed up if/when you upgrade your operating system containing /boot/Grub. All this make me wonder if a separate partition won't solve the problem.

I did, in trying different things, upgrade Ununtu, and Grub2 now starts instead of Grub-legacy so I have lost the ability to boot freeBSD from the hard disk. I think I need to reinstall Grub-legacy in the MBR. How do I do that? I think see direction for that but do not recall where I saw them. I can still boot freebsd with a CD.

Thanks for any answers and help,

Tom 
address@hidden



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 Grub2 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:
Code:
 # For booting FreeBSD
     title  FreeBSD
     root   (hd0,0,a)
     kernel /boot/loader
The portion of the Grub2 grub.cfg that boots ubuntu is”

Code:
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:
Code:
 # 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.Reply With Quote
  #2  
Unread January 2nd, 2013, 19:26
Beeblebrox's Avatar
Member
 
Join Date: Sep 2010
Posts: 609
Thanks: 32
Thanked 62 Times in 57 Posts
Default

Quote:
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.
__________________
9_stable - gcc46 - root on zfs - amd64
Douglas Adams: The fact that we live at the bottom of a deep gravity well, on the surface of a gas covered planet going around a nuclear fireball 90 million miles away and think this to be normal is obviously some indication of how skewed our perspective tends to be.
Reply With Quote



reply via email to

[Prev in Thread] Current Thread [Next in Thread]