Jump to content
InsanelyMac Forum
iWin32

Multiboot Mac OS X from .vhd/.vmdk/.vdi/.img?

Recommended Posts

I am wondering if there are any developers out there interested in getting a hackintosh to boot from a virtual image file, like a .vhd file. Native VHD Boot was discussed a while back as the official Windows 7 feature. As other users have posted, it hangs at an error of 0x02 when attempting to boot Mac OS X. The main problem with this method is that Mac OS X or any non-Windows OS installation is not supported by this feature. Furthermore, only the booting of Windows 7 Ultimate (and maybe Windows 8 CP as mentioned online) is supported by this feature. Interestingly, a non-Microsoft product called vBoot (released by VMLite) claims to be able to boot all Windows and some Linux operating systems from a .vhd. Here is what a moderator of their forum said when someone asked if vBoot would allow Mac OS X booting from a VHD file:

This is a long term goal, won't be available in any time soon.

 

We have verified that OS X would work with VBoot, but it's not a top priority right now.

 

The thing is, though, that was one year ago, and their free trial of vBoot (that's right, it's not free) expired in January of this year, and hasn't been updated since. So basically, it won't work until you buy a license, and the sdk's price for us users to develop our own drivers for it is rediculous ($5000!?!)

 

They do, however, have released a modified version of Grub that apparently enables support of .vhd files, but I haven't looked at a code, because I'm not a programmer.

 

VirtualBox contains support for .vhd, .vmdk, and their own .vdi files. .img files are supported by a modified version of Grub, like Burg (whose map commands does NOT require the images to be in one, contigiuous area, unlike Grub4dos who does). Who knows? Maybe we could add DMG2IMG to add support for even native .dmg boot!

 

But, it's not that simple as merging code, I'm afraid. We need to create our own drivers for Mac OS X (probably .kext files) to enable it to support the .vhd/.img as a boot device. Both the official Windows 7 feature and VMLite's VBoot have their own drivers to enable the OS to boot. So, I was wondering if other developers would be willing to develop the following things:

1. A modified version of Grub or Burg that enables you to boot Mac OS X (perhaps chainload Chameleon from the .vhd)

2. Drivers that enable Mac OS X to boot from the .vhd.

 

After that, we could try to do the same thing as before, install Mac OS X from VMware onto the .vhd (native disk .vmdk pointing to the .vhd file), install the modified bootloader, and set it up. After that, we could reboot into it!

 

Anyone interested? Thanks in advanced!

Share this post


Link to post
Share on other sites
Advertisement

Well it is possible to boot from an Apple DMG file. Used to install Lion and Netinstall images. Maybe simpler to work on that which is built into the kernel rather than add new image format support. Interesting idea though and or me VHD would be great. Use boot from VHD all the time at work. Would love Linux and Mac OS X support.

Share this post


Link to post
Share on other sites

Well it is possible to boot from an Apple DMG file. Used to install Lion and Netinstall images. Maybe simpler to work on that which is built into the kernel rather than add new image format support. Interesting idea though and or me VHD would be great. Use boot from VHD all the time at work. Would love Linux and Mac OS X support.

hi,when you say "Use boot from VHD all the time at work" on mac os x how you do that to boot from vhd ?

Thanks for your answer.

Hello everyone, this topic is old but still topical since we do not have an integral solution to start a version of mac os x directly from a vhd and a partition wndows for example .

With Grub4Dos and chameleon and a lot of manipulation (7 manipulations) I can boot from a vhd to another vhd using the Mac OS X Netboot local , it works but is not satisfying. Too many manipulations and that one must agree that mac os x does not integrate the virtualization natively as did microsoft with Windows 7.

 

Thank you to all those who can enlighten us on this subject.

Share this post


Link to post
Share on other sites

I use grub4dos, little memo for my use of Grub4Dos to launch chameleon or throw chameleon and a Mac OS X system link to a DMG or VHD file, from the boot of Windows. In absolute terms it must implement 7 maneuvers to arrive at the result, but by automating a little, it does with 3 manipulations.

The goal is to have the ability to start a Mac os x system on Windows startup, I use it to check that my mac os x backups in dmg or vhd are functional and error-free

I am using Visual BCD to create an opening choice of /Grub4/grub.exe in the Windows BCD (BCD Windows Startup Store).



First of all have a DMG system or file from an existing Mac OS X installation. After having at least one HFS partition.

It is necessary to create an Iso or a Vhd, mounted under mac os this iso or this vhd or this DMG, intaller chameleon with a folder Extra, in this file we will place the kernel (mach_kernel or kernel) of the desired system, the kernelcache of the same system, the boot.plist (org.chameleon.Boot.plist) containing the options for your boot plus the kernel option for the kernel file, the kernelcache option for the cache to use, the Kernel Flags option - v -s rd = uuid boot-uuid = (the uuid of the hfs partition containing the DMG or Vhd to mount), rp = file: ///MacLion.dmg (the DMG file of the system to be mounted which is on the hfs partition which we gave the UUID), example of a Kernel Flags

Kernel Flags String PciRootUID = 0 rd = uuid boot-uuid = B61C6FED-DB6F-3B84-8D39-E933A2DF1312 rp = file: ///MacLion.dmg -v -s npci = 0x2000

<key> Kernel Flags </ key>
<string> PciRootUID = 0 rd = uuid boot-uuid = B61C6FED-DB6F-3B84-8D39-E933A2DF1312 rp = file: ///MacLion.dmg -v -s npci = 0x2000 </ string>.

to create an iso under Mac Os X mountable by Grub4Dos, one creates a folder or a dmg (preferably a dmg read and write) where one installs chameleon (if it is a file one copies in this file the file Extra, the file usr, the boot file) we use hdiutil in the terminal

with the following options for a dmg create which bears the name "base.dmg" and which is mounted

sudo hdiutil makehybrid -o /base.iso / Volumes / base -iso -hfs -joliet -eltorito-boot / Volumes / base / usr / standalone / i386 / cdboot -no-emul-boot -hfs-volume-name "base" -joliet-volume-name "base" - iso-volume-name "base"

the command will create a base.iso file at the root (/base.iso), this file will be created from the mounted.dmg database (/ Volumes / base)


with the following option for a folder (this folder is on the desktop) containing chameleon and folders (Extra, usr)

sudo hdiutil makehybrid -o /base.iso ~ / Desktop / base -iso -hfs -joliet -eltorito-boot ~ / Desktop / base / usr / standalone / i386 / cdboot -no-emul-boot -hfs-volume-name " baseiso "-joliet-volume-name" base "-iso-volume-name" base "

the command will create a base.iso file at the root (/base.iso), this file will be created from ~ / Desktop / base the ~ replaces "/ Users / yourname" (~ / Desktop / base)
 


Once the iso is created, you copy it to a windows partition (ntfs).

In the menu.lst of grub4dos (for Yosemite for example)

"find --set-root - ignore-floppies - ignore-cd / yos.vhd
map /chamyos.vhd (hd4,0)
map --hook
map --harddrives = 4
rootnoverify (hd4,0)
chainloader (hd4,0) +1
boot "


or for an Elcapitan iso

"title Elcapitan
find --set-root --ignore-floppies --ignore-cd /elcap.iso
map --mem /elcap.iso (hd32)
map --hook
rootnoverify (hd32)
chainloader (hd32)
boot "


After grub4dos, your new "bootloader" "chameleon or Enoch" is displayed, in the choice of start you see your iso or vhd, you select it, the boot of the mac os x is realized after mounting the dmg or vhd until at the mac os x command-line entry (kernel flags -s option), i'm using a modified version of /private/etc/rc.netboot that is present on all mac os x. So once in the command line at the root, you type in "/private/etc/rc.netboot" and then "/ exit" to continue booting your mac os x.

you have downloaded a version of Grub4Dos (version 0.4.6a) and install it from Windows (for reminder all this is possible if only if you already have an existing mac os x system, means to read, write and create partitions (volumes) HFS +, NTFS (ex: Paragon NTFS for Mac and Paragon HFS for windows).

All that is written above is from the google translation, I apologize if it is badly translated.

Maybe you think that all this is not very useful, I understand very well, basically I wanted to boot from windows, it turned out that Apple does not treat virtualization directly for its system. exploitation (unlike window which since windows 7 allows to use vhd as operating system)

To start a mac os x system from an iso, the easiest way is to use easybcd under windows rather than grub4dos. Easybcd can create in the bcd the choice to start a system from an iso. To create an easier iso, as it is written above, it is to use the commands of the terminal under mac. Create a folder containing the Extra folder (unavoidable for bootloader with chameleon (or Ermac's Enoch)) a system folder (practically empty just containing a SystemVersion.plist file (which is checked by chameleon at startup (the/System/Library/CoreServices/SystemVersion.plist, a System folder inside a Library folder, inside a CoreServices folder and inside the SystemVersion.plist file), a usr folder containing the standalone folder (create chameleon folder or Enoch, when you install this one on a partition, as a reminder chaméléon is a system bootloader mac os x on a hackintosh) (tree/usr/standalone) /usr/standalone, because in the command I use cdboot which is here/usr/standalone/i386/cdboot, cdboot to make bootable  iso.

Back to the folder/Extra, it must contain the file "org.chameleon.Boot.plist" which contains all options for chameleon and option for system startup, can be a folder/Extra/Extentions, for extensions of the kernel that does not may not be in the cache (ex: FakeSMC.kext for macos x High Sierra, so any kexts that can not be in the cache), a smbios.plist file that contains the description of your mac (imac, mini, macbook, MacPro)

 

(ex:
<Key> SMbiosdate </key>
    <String> 09/03/13 </string>
    <Key> SMbiosvendor </key>
    <string> Apple Inc. </string>
    <Key> SMbiosversion </key>
    <String> IM142.88Z.0118.B00.1309031249 </string>
    <Key> SMboardproduct </key>
    <String> Mac 27ADBB7B4CEE8E61 </string>
    <Key> SMexternalclock </key>
    <string> 100 MHz </string>
    <Key> SMfamily </key>
    <String> iMac </string>)

 

you can find smbios.plist files on the net without difficulty. In the Extra folder there is also the kernel file of the system you want to start, originally the kernel file from Yosemite is "/System/Library/Kernels/kernel" once copied to the Extra folder you can name it as you want (eg "macHSker"), you must have the key in org.chameleon.Boot.plist

<key> Kernel </key>
    <String>/extra/macHSker </string>

 

the cache file that according to the systems from Lion to El Capitan was in the folder/System/Library/Caches/com.apple.kext.caches/Startup/kernelcache, and from El Capitan in/System/Library/PrelinkedKernels/prelinkedkernel, the kernelcache (or prelinkedkernel) it is the assembly of the kernel and kernel extensions (kext) it is this file that allows to bypass the loading of all the kexts and the kernel at startup, once the file copied in the folder/Extra you can rename it as you wish (ex: macHSCach) without forgetting the key in org.chameleon.Boot.plist

 

<key> Kernel Cache </key>
    <String>/extra/macHSCach </string>. and finally the key in org.chameleon.Boot.plist <key> Kernel Flags </key>
    <string>PciRootUID=0 GraphicsEnabler=yes kext-dev-mode=1 -v -s npci=0x2000 nvda_drv=1 rd=uuid boot-uuid=399520ED-E5A2-3CD7-94DA-C94AE68692EB rp=file:///MacHS.vhd rootless=0 </string>
 which will allow you to get your vhd and load it or if you want to start your partition containing your mac os x system just use the uuid of the partition.

<key> Kernel Flags </key>
    <string>PciRootUID=0 GraphicsEnabler=yes kext-dev-mode=1 -v -s npci=0x2000 nvda_drv=1 rd=uuid boot-uuid=399520ED-E5A2-3CD7-94DA-C94AE68692EB rootless=0 </string>

, the uuid present, it is either the uuid of the partition HFS containing the file vhd or dmg or the uuid of your system partition mac os x (Yosemite, El Capitan, Sierra, High Sierra, etc ...), the boot file will also be copied to the folder, the boot file is chameleon or Enoch. So in the end in the folder that you will convert to iso file and copied to the root of your Windows partition, the tree of this folder will be for example

/MacHS
/Extra/
/System/
/Usr/
/boot

The iso will be realized with the command below in the terminal of the system mac os x

sudo hdiutil makehybrid -o/hsiso.iso/Volumes/disk0s3/MacHS -iso -hfs -joliet -eltorito-boot/Volumes/disk0s3/Machs/usr/standalone/i386/cdboot -no-emul-boot-hfs-volume- name "MacHS" -joliet-volume-name "MacHS" -iso-volume-name "MacHS"

Once your imagedisk "VHD" or "DMG", mounted by the system, it will be read only (although originally it is "Read & Write") is a choice of Apple.

So to replace this situation, after having arrived at the command line following the execution of the "-s" option of the kernel fkags of org.chameleon.Boot.plist we can use "sh / private / etc / rc.netboot init "directly then exit to exit the command line and continue booting. /private/etc/rc.netboot must be modified, to edit it copy it to your desktop, it will be unlocked, below the original version of lines 24,25,26 of the script "/private/etc/rc.netboot "

"NETBOOT_MOUNT = / var / netboot
NETBOOT_SHADOW = $ {NETBOOT_SHADOW: -NETWORK-}
LOCAL_NETBOOT_DIR = private / var / run / com.apple.NetBootX "

To create a shadow file you have to modify the line 25 like this "NETBOOT_SHADOW = $ {NETBOOT_SHADOW: -LOCAL_ONLY-}" below the same modified lines

NETBOOT_MOUNT = / var / netboot
NETBOOT_SHADOW = $ {NETBOOT_SHADOW: -LOCAL-}
LOCAL_NETBOOT_DIR = private / var / run / com.apple.NetBootX

rc.netboot creates a ramdisk where all write disk accesses will be hijacked as your imagedisk is read-only.

attach ramdisk to your root disk image



once modified rc.netboot you can copy it to / private / etc /.

when you are on the command line typing "sh /private/etc/rc.netboot init", if you encounter a "permission denied" problem copy rc.netboot to the root of your imagedisk, command line type keyboard "sh /rc.netboot init" then exit
To make the script executable in the terminal "sudo chmod + x /private/etc/rc.netboot". All these modifications must modify rc.netboot which is on your imagedisk. If you made it on your used disk inct, copy rc.netboot to your imagedisk.

I am using a rc.netboot modified by spartango 2008 rc.liveboot
that I myself reduced in size, it creates a ramdisk of 2go, below the script of /rc.b that I use
to copy if you wish. To use it on the keyboard you type "/rc.b" and exit wait until the end of the execution of "/rc.b" the last sentence that must be written on the screen is "set ComputerName VHD "So he creates a ramdisk of 2go

 

"
#!/bin/sh -x
##
# Copyright 2002 Apple Computer, Inc.
#
# This script configures LiveDVD, derived from Netboot
# Modded by spartango 2008
# still has remanents of netboot
##

. /etc/rc.common

#
# Define: NETBOOT_SHADOW
# Purpose:
# To change the behavior of the system when choosing a netboot shadow
# to use.
# Values:
# -NETWORK- Try to use the network for the shadow file, if
# that fails, use the local drive
# -NETWORK_ONLY- Only use the network, fail if not available
# -LOCAL- Use the local drive for the shadow file, if that
# fails, use the network
# -LOCAL_ONLY- Only use the local drive for the shadow, fail if
# not available

NETBOOT_MOUNT=/var/netboot
NETBOOT_SHADOW=${NETBOOT_SHADOW:-LOCAL-}

Failed()
{
echo rc.netboot: $1
exit 1
}

common_start()
{
netboot_dir=$1
netboot_shadow=$2
if [ "${netboot_dir}" = "" ] ; then
Failed "netboot_dir is empty"
fi
if [ "${netboot_shadow}" = "" ] ; then
Failed "netboot_shadow is empty"
fi
netboot_shadow="${netboot_dir}/${netboot_shadow}"
if ! mkdir -p "${netboot_dir}" ; then
Failed "create ${netboot_dir} failed"
fi
chmod 700 "${netboot_dir}"
mount -u -o ro /
root_device=$(mount | sed -n 's:/dev/\(.*\) on / .*:\1:p')
case "${root_device}" in
vn*)
if ! touch "${netboot_shadow}" ; then
Failed "create ${netboot_shadow} failed"
fi
chmod 600 "${netboot_shadow}"
if ! /usr/libexec/vndevice shadow "/dev/r${root_device}" "${netboot_shadow}" ; then
Failed "vndevice shadow failed"
fi
;;
"")
Failed "root device unknown"
;;
*)
if ! touch "${netboot_shadow}" ; then
Failed "failed to create shadow ${netboot_shadow}"
fi
chmod 600 "${netboot_shadow}"
if ! /usr/bin/nbdst -recycle "${root_device}" "${netboot_shadow}" ; then
Failed "nbdst failed"
fi
;;
esac
}

local_mount()
{
volinfo=`autodiskmount -F 2>/dev/null`
RAMDisk "${NETBOOT_MOUNT}"
common_start "${NETBOOT_MOUNT}/.com.apple.NetBootX" shadowfile
return 0
}


do_start()
{

err=$(local_mount)
if [ $? -ne 0 ]; then
Failed "${err}"
fi
}

RAMDisk()
{
mntpt=$1
#rdsize=$2
echo "Creation RAM Disk pour $mntpt"
dev=`hdik -drivekey system-image=yes -drivekey eject-upon-logout=no -nomount ram://2000000`
if [ $? -eq 0 ] ; then
#newfs $dev #hack to init partition table automatically
/sbin/newfs_hfs $dev
mount -t hfs -o nosuid,nodev $dev $mntpt
echo "ramdisk créé et monté OK"
fi
}
#Example: RAMDisk /Volumes 2048

do_init()
{


# attach the shadow file to the root disk image
do_start

# make sure the root filesystem is clean
fsck -p || fsck -fy || Failed "Could not clean root filesystem"

# make it writable
mount -uw /

# adjust /private/var/vm to point to the writable area (if not diskless)
swapdir=/private/var/vm
mounted_from=$(mount | sed -n 's:\(.*\) on .*/var/netboot.*:\1:p')
case "${mounted_from}" in
/dev/*)
netboot_dir="${NETBOOT_MOUNT}/.com.apple.NetBootX"
if [ -d "${netboot_dir}" ]; then
rm -rf "${swapdir}"
ln -s "${netboot_dir}" "${swapdir}"
echo "Montage par ramdisk miroir !"
fi
;;
*)
;;
esac

# set the ComputerName
echo " set ComputerName VHD "
scutil --set ComputerName VHD
}

do_init

exit 0

"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   1 member

×