Jump to content

GRUB2 as the only boot loader: it's possible!


  • Please log in to reply
58 replies to this topic

#21
kr4zyc1d

kr4zyc1d

    InsanelyMac Protégé

  • Members
  • Pip
  • 5 posts

I have exactly the same problem and I did install Grub to Linux partition, not the MBR.

/edit
Installed again, this time partitioned to ext4 and Linux shows up on boot disk list. On both times installed grub to sda2 but first time used ext3.


Any word on a fix? I have always done my formatting as ext4 and never got mine to show up on chameleon (with karmic that is). Are you saying that you got chameleon to show it?

#22
mm67

mm67

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 673 posts
  • Gender:Male
  • Location:Finland

Any word on a fix? I have always done my formatting as ext4 and never got mine to show up on chameleon (with karmic that is). Are you saying that you got chameleon to show it?


Yes, Linux is shown on Chameleon and I can boot to it.

/edit
I just remembered that I am actually using PC EFI 10.5, not Chameleon RC3 anymore. Don't know if that makes any difference.

#23
thorazine74

thorazine74

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 241 posts
  • Gender:Male
  • Location:Spain

I started experimenting with direct boot of 10.6.1 from grub2 yesterday. I don't have a multi-boot setup yet. It booted to the grub> prompt. It would never find the kernel. I talked to the guys on the #grub irc channel today and they said native boot of 10.6 is not supported yet.

Interesting... Rod's first report talked about voodoo so you can assume it was leo but the other poster got snow's kernel running up to the panic point.

#24
kr4zyc1d

kr4zyc1d

    InsanelyMac Protégé

  • Members
  • Pip
  • 5 posts
After a few days of trying different attempts, I am still having trouble making chameleon see my karmic partition. I have installed efi 10.5, and replaced the boot file and I kernel panic. I'm not quite sure where to go from here. I'm sure there is a solution for the problem, but nothing seems to be working. Is there something in Karmic that I should be doing? Thanks again guys.

matt

#25
saivert

saivert

    InsanelyMac Protégé

  • Members
  • PipPip
  • 71 posts
why do you guys assume GRUB2 can boot vanilla kernels?

#26
DB1

DB1

    InsanelyMac Sage

  • Donators
  • 407 posts

why do you guys assume GRUB2 can boot vanilla kernels?


Grub2 WIKI

#27
Azimutz

Azimutz

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 759 posts
  • Gender:Male
  • Location:Almadan - Pt.
  • Interests:At the moment, OSx86.. In general, music, audiophile, computers.. to much to mention...
For you guys having problems with Chameleon not showing Linux installation, this is how it works for me.
First, make sure you have a way to boot your installs if something goes wrong.. get Super Grub Disk, it will boot your Linux install if everything else fails. Also keep a pre-boot CD for OS X, you can make one with this app.. i'm mentioning a pre-boot CD because it's the only method i can trust atm.. use what ever works for you.
Tests i made were done using Ubuntu 9.10, selecting Grub to install to /.

First case.. GUID partitioned HD:
- the only problem here is that, Chameleon gets wiped out of MBR. yeah, even installing it to /.
Also, when configuring installation there's no mention of the "BIOS boot partition" creation.. i think that lead me to a second install, as the first one was not showing on Chameleon. I'm assuming Grub didn't got installed to the correct partition (or not installed at all) because of the creation of "BIOS boot partition" but, there's always the possibility i messed up ;) can't be sure atm.
I removed this install because, this breaks all the nice things DiskUtility can do to GUID HD's like resizing, deleting, adding partitions. I only did it to test Grub.. i already knew this would break from previous tests. Don't know if it's the presence of another file system or the fact that these installations don't use the same layout as OS X installs (no 128MB unallocated space between partitions).

Second case.. MBR partitioned HD:
- no problems with MBR being wiped here and no "BIOS boot partition" creation. A lot of problems caused by Extended/Logical partitions.
The only way i got this to work was by setting up a Primary partition for Ubuntu, after XP/Windows 7 and installing Ubuntu without Swap partition. I did a install providing Swap partition (on Extended partition) and it did show on Chameleon but then, Ubuntu would take forever to boot.. and i do mean "forever", so much i didn't had the patience to wait :P I'm a patient guy so... If you get the blinking cursor, wait a couple of minutes, probably it's booting slow.(*)
Letting Ubuntu do the partitioning always leads to the use of Extended partition, even if i only leave XP partition.

After this tests, this is my HD layout:
- Note: HD's are not in the correct order.. OS X insists on doing that a lot lately, more than usual..
Azi@AziLandz:~>dul  <strong class='bbc'><alias to "diskutil list"</strong>/dev/disk0  <strong class='bbc'><SATA 3</strong>   #:                       TYPE NAME                    SIZE       IDENTIFIER   0:      GUID_partition_scheme                        *500.1 GB   disk0   1:                        EFI                         209.7 MB   disk0s1   2:                  Apple_HFS Snow                    200.0 GB   disk0s2   3:                  Apple_HFS Home                    99.9 GB    disk0s3   4:                  Apple_HFS SnowLab                 30.0 GB    disk0s4   5:                  Apple_HFS Leo                     30.0 GB    disk0s5/dev/disk1  <strong class='bbc'><SATA 1</strong>   #:                       TYPE NAME                    SIZE       IDENTIFIER   0:     FDisk_partition_scheme                        *320.1 GB   disk1   1:               Windows_NTFS XP                      64.4 GB    disk1s1   2:               Windows_NTFS Windows_7               32.2 GB    disk1s2   3:                      Linux Ubuntu                  32.2 GB    disk1s3Extended partition   4:                 Linux_Swap                         2.1 GB     disk1s5   5:                  Apple_HFS Virtual                 53.7 GB    disk1s6   6:                  Apple_HFS Hyperspace              135.4 GB   disk1s7

As you can see i have the Swap partition, added later to the Extended partition. The thing is, the Swap partition is not activated at startup.. a simple way to activate it is by using GParted after you boot into the system. Anyway, unless you have small RAM size or you need to do some "heavy lifting", most probably the system wont use the Swap.

As a sort of conclusion:
- doing this on GUID HD is much easier. Just install manually, Chameleon boot0 back to MBR and Grub2 to the partition if it doesn't show on Chameleon.
- if you really have to do it to MBR HD, follow my testing and keep in mind, this can work different on your machine. Installing Grub2 manually didn't help in the cases were it didn't show up on Chameleon. It always shows a "not good idea" msg when installing to partition, even when install is successful. In the cases were Ubuntu was installed to Logical partition, manual Grub2 installation was never successful.

As for the real theme of this thread, one thing is certain, Grub2 is not prepared to deal with Snow.. it's not that difficult to understand why, just look at the path for system mkext on grub.cfg entries (first post).
Atm choosing any OS X installation to boot sends me back to Grub2 prompt. I did some attempts while testing.. they all ended up in kp. Will have to test this with more time and reading.

Hope this helps..
See ya.

Edits:
- One less important thing i forgot to mention.. Ubuntu always insisted on creating a 5,8MB unallocated space before the / partition, except when i left only the first one, XP.

(*): This just happened again, after i installed some updates on Ubuntu (including a Proposed update for Grub), rebooted, tried to boot OS X and booted Ubuntu again. A new reboot and another one, were ok. But, no audio.. grrrr.. this already happened while testing and booting with Super Grub Disk. It seems it's not SGD's fault!

Edited by Azimutz, 05 November 2009 - 03:14 AM.


#28
srs5694

srs5694

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 541 posts
  • Gender:Male
  • Location:Woonsocket, RI
[quote name='Azimutz' post='1320188' date='Nov 4 2009, 03:47 PM']First case.. GUID partitioned HD:
- the only problem here is that, Chameleon gets wiped out of MBR. yeah, even installing it to /.[/quote]

Unfortunately, the most common Linux GPT tools (GNU Parted and its GUI relatives) wipe out the boot loader from the MBR on GPT disks. I believe the logic is that EFI doesn't use this code, so it "should" be empty, and the partitioning tools make it so.

[quote]Also, when configuring installation there's no mention of the "BIOS boot partition" creation.. i think that lead me to a second install, as the first one was not showing on Chameleon. I'm assuming Grub didn't got installed to the correct partition (or not installed at all) because of the creation of "BIOS boot partition" but, there's always the possibility i messed up :) can't be sure atm.[/quote]

On a GPT disk, GRUB2 works best when a BIOS Boot Partition is present, since GRUB2 installs part of its code there. (This partition can be quite small -- 100KB is probably plenty big, although I'm not sure exactly how big it should be for GRUB2.) Without a BIOS Boot Partition, GRUB2 should still install and work, but it'll be more susceptible to failure if files get moved around on the boot partition.

I believe there's a way to create a BIOS Boot Partition in GNU Parted, but I don't recall the exact procedure. It's quite simple in GPT fdisk -- just create a partition and assign it a type code of ef02. (Note that GPT fdisk's type codes are unique to it; I used this scheme because the real GPT type codes are GUIDs, which are 16-byte numbers -- 21686148-6449-6E6F-744E-656564454649, in the case of the BIOS Boot Partition. Expecting users to type or remember such numbers is unreasonable.)

[quote]I removed this install because, this breaks all the nice things DiskUtility can do to GUID HD's like resizing, deleting, adding partitions. I only did it to test Grub.. i already knew this would break from previous tests. Don't know if it's the presence of another file system or the fact that these installations don't use the same layout as OS X installs (no 128MB unallocated space between partitions).[/quote]

I don't know precisely what Apple's Disk Utility requires of GPT disks in order to support resizing, but the 128MB between partitions is certainly a possibility. Apple specifies this as something that should be done for its disks, although it's not part of the GPT specification. IIRC, Microsoft's tools also create such a gap between partitions, but neither GNU Parted nor GPT fdisk enforces such a rule. (You can still create such layouts, but you'll need to set the start and end points to add this gap.) Apple also recommends aligning partitions on 4KB boundaries, apparently because of HFS+ issues. AFAIK, no non-Apple tool enforces that rule, either.

[quote]Second case.. MBR partitioned HD:
- no problems with MBR being wiped here and no "BIOS boot partition" creation. A lot of problems caused by Extended/Logical partitions.[/quote]

On MBR disks, I think (but am not positive) that GRUB2 installs part of its boot loader in the unpartitioned space between the MBR (the first sector of the disk) and the start of the first partition, which is normally sector 63. This effectively serves the same role as the BIOS Boot Partition on GPT disks.

[quote]Letting Ubuntu do the partitioning always leads to the use of Extended partition, even if i only leave XP partition.[/quote]

Most Linux distributions have taken to using simplified partitioning tools with few options as part of their install routines. IIRC, Fedora uses primary partitions exclusively unless you want more than three or four partitions, at which point it begins using logical partitions for the extras. I'm not intimately familiar with Ubuntu's installer, but it doesn't surprise me to hear that it does things differently, favoring logical partitions. FWIW, the lack of the primary/extended/logical partition distinctions is one of the big advantages of GPT over MBR.

[quote]As you can see i have the Swap partition, added later to the Extended partition. The thing is, the Swap partition is not activated at startup.. a simple way to activate it is by using GParted after you boot into the system. Anyway, unless you have small RAM size or you need to do some "heavy lifting", most probably the system wont use the Swap.[/quote]

Check your /etc/fstab file. In Linux, swap is defined there, in a line like this:

/dev/sda6	   none			swap	sw			  0	   0

The device identifier (/dev/sda6 in this example) may be replaced by something taking another form, such as a UUID, to make the system less susceptible to device ID changes. In any event, if you don't see a line like this, you can add one. If you do see such a line, verify that the device identifier is correct.

Although a system with plenty of RAM might not need swap for most things, having it is helpful insurance in case of an unusual RAM demand. It's also used for deep sleep modes (most useful on notebooks and netbooks); Linux stores its RAM snapshot to swap for quick recovery when it wakes up.

[quote]- One less important thing i forgot to mention.. Ubuntu always insisted on creating a 5,8MB unallocated space before the / partition, except when i left only the first one, XP.[quote]

I suspect this is related to cylinder alignment code in GNU Parted, upon which Ubuntu's partitioning tool is probably based. In some GNU GNU Parted variants I've seen, there's a check box to enable or disable cylinder alignment. Turning it on produces gaps at the starts and ends of the disk; turning it off eliminates those gaps. This feature is useful for producing MBR disks that are less likely to cause problems in older OSes, but AFAIK it's completely useless for GPT disks.

#29
kr4zyc1d

kr4zyc1d

    InsanelyMac Protégé

  • Members
  • Pip
  • 5 posts
Ok everyone, I have finally figured some things out and my system is up and running.

Originally I was trying to set up my system as so:

Sda1: testing blank partition
Sda2: Windows 7
Sda3: OSX
Sda4 - EXTENDED
Sda5: Karmic
Sda6: Swap
Sda7: Storage for docs

This setup worked great when I had Jaunty, but Karmic was giving me lots of trouble. After multiple installs and googling for hours, and thanks to some posts here, I quickly found out that Karmic does not like to be on an extended partition for some reason. So my thought process was simple. Swap OSX and the Karmic partitions. I did so, and I could never get OSX to boot off of the extended either. I am not sure why. However, since I hardly use the testing partition, I felt that it was in my best interest that I dump this and Keep it to three up front and swap and storage on the extended.

So I reformated and installed karmic and Os X, and restored an image of windows 7 I had to the 3 primary partitions up front on my drive.

During my Karmic install I made sure that I installed grub to that partition. The OSX install went normal as planned, and then I installed chameleon to that drive and the boot process works fine. Anyway, I hope this helps any of you that are running into the same issues that I have had. Thanks again for all of the help.

#30
thorazine74

thorazine74

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 241 posts
  • Gender:Male
  • Location:Spain

First case.. GUID partitioned HD:
- the only problem here is that, Chameleon gets wiped out of MBR. yeah, even installing it to /.
Also, when configuring installation there's no mention of the "BIOS boot partition" creation.. i think that lead me to a second install, as the first one was not showing on Chameleon. I'm assuming Grub didn't got installed to the correct partition (or not installed at all) because of the creation of "BIOS boot partition" but, there's always the possibility i messed up :D can't be sure atm.
I removed this install because, this breaks all the nice things DiskUtility can do to GUID HD's like resizing, deleting, adding partitions. I only did it to test Grub.. i already knew this would break from previous tests. Don't know if it's the presence of another file system or the fact that these installations don't use the same layout as OS X installs (no 128MB unallocated space between partitions).


I understand that chameleon can only chain boot linux by loading a partitions boot sector with grub in it (post #17), so if grub2 cannot be installed just there in a GPT disk and it needs to be in mbr and bios boot partition, I think its imposible to make it work with chameleon at its current state.

As for the real theme of this thread, one thing is certain, Grub2 is not prepared to deal with Snow.. it's not that difficult to understand why, just look at the path for system mkext on grub.cfg entries (first post).
Atm choosing any OS X installation to boot sends me back to Grub2 prompt. I did some attempts while testing.. they all ended up in kp. Will have to test this with more time and reading.


You are surely right about grub2 not being able to deal with snow but I doubt the mkext location error would stop it, if I understand the grub code right, it will just load the kexts from /S/L/E when it doesnt find /S/L/Extensions.mkext. I changed the grub entry to this:

[code
xnu_kernel /mach_kernel boot-uuid=${uuid} rd=*uuid
if [ /System/Library/Caches/com.apple.kext.caches/Startup/Extensions.mkext -nt /System/Library/Extensions ]$
xnu_mkext /System/Library/Caches/com.apple.kext.caches/Startup/Extensions.mkext
else
xnu_kextdir /System/Library/Extensions
fi
}[/code]

and it didnt make any difference, the panic that appears seem to be related to boot arguments, the same one as reported above:

panic(cpu 0 caller 0x2ac8d5): "Incompatible boot args version 1 revision 4\n"0/SourceCaches/xnu/xnu-1456.1.25/osfmk/i386/AT386/nodul_dmp.c:542

It seems to be traced to this file in the kernel source and this snipped of code:

/* Remap EFI runtime areas. */
void
hibernate_newruntime_map(void * map, vm_size_t map_size, uint32_t system_table_offset)
{
	boot_args *args = (boot_args *)PE_state.bootArgs;

	kprintf("Reinitializing EFI runtime services\n");

	if (args->Version != kBootArgsVersion1)
	return;
	do
	{
		vm_offset_t vm_size, vm_addr;
	vm_map_offset_t phys_addr;
	EfiMemoryRange *mptr;
	unsigned int msize, mcount;
	unsigned int i;

	gPEEFISystemTable	 = 0;
	gPEEFIRuntimeServices = 0;

	system_table_offset += ptoa_32(args->efiRuntimeServicesPageStart);

	kprintf("Old system table 0x%x, new 0x%x\n",
		(uint32_t)args->efiSystemTable,	system_table_offset);

	args->efiSystemTable	= system_table_offset;

	kprintf("Old map:\n");
	msize = args->MemoryMapDescriptorSize;
	mcount = args->MemoryMapSize / msize;
	mptr = (EfiMemoryRange *)ml_static_ptovirt(args->MemoryMap);
	for (i=0; i < mcount; i++, mptr = (EfiMemoryRange *)(((vm_offset_t)mptr) + msize)) {
		if ((mptr->Attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {

		vm_size = (vm_offset_t)i386_ptob((uint32_t)mptr->NumberOfPages);
		vm_addr =   (vm_offset_t) mptr->VirtualStart;
		phys_addr = (vm_map_offset_t) mptr->PhysicalStart;

		kprintf("mapping[%u] %qx @ %lx, %llu\n", mptr->Type, phys_addr, (unsigned long)vm_addr, mptr->NumberOfPages);
		}
	}

	pmap_remove(kernel_pmap, i386_ptob(args->efiRuntimeServicesPageStart), 
				 i386_ptob(args->efiRuntimeServicesPageStart + args->efiRuntimeServicesPageCount));

	kprintf("New map:\n");
	msize = args->MemoryMapDescriptorSize;
	mcount = (unsigned int )(map_size / msize);
	mptr = map;
	for (i=0; i < mcount; i++, mptr = (EfiMemoryRange *)(((vm_offset_t)mptr) + msize)) {
		if ((mptr->Attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {

		vm_size = (vm_offset_t)i386_ptob((uint32_t)mptr->NumberOfPages);
		vm_addr =   (vm_offset_t) mptr->VirtualStart;
		phys_addr = (vm_map_offset_t) mptr->PhysicalStart;

		kprintf("mapping[%u] %qx @ %lx, %llu\n", mptr->Type, phys_addr, (unsigned long)vm_addr, mptr->NumberOfPages);

#if defined(__i386__)
		pmap_map
#elif defined(__x86_64__)
		pmap_map_bd /* K64todo resolve pmap layer inconsistency */
#endif
			(vm_addr, phys_addr, phys_addr + round_page(vm_size),
			 (mptr->Type == kEfiRuntimeServicesCode) ? VM_PROT_READ | VM_PROT_EXECUTE : VM_PROT_READ|VM_PROT_WRITE,
			 (mptr->Type == EfiMemoryMappedIO)	   ? VM_WIMG_IO   : VM_WIMG_USE_DEFAULT);
		}
	}

		if ((args->Version != kBootArgsVersion1) || (args->Version == kBootArgsVersion1 && args->Revision < kBootArgsRevision1_5 ))
			panic("Incompatible boot args version %d revision %d\n", args->Version, args->Revision);

		kprintf("Boot args version %d revision %d mode %d\n", args->Version, args->Revision, args->efiMode);
		if (args->efiMode == kBootArgsEfiMode64) {
		efi_set_tables_64((EFI_SYSTEM_TABLE_64 *) ml_static_ptovirt(args->efiSystemTable));
		} else {
		efi_set_tables_32((EFI_SYSTEM_TABLE_32 *) ml_static_ptovirt(args->efiSystemTable));
		}
	}
	while (FALSE);

	kprintf("Done reinitializing EFI runtime services\n");

	return;
}

I'm not a coder so I dont really understand whats going wrong, something related with memory remapping?

Can someone confirm if we need to load efiemu? I understand that IT IS NEEDED to boot Mac OS X kernels on non-EFI machines, the fact that osprober script that creates the built-in grub.cfg entry for OS X doesnt put it there it could be only because it is made for real macs which doesnt need it, but I'm not sure if the modules would get autoloaded when needed (i.e. if xnu_kernel finds out it cant load the kernel without efiemu, would it be loaded automatically or not?)

I tried to play with the efiemu commands but arrived no where :-(
These are the mods to grub.cfg I tried:
insmod efiemu
# use only one, 32 or 64
# efiemu_loadcore /boot/grub/efiemu64.o
efiemu_loadcore /boot/grub/efiemu32.o
efiemu_pnvram
efiemu_prepare

But it made no difference at all...
Maybe an updated grub2 package or compilation will fix it, I was just using the built-in Kubuntu 9.10 package.



This setup worked great when I had Jaunty, but Karmic was giving me lots of trouble. After multiple installs and googling for hours, and thanks to some posts here, I quickly found out that Karmic does not like to be on an extended partition for some reason.


I cant confirm this, I got Karmic installed to a logical partition with grub2 installed onto it, and it boots and works just fine from there, it shows up in pcefi 10.5, never tried to boot it from there though as I use BootIt NextGen to multiboot but I cant see why it would not work.

#31
drbrando007

drbrando007

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 4 posts

And could you maybe give an example of how that would look?

Been trying with this but can not get it to work. I have saved the MBR from the working USB-stick to /boot/chameleon.mbr and I have added this in grub.config:

menuentry "MacOS X, chameleon" {
			  set root=(hd0,2)
			  chainloader (hd0,6)/boot/chameleon.mbr +1
	  }

hd0,2 is the SnowLeo partition and hd0,6 is my Ubuntu-partition. I end up at a black screen with the text:

y-MORE--


yo - here is grub.cfg for leopard 10.5.7 - this should give you the way to go for snow leopard - no uuid's neccessary and I'll show you my insmod loaded before the menuentries--
i won't ditch chameleon, it very intelligently detects all partitions on an sd that have a boot loader - try to use multiboot as per below

[code=auto:0]
...
insmod linux
insmod terminal
insmod boot
insmod 915resolution
insmod video
insmod jpeg
915resolution 34 1366 768
set gfxmode=1366x768
...
menuentry "**********XxX********** Leopard (/dev/sda1)" {
set root=(hd0,1)
multiboot (hd0,1)/boot
}
[code=auto:0]

Works flawlessly for me, I had to mod the resolution to get my native.

cheers
-TheFugitive
EDIT: This works for the grub-1.96 package on 32bit. Am currently working on a 915resolution to grub-1.98 64bit. And then next week, will be working on grub-1.98 resolution for SnowLeopard 10.6.3 - Hope that helped

#32
陈小龙

陈小龙

    InsanelyMac Protégé

  • Members
  • Pip
  • 37 posts
I have it set up the same way as drbrando007, except I made a script in the Grub config directory, so every time Ubuntu updates the kernel and the Grub entries, the Chameleon option remains.

I made a script as /etc/grub.d/11-OSX86

#!/bin/sh
  exec tail -n +3 $0
echo "Adding Chameleon Entry..." >&2
  menuentry "Chameleon" {
		  set root=(hd0,0)			   <-------------Your partition number.
		  multiboot (hd0,0)/boot	   <-------------Your partition number.
  }

and made it executable

sudo chmod a+x /etc/grub.d/11-OSX86

#33
shikhar623

shikhar623

    InsanelyMac Protégé

  • Members
  • PipPip
  • 68 posts
  • Gender:Male
  • Location:NBA

I've been playing around with the GRUB2 boot loader a bit recently, and I've run across some interesting references. To summarize what I've found, it's possible to use GRUB2 as the only boot loader to boot both Linux and OS X. That is, there's no need for PC-EFI, Chameleon, Boot Think, etc. GRUB2 will also boot Windows, although it does need the help of the 2nd-stage Windows boot loader (BCD, I believe it's called). The end result is one menu for all your OSes. This configuration also reduces the chances of problems from one boot loader overwriting another one's files.

So, let's back up a bit. GRUB2 is the next generation of the GRUB boot loader. (The original is now called "GRUB Legacy.") GRUB2 is still officially in beta, but I've been using it on my multi-boot laptop for a while (currently SUSE Linux 11.0, OS X 10.5.6, and Windows 7 RC). GRUB2 is designed to be more modular than GRUB Legacy, it's multi-platform, and it's got various other enhancements. Two of these are limited EFI emulation support and support for loading XNU kernels.

I'm going to assume in the following that you know a bit about Linux, software compilation, and GRUB or GRUB2 installation and configuration. If you don't, try Googling on these topics to find some tutorials.

My initial tests, using a GRUB2 RPM intended for Fedora 10 systems, were less than successful. To get OS X booting, I had to download the grub-1.97~beta3.tar.gz source code tarball from the GRUB Web site and compile it locally. (I compiled under Linux. A quick attempt under OS X failed, but it's conceivable this problem could be overcome.)

If you're familiar with GRUB but not GRUB2, you should be aware that the configuration file name and syntax have changed. The new filename is /boot/grub/grub.cfg. Some of the configuration file changes will be obvious below, but note that GRUB2 numbers partitions differently. What was (hd0,0) in GRUB Legacy is (hd0,1) in GRUB2, with corresponding changes to other partition numbers. Below are the three entries I'm using to boot Linux, Windows, and Mac OS X:

menuentry "openSUSE 11.0 - 2.6.25.20-0.5" {
	 set root=(hd0,3)
	 linux /boot/vmlinuz-2.6.25.20-0.5-default root=/dev/sda3 showopts
	 initrd /boot/initrd-2.6.25.20-0.5-default
 }
 
 menuentry "Windows 7 RC" {
	 set root=(hd0,7)
	 chainloader +1
 }
 
 menuentry "Mac OS X" {
	 set root=(hd0,6)
	 insmod video
	 insmod vbe
	 gfxmode="1280x800x32"
	 xnu_kernel /mach_kernel rd=disk0s6
	 if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
		xnu_mkext /System/Library/Extensions.mkext
	 else
		xnu_kextdir /System/Library/Extensions
	 fi
 }

If you try something similar, pay careful attention to system-specific items, such as the disk and partition identifiers and the video mode. After setting this up, typing "/usr/local/sbin/grub-install /dev/sda" installed it for me, including copying a boatload of files to the /boot/grub directory. The explicit path to /usr/local/sbin ensures that I installed my locally-compiled GRUB2 rather than the distribution's standard GRUB. The new files in /boot/grub hold the modular GRUB2 components, such as filesystem drivers, the EFI emulation code, etc.

A few random comments:

  • The system boots in verbose mode, similar to passing the "-v" parameter via Chameleon or some other traditional OSx86 boot loader. I haven't yet figured out if it's possible to get a more GUI boot out of GRUB2.
  • My test system is running a Voodoo kernel. I know of no reason other kernels wouldn't work, but I've also not tested them.
  • My system has a hybrid MBR, which GRUB sees as GPT. I haven't tried this on an MBR-only system. I have no reason to think it wouldn't work, but I thought I'd point out this detail.
  • On GPT disks, GRUB2 likes to have a small (a few tens or hundreds of KB) partition of type "BIOS boot partition" in which it can install its second-stage boot loader. It will work without this partition, but such a partition is recommended.
  • I haven't yet investigated ways to pass additional parameters to the system (-f, -x, etc.).
  • GRUB2 allows you to edit its entries on the fly, so you can make boot-time changes. IIRC, you press the 'e' key when the menu comes up and you can edit the menu item.
  • I've reconfigured my system to use an HFS+ /boot partition (in Linux) so that I can edit the grub.cfg file in either OS. This seems fine so far, but it's only been set up this way for a short time. FAT might also work, but my experience is that some GRUB and GRUB2 configurations rely on symbolic links, which aren't supported in FAT. Oddly, the OS X Disk Utility deleted my EFI System partition and reverted my hybrid MBR to a plain GPT setup when I used it to format the /boot partition. Both problems were easily rectified, but annoying.
  • GRUB2 is not yet common on emergency disks. GRUB-2 includes a grub-mkrescue command that I believe creates emergency boot disks (USB flash drives, CD-ROMs, etc.), but I've not yet tested this.
  • So far I've tested this on only one system. I've got another multi-boot system with which I might test this configuration, but I haven't gotten around to it yet.

Overall, I wouldn't recommend that everybody ditch Chameleon, Boot Think, etc. in favor of GRUB2. It might be worth considering such a configuration if you dual-boot with Linux or some other OS that relies upon GRUB or GRUB2, though. This will give you one boot loader configuration file and a reduced risk of problems from one boot loader stepping on another's feet, as it were. If possible, I recommend keeping a second boot path option available -- in other words, a GRUB2 option to boot via Chameleon, Boot Think, PC-EFI, or whatever. This might be handy if GRUB2 suddenly stops liking your XNU kernel or something.


Will above method work for iAtkos_v7 ?

#34
rorhro

rorhro

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 3 posts
Sorry guys...I am new and my English is very poor. I am trying to understand how to solve some issue with grub 2. This is my problem

I followed various forums in order to have 3 different OS on my old Pentium 4.
Jas 10.4.8 works fine. Then I installed XP on a different primary partition. The same with Ubuntu 9.10.

When rebooting I can chose from Grub 2 which OS to use. XP works fine, Ubuntu fine BUT when I chose Mac Os X I just get some strange commands line....and I cant boot

panic(cpu 0 caller 0x001a3129) unresolved kernel, trap (CPU, type 14 page fault)

and so on......

what is wrong...

sorry but I am really new and sorry for my english, but your hel will be really appreciate

Sorry guys...I am new and my English is very poor. I am trying to understand how to solve some issue with grub 2. This is my problem

I followed various forums in order to have 3 different OS on my old Pentium 4.
Jas 10.4.8 works fine. Then I installed XP on a different primary partition. The same with Ubuntu 9.10.

When rebooting I can chose from Grub 2 which OS to use. XP works fine, Ubuntu fine BUT when I chose Mac Os X I just get some strange commands line....and I cant boot

panic(cpu 0 caller 0x001a3129) unresolved kernel, trap (CPU, type 14 page fault)

and so on......

what is wrong...

sorry but I am really new and sorry for my english, but your hel will be really appreciate


#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
have_grubenv=true
load_env
fi
set default="5"
if [ ${prev_saved_entry} ]; then
saved_entry=${prev_saved_entry}
save_env saved_entry
prev_saved_entry=
save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set 7a59e598-8f7d-49ac-beee-84e805090ec0
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=20
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/white
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set 7a59e598-8f7d-49ac-beee-84e805090ec0
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=7a59e598-8f7d-49ac-beee-84e805090ec0 ro splash quiet splash
initrd /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set 7a59e598-8f7d-49ac-beee-84e805090ec0
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=7a59e598-8f7d-49ac-beee-84e805090ec0 ro single splash
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Mac OS X (on /dev/sda1)" {
insmod hfsplus
set root=(hd0,1)
search --no-floppy --fs-uuid --set d8d3935e73aae5d9
insmod vbe
do_resume=0
if [ /var/vm/sleepimage -nt10 / ]; then
if xnu_resume /var/vm/sleepimage; then
do_resume=1
fi
fi
if [ $do_resume == 0 ]; then
xnu_uuid d8d3935e73aae5d9 uuid
if [ -f /Extra/DSDT.aml ]; then
acpi -e /Extra/DSDT.aml
fi
xnu_kernel /mach_kernel boot-uuid=${uuid} rd=*uuid
if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
xnu_mkext /System/Library/Extensions.mkext
else
xnu_kextdir /System/Library/Extensions
fi
if [ -f /Extra/Extensions.mkext ]; then
xnu_mkext /Extra/Extensions.mkext
fi
if [ -d /Extra/Extensions ]; then
xnu_kextdir /Extra/Extensions
fi
if [ -f /Extra/devtree.txt ]; then
xnu_devtree /Extra/devtree.txt
fi
if [ -f /Extra/splash.jpg ]; then
insmod jpeg
xnu_splash /Extra/splash.jpg
fi
if [ -f /Extra/splash.png ]; then
insmod png
xnu_splash /Extra/splash.png
fi
if [ -f /Extra/splash.tga ]; then
insmod tga
xnu_splash /Extra/splash.tga
fi
fi
}
menuentry "Windows XP Media Center Edition (on /dev/sda2)" {
insmod ntfs
set root=(hd0,2)
search --no-floppy --fs-uuid --set 59ab94f45db861f0
drivemap -s (hd0) ${root}
chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

#35
l3osx

l3osx

    InsanelyMac Protégé

  • Members
  • Pip
  • 7 posts

Sorry guys...I am new and my English is very poor. I am trying to understand how to solve some issue with grub 2. This is my problem

I followed various forums in order to have 3 different OS on my old Pentium 4.
Jas 10.4.8 works fine. Then I installed XP on a different primary partition. The same with Ubuntu 9.10.

When rebooting I can chose from Grub 2 which OS to use. XP works fine, Ubuntu fine BUT when I chose Mac Os X I just get some strange commands line....and I cant boot

panic(cpu 0 caller 0x001a3129) unresolved kernel, trap (CPU, type 14 page fault)

and so on......


If you have Chameleon installed to your OS X partition, you can load it via Grub 2 by doing the following:

1. Boot into Ubuntu, open a terminal and type:
sudo gedit /etc/grub.d/40_custom

Then use one of the following entries to put into this file and save the file (credit goes to thorazine74's post from this thread)


or

menuentry "Mac OS X Chameleon" {         insmod hfsplus         set root=(hd0,X)         multiboot /boot}

where X in (hd0,X) is the partition number; in your case, X = 1
The title between the " " above can be anything; it doesn't have to be Mac OS X Chameleon.

2. After saving the 40_custom file and closing it, at the terminal type:
sudo update-grub
This will update the grub.cfg file.

Now reboot and you should see the custom entry you made in Grub 2 and it should boot to Chameleon and you can then boot OS X. This works with Chameleon 2.0 RC3 and RC4; I don't know if it works with older Chameleon versions. You can update to these Chameleon versions if necessary.

#36
vivelapsp

vivelapsp

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 1 posts
Hi all,

I have read all your topics and if i have well understanded (i'm french...), you can't launch mac os x with grub2 without have chameleon install on your computer, isn't it ?

I have installed iATKOS_v7 on my pc, but before installation, i have unchecked the chameleon boot loader (for use grub2). So, i can't use your methods for boot chamelon with grub2. I have to install chameleon (still if i have all well understanded), but how do that without erase my grub2 ??

Hope you will understand me,
vivelapsp

#37
Penguin X

Penguin X

    InsanelyMac Protégé

  • Members
  • Pip
  • 27 posts

<br />Hi all,<br /><br />I have read all your topics and if i have well understanded (i'm french...), you can't launch mac os x with grub2 without have chameleon install on your computer, isn't it ?<br /><br />I have installed iATKOS_v7 on my pc, but before installation, i have unchecked the chameleon boot loader (for use grub2). So, i can't use your methods for boot chamelon with grub2. I have to install chameleon (still if i have all well understanded), but how do that without erase my grub2 ??<br /><br />Hope you will understand me,<br />vivelapsp<br /><br />


You CAN use grub2 WITHOUT Chameleon.
Just follow 1st post.
Install grub2 or update grub2 it should find the osx install.
On your linux-Partition: In your /boot/grub/grub.cfg - file replace the uuid stuff with your actual partition!
Example:
xnu_kernel64 /mach_kernel boot-uuid=${uuid} rd=*uuid
replace:
rd=... with: rd=disk0s1 (s1 for sda1)

then grub2 will boot, I think.

#38
ppoomm

ppoomm

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 1 posts
ขอบคุณครับ (Thank you in thai) ^0^ i'm so happy now my notebook working in 3 OS (very thank)

#39
Methanoid

Methanoid

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 114 posts
  • Location:Brittania
Someone still not figured out how to get a GUI-only boot (ie no verbose)? Does booting to Chameleon give GUI only?

#40
Jonas Grey

Jonas Grey

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 2 posts
some success here -- I'm expecting a Mini 9 from the UPS soon, and I want a dual boot w/o the Chameleon thing if possible (discrete, inconspicuous, etc) so I'm experimenting on my GA-EP45-UD3r and a spare HD to see what might be possible (if anything).

I'm using a 32 bit Ubuntu minimal install CD (like 12 mb or something), then building it up manually -- with Windowmaker, gdm, and some basic stuff -- Firefox, Opera, Chrome, Open Office, Xmms2 w/ Promoe or something, VLC, mplayer, etc... I'm looking at a Linux install of -- well, I'm going to try to reserve 2.5 gigs including swap -- my Linux build is up to 1.8 Gigs of hard drive utilization or so and is only bound to grow as I continue to add a little bit of stuff here and there -- but it's really only mostly for show so I don't really need the space I just want to have the dual boot so that I'm not showing off the OS X all the time -- plus the hfsplus package gives me read/write on the hfs+ partition anyway -- so maybe 2.25 gigs + 250megs swap or something? -- for my roll-your-own Ubuntu, the rest of the 16GB SSD will go to OS X.

So here's what my weekend of experimentation has taught me. GRUB2 (technically 1.97 beta 4 in Ubuntu 9.10 karmic) does in fact boot the hfs+ partition w/o the apple logo. But can I do it with the GUID partition? MBR is no problem, BTW, but you might need an iPC or something along those lines, retail seems to be easier with the GUID, so I'd rather do retail with GUID. That's the plan, anyway.

I install Leopard (not Snow) with a GUID partition table -- basically, fire up the install method, plop in the install disk, and when it comes to interrupting the process to go to Disk Utility, I "partition" with 3 partitions -- one for the Linux, one for the swap, and one for the hfs+. I left the swap and Linux parts (the hfs+ is the tail end of the disk) as empty space. Install as normal, options says GUID, name the one partition whatever, install to it when you exit out of Disk Utility.

Install proceeds as normal, reboot, registration screen, etc. I install Chameleon, and it works just fine, all I need now is kexts for the sound card and maybe another thing or two. Worry about that later.

So I reboot and it's working on its own, I plop in the Ubuntu minimal install CD, and reboot. If you're not familiar with the "cli" -- command line install, well, anyway, I've used Linux for about a decade, that's another post for another time.

I partition manually, and there's all these partitions (like 6 of them or something, a few small GUID ones or whatever). I leave the hfs+ partition and a 130 something megabyte partition on the far side of (end of the disk) that says empty space, but I delete everything else in front of it, leaving the swap. Now I have empty space, swap, and hfs+, and a 130 something megabyte partition on the other side of the hfs+ which I just left there (think it said empty space). I re-create the Linux (I chose xfs) partition, make it bootable, leaving the swap intact. Now the xfs partition is #1, the hfs+ partition is #2, and the swap is partition #4 (I deleted a EFI partition in there somewhere). Just leave the hfs+ intact -- it's the only thing I left intact -- and don't worry -- GRUB2 will boot it up for you, right?

Now the one thing -- I delete the swap 'cause it's #4 and not #3, recreate the swap, and now it's partition #3.

Then I install Ubuntu -- it's a quick process, it downloads the basic system (about 10-15 mins) and asks you time zones and things like that. Where it kept failing for me was on the GRUB install -- the command line interfaces asks you to specify where you want to install GRUB, and I used GRUB terminology -- (hd0), then I tried (hd0,1), etc... to no avail. But the installer also lets you use the /dev thing, so I tried specifying /dev/sda and it worked! Or was that /dev/sda1 -- I don't remember 100% -- I was trying all sorts of things over and over (I'm pretty sure it was /dev/sda though) Installed grub2 to /dev/sda and completed the Linux install process -- reboot, and voila -- there it is -- Grub's menu says "Mac OS X (on /dev/sda2)" as a selection, select it and I'm in. No messing with the menu.lst, it's automatically detected.

So that's it -- use a distro that uses Grub2, and at least with Ubuntu's command line installer (which is actually quite a cinch if you asked me) specify the "dev/sdx" format, not the (hdx,x) grub format on the command line install when it asks you towards the end, and when you partition near the start of the process, basically delete all the partitions except the hfs+ -- clean that disk up -- keep the one OS X partition, non-blessed, perhaps, and GRUB should detect it, list it, and boot it up for you. Of course, YMMV.

URL's that were important to me throughout this whole process:

Ubuntu minimal install: https://help.ubuntu....ation/MinimalCD

Install on Low Memory Systems (may be relevant, may by not): https://help.ubuntu....owMemorySystems

Grub2 Title Tweaks: http://ubuntuforums....d.php?t=1287602

Anyway, it's working now on my Gigabyte board. Disk utility still says GUID Partition table, I'm assuming that Chameleon is gone or inaccessible -- I don't think it's actually possible to get to it at all even if it isn't gone, it would probably would need to be reinstalled and GRUB removed or something, but I'd rather have grub in this particular instance anyway, which was the whole point of this exercise for me -- doing it with grub.

Anyway, will have to wait and see if it works on the Mini 9, but it works just 100% great on the Gigabyte board, flawlessly. If only it was my main computer and not a testbed I'd be totally psyched.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy