Author Topic: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive  (Read 80189 times)

0 Members and 1 Guest are viewing this topic.

digital_dreamer

  • Observer
  • Posts: 11
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #15 on: July 19, 2011, 02:41:06 AM »
Just to clarify and make sure I understand the changes:
From r1173, boot0 now takes on its previous role as just the booter that prefers active partitions first (with no config changes)?
And, the new bootmd is like boot0hfs (which, itself, is no longer being made) - prefers bootable HFS+ partitions first - but with added functionality of searching all disks accessible by BIOS and loading the Chameleon GUI even when the WIN install is the first boot disk?
This eliminates the need to select the Mac OS X drive in the BIOS first <F12>, if a WIN install is first in BIOS list, as previously you needed the Mac OS X install on the first drive in the BIOS priority list for the Chameleon bootloader to load.

Am I on the right track?  :P

Nice to see progress here. Thanks for all the work being done!

regards,
MAJ

P.S. Oh, and I agree about making boot0 and boot0hfs separate. (it's bootmd now, right? Or, boot0md? Shouldn't we name it according to the stage?)
I'm having to add a new portion in my script just to test which booter is actually being used, just to make sure the right one is being compiled and installed. You never know when they share the same name - you have to compare the dump. Here's my test of the installed boot0 booter: a 12-byte dump at offset 105, where the opcodes appear to change:
Code: [Select]
if [[ $(dd if="/dev/disk${DK_ID:0:1}" bs=440 count=1 2>/dev/null | od -A n -j 105 -N 12 -t x | sed 's/ //g') = "803c800af6301475800008e9" ]];then
BOOT0_TYPE="prefers active partitions first"
elif [[ $(dd if="/dev/disk${DK_ID:0:1}" bs=440 count=1 2>/dev/null | od -A n -j 105 -N 12 -t x | sed 's/ //g') = "047c800bb61375af0007e901" ]];then
BOOT0_TYPE="prefers bootable HFS+ partitions first"
else
BOOT0_TYPE="Unknown! Dump at offset 105: "$(dd if="/dev/disk${DK_ID:0:1}" bs=440 count=1 2>/dev/null | od -A n -j 105 -N 12 -t x | sed 's/ //g')
fi
Haven't tested for the bootmd booter, yet, though.

Azimutz

  • VoodooLabs
  • Posts: 420
  • Paranoid Android
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #16 on: July 19, 2011, 04:42:13 AM »
d_dreamer,
i have the feeling i already explained you about "make config" and default Chameleon build settings, haven't i??
Don't kill your neurons thinking so much :P soon all the boot0 files will have their respective names.
Meanwhile, compile them your self or get them from here; boot0 is the good old boot0, boot0hfs is the old boot0hfs
and boot0md is explained on this topic ;) try it!
 System & Patches: http://goo.gl/i961
 Chameleon:
- trunk builds: http://goo.gl/9G1Hq
- pref pane: http://goo.gl/OL2UT

digital_dreamer

  • Observer
  • Posts: 11
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #17 on: July 19, 2011, 05:19:06 AM »
 :lol:

Yes, Azimutz, you've already described the "make and "make config" stuff quite well and I'm using your tips (and meklort's). Thank you!
I was thinking out loud. Really loud.  ;D

best of wishes,
MAJ

Azimutz

  • VoodooLabs
  • Posts: 420
  • Paranoid Android
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #18 on: July 19, 2011, 09:20:52 AM »
And i was just messing a bit with you ;)

Stay safe
 System & Patches: http://goo.gl/i961
 Chameleon:
- trunk builds: http://goo.gl/9G1Hq
- pref pane: http://goo.gl/OL2UT

peter_sm

  • Entrant
  • Posts: 2
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #19 on: July 19, 2011, 07:03:32 PM »
Hi,

This looks great with the new  boot0md, but how would this be for me ?

I have 2 HD in my laptop, but I can't change what HD I like to boot from in my BIOS,(pressing  esc, F9), it let me chose only primary HD.

I rely like to have the windows 7 back up working  ;D

Should I perhaps shift the 2 hard drive and let the OSX HD be my secondary and W7 HD my primary ?

My spec of my Laptop is below.
Code: [Select]
HP DV8t-1290e0 (WN916EA#UUW) | 1.60 GHz Intel Core i7-720QM | nVidia GeForce GT 230M w/ 1024MB | 18.4" 1920 x 1080 display | 6 GB DDR3 (1 x 2048 MB + 1 x 4096 MB) |2 x 500 GB SATA Hard Disk Drive 7200 rpm| Atheros AR928X Wireless Network Adapter |OS X 10.6.8 & LION GM & Win7 Ult x64 SP1

EDIT

Shifted my 2 HD so my W7 is primary, and my backu up on W7 is just now running  :lol no: :lol:

//Peter
« Last Edit: July 19, 2011, 08:20:35 PM by peter_sm »

meklort

  • VoodooLabs
  • Posts: 65
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #20 on: July 20, 2011, 06:54:11 AM »
One additional suggestion: please consider making boot0.s and boot0hfs.s code as separate source files to allow one 'make' to do all the job without switching config flags.
Compiling with make is done by many users very often and would be better to make this as easy as possible. Boot0 code changes are made by developers not more then once per year, I guess, and in that rare case developers should/could take care of that duplicate code (copy the change to the other file as well).

I've separated boot0 and boot0hfs into two separate files.
return c ? c : !c;

Enzo

  • Resident
  • Posts: 256
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #21 on: July 20, 2011, 09:22:19 PM »
This is great, I would no longer have to unplug the OS X HDD to be able to install SP1 =P.

dmazar

  • Member
  • Posts: 52
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #22 on: July 20, 2011, 11:56:08 PM »
Let me know if you feel that boot0 can be replaced in it's entirety with boot0md (I'd prefer this).
The only reason I know for using the original boot0 is as Zef posted, in that if the user has an HDD with two HFS partitions both installed with boot1h/boot then they could choose which partition to use by setting the active flag. In this case two versions of boot0 are still required and I can't see how one boot0 could cater for all situations.
I'll think about it, but it seems you'll have to keep boot0 as is.

It seems it will be possible to make one universal boot0. But before that I'll write down simplified explanation for each boot0 version. It helps me to see what's going on. I hope I did not make mistakes there ...

boot0:
------
for the boot drive only:
- Pass1:
    - searches MBR partition table for an active bootable partition and boots it
    - if not found and disk is actually GPT, then searches for the first HFS+ bootable
      partition (or EFI with boot1f32) in the GPT array and boots it
    - if still not found, then continues with Pass2
   
- Pass2:
    - searches MBR partition table for a first HFS+ bootable partition and boots it
    - if not found and disk is actually GPT, then searches for the first HFS+ bootable
      partition (or EFI with boot1f32) in the GPT array and boots it
    - if still not found, then finishes with "boot0: error"


boot0hfs:
------
for the boot drive only:
- Pass1:
    - searches MBR partition table for a first HFS+ bootable partition and boots it
    - if not found and disk is actually GPT, then searches for the first HFS+ bootable
      partition (or EFI with boot1f32) in the GPT array and boots it
    - if still not found, then continues with Pass2

- Pass2:
    - searches MBR partition table for an active bootable partition and boots it
    - if not found and disk is actually GPT, then searches for the first HFS+ bootable
      partition (or EFI with boot1f32) in the GPT array and boots it
    - if still not found, then finishes with "boot0: error"
   

boot0md:
------
- Pass1:
    - iterates over all drives and for each drive:
        - searches MBR partition table for the first HSF+ bootable partition and boots it
        - if not found and disk is actually GPT, then searches for the first HFS+ bootable
          partition (or EFI with boot1f32) in the GPT array and boots it
        - if still not found, then continues with the next drive
    - if all drives are searched and nothing found, then continues with Pass2

- Pass2:
    - iterates over all drives and for each drive:
        - searches MBR partition table for the first active bootable partition and boots it
        - if not found and disk is actually GPT, then searches for the first HFS+ bootable
          partition (or EFI with boot1f32) in the GPT and boots it
        - if still not found, then continues with the next drive
    - if all drives are searched and nothing found, finishes with "boot0: error"


Bootable partition above means a partition with the boot sector signature (0xAA55) at the end of the partition boot sector.
Drives are searched (boot0md) in the order defined in the BIOS. Drive which is selected as the boot drive is searched first.

Few conclusions from the above:
----
boot0, boot0hfs and boot0md behaves differently only if booted from MBR or hybrid discs, while if booting from GPT disks they do the same: boot first HFS+ partition.

Active partition exists only on MBR or hybrid discs and can be used with boot0. There is no such equivalent on GPT disks. If somebody wants to load Chameleon from some other HFS+ partition, one solution is to make that one bootable (install Chameleon on it) and other HFS+ partitions not bootable by overwriting boot sector signature 0xAA55 with something else. If somebody is inspired, make a script for making some partition bootable/not-bootable and we'll have active partition equivalent on GPT.

There are some redundant steps in the above code (constant check for GTP disk), but that's how it is now. It's redundant, but does not cause any harm.

Later added  "(or EFI with boot1f32)" since I forgot that.
« Last Edit: July 22, 2011, 10:20:27 PM by dmazar »

dmazar

  • Member
  • Posts: 52
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #23 on: July 20, 2011, 11:57:37 PM »
Back to "universal" boot0. I think I can add one more pass to boot0md with minimal changes to the existing code. This would cover searching for active HFS+ partition in MBR plus boot0md (extended boot0hfs) functionality.

boot0work: (work in progress)
------
// part of boot0 special functionality
- Pass1:
    - for the boot drive only:
        - searches MBR partition table for an active HSF+ bootable partition and boots it
        - if not found and disk is actually GPT, then searches for the first HFS+ bootable
          partition (or EFI with boot1f32) in the GPT array and boots it
        - if still not found, then continues with Pass2

// the following is the same as for boot0md which is extended boot0hfs
- Pass2:
    - iterates over all drives and for each drive:
        - searches MBR partition table for the first HSF+ bootable partition and boots it
        - if not found and disk is actually GPT, then searches for the first HFS+ bootable
          partition (or EFI with boot1f32) in the GPT array and boots it
        - if still not found, then continues with the next drive
    - if all drives are searched and nothing found, then continues with Pass3

- Pass3:
    - iterates over all drives and for each drive:
        - searches MBR partition table for the first active bootable partition and boots it
        - if not found and disk is actually GPT, then searches for the first HFS+ bootable
          partition (or EFI with boot1f32) in the GPT and boots it
        - if still not found, then continues with the next drive
    - if all drives are searched and nothing found, finishes with "boot0: error"


I'm 99% sure I can make it. Have code for it which compiles (nasm works on Win laptop), but can not test it until I get back home. If anybody feels adventurous and wishes to mess with MBR boot loader I can post untested code.

Later added  "(or EFI with boot1f32)" since I forgot that.
« Last Edit: July 22, 2011, 10:18:45 PM by dmazar »

D-an-W

  • Entrant
  • Posts: 6
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #24 on: July 21, 2011, 07:42:01 PM »
Excuse my ignorance here...but  ::)

Does this mean I can have a HD attached with a Windows 7 install via USB2.0 and boot from it should I need to run something that won't work from Parallels (I do have a working Chamelon partition up and running with the latest build thanks to some great work by blackosx)?

Using...where X is the Windows 7 HD?

Code: [Select]
fdisk440 -f boot0md -u -y /dev/rdiskX

Gringo Vermelho

  • Forum Moderator
  • Posts: 611
  • The gray monster energy hat
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #25 on: July 22, 2011, 12:34:38 AM »
As long as it's properly detected by your BIOS and can boot by itself if set as primary boot device, your USB hard drive with Windows 7 on it should show in the Chameleon GUI already. You don't have to install anything on your Windows 7 drive. You should be able to boot it from Chameleon installed to your OS X drive, using the boot selector.

This has been possible for a long time but the problem is that when you boot Windows 7 from another HDD (i.e. from your OS X drive with Chameleon installed on it) hibernation and hybrid sleep doesn't work and you can't install Service Pack 1. As I understand it, dmazar's code fixes this.

 



 
« Last Edit: July 23, 2011, 02:34:01 AM by Gringo Vermelho »
10.9.5 - ASUS P8Z77-V Pro - i5 3570K - GTX 660 - Chameleon 2.3 svn-r2xxx
How to...
Install Chameleon: http://forum.voodooprojects.org/index.php/topic,649
Make your own Chameleon boot CD: http://forum.voodooprojects.org/index.php/topic,484.msg2131.html#msg2131

Blackosx

  • Forum Moderator
  • Posts: 1150
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #26 on: July 22, 2011, 01:10:54 PM »
It seems it will be possible to make one universal boot0. But before that I'll write down simplified explanation for each boot0 version. It helps me to see what's going on. I hope I did not make mistakes there ...
Hi dmazar

hmm. At first look, this is a bit of a mind-bender, but I'm interested in your positive approach here. :)
I'm a bit busy right now so I haven't got time to look in detail but I would say your summary looks about right.

Few conclusions from the above:
----
boot0, boot0hfs and boot0md behaves differently only if booted from MBR or hybrid discs, while if booting from GPT disks they do the same: boot first HFS+ partition.
Most (if not all) users will either be using hybrid MBT/GPT or MBR.

Back to "universal" boot0. I think I can add one more pass to boot0md with minimal changes to the existing code. This would cover searching for active HFS+ partition in MBR plus boot0md (extended boot0hfs) functionality.
.../snip/...
I'm 99% sure I can make it. Have code for it which compiles (nasm works on Win laptop), but can not test it until I get back home. If anybody feels adventurous and wishes to mess with MBR boot loader I can post untested code.
This would be a marvellous piece of coding if it works, though I have yet to sit down and actually get my head around your solution. But if you could make a test a binary available then I'll try to find time to run some trials.
« Last Edit: July 22, 2011, 01:14:43 PM by Blackosx »
10.10.5 / 10.11 GM1 | Asus Maximum IV Gene-Z | i7-2600 3.40GHz | 4GB | Radeon 5770 1GB

dmazar

  • Member
  • Posts: 52
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #27 on: July 22, 2011, 10:25:09 PM »
Src and binary attached. Work in progress. If it does not work (which would not be a surprise), I'll debug it when I get back home.

dmazar

  • Member
  • Posts: 52
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #28 on: July 22, 2011, 10:32:45 PM »
Using...where X is the Windows 7 HD?

Code: [Select]
fdisk440 -f boot0md -u -y /dev/rdiskX

I agree with Gringo Vermelho. I got the impression that you would boot that USB Win rarely, so you probably do not need hybrid sleep and stuff. You should be able to boot it from Chameleon or by selecting USB drive from BIOS. I see no need to install anything additionally.

Azimutz

  • VoodooLabs
  • Posts: 420
  • Paranoid Android
Re: boot0md: dual boot Windows 7 and Mac OSX from Win7 drive
« Reply #29 on: July 23, 2011, 05:03:12 AM »
Ok, i'm on to it :P in fact, i already have; been without network for last couple of days so,
i dedicate the extra free time to put some stuff up to date.

Will post details later... so far so good, looks promising.
« Last Edit: July 23, 2011, 03:30:53 PM by Azimutz »
 System & Patches: http://goo.gl/i961
 Chameleon:
- trunk builds: http://goo.gl/9G1Hq
- pref pane: http://goo.gl/OL2UT