Many .dmg files are simply sector-by-sector disk images.
The Yosemite Installer .dmg file seem to contain only one (Type AF HFS+) partition in the MBR.
The PBR of these HFS+ partitions can be booted from using the grub4dos chainloader command, however the HFS+ boot code needs to see a valid Type AF partition in a MBR (a real MBR - not a BIOS-mapped MBR).
The following test code seems to boot such a OS X installer .dmg file, but it requires the USB Boot drive to have the last two Primary partition table entries free. The last HFS partition in the image will be treated as the 'boot' partition. If your .dmg image contains multiple partitions, this probably wont work!
set IMG=/Yosemite-Zone.dmg echo -n Checking Partitions 3 and 4 are unused... #enable parttype output debug 1 parttype (hd0,3) | set check= set check=%check:~-5,4% if "%check%"=="0x00" partnew (hd0,3) 0 0 0 if not "%check%"=="0x00" echo SORRY: PTN TABLE 4 IS ALREADY IN USE! && pause && configfile /menu.lst parttype (hd0,2) | set check= set check=%check:~-5,4% if "%check%"=="0x00" partnew (hd0,2) 0 0 0 if not "%check%"=="0x00" echo SORRY: PTN TABLE 3 IS ALREADY IN USE! && pause && configfile /menu.lst debug 1 echo -e OK partnew (hd0,2) 0xAF %IMG% dd if=(hd0)0+1 of=(md)0x300+1 > nul # get length read 0x601ea > nul set /A LEN=%@retval%&0xffffffff > nul map --read-only %IMG% (hd15) > nul map --hook dd if=(hd15)0+1 of=(md)0x300+1 > nul # find AF partition set /A TYP=*0x601c2 & 0xff > nul if /i "0xaf"=="%TYP%" && set STOFF=0x601c6 && echo Found AF partition in PTN 1 of %IMG% set /A TYP=*0x601d2 & 0xff > nul if /i "0xaf"=="%TYP%" && set STOFF=0x601d6 && echo Found AF partition in PTN 2 of %IMG% set /A TYP=*0x601e2 & 0xff > nul if /i "0xaf"=="%TYP%" && set STOFF=0x601e6 && echo Found AF partition in PTN 3 of %IMG% set /A TYP=*0x601f2 & 0xff > nul if /i "0xaf"=="%TYP%" && set STOFF=0x601f6 && echo Found AF partition in PTN 4 of %IMG% # get start PBR inside image read %STOFF% > nul set /A OFFSTART=%@retval%&0xffffffff > nul set /A L=%LEN%-%OFFSTART% > nul echo Creating new partition 4 on hd0 using command: partnew (hd0,3) 0xAF (hd0,2)%OFFSTART%+%L% partnew (hd0,3) 0xAF (hd0,2)%OFFSTART%+%L% # delete ptn 3 partnew (hd0,2) 0 0 0 # unmap file map --unhook map --unmap=0xff map --unmap=0x8f # boot from new partition chainloader (hd0,3)+1 rootnoverify (hd0,3)
If you are sure that ptns 3 and 4 are empty - you can add the lines below to the top of the menu:
# clear Ptn 3 and ptn 4 entries! partnew (hd0,2) 0 0 0 partnew (hd0,3) 0 0 0
It would be nice if only one partition was required and not the temporary ptn hd0,2 but I haven't yet figured a way around that yet!
Tip: adding the OS X boot switches -v -x at the Installer boot menu before pressing ENTER seems to help it to boot more reliably (esp. from VBox).
Note: If you have a Haswell system and are testing in VBox, you may need to tweak the Virtual Machine settings like this to get the OS X installer to boot (as well as setting the VM Machine Type to Mac OS X:
VBoxManage.exe modifyvm SATA --cpuidset 00000001 000306a9 00020800 80000201 178bfbff