Mac OS guest from HD partition?

Discussion in 'macOS Virtual Machine' started by StuF, Sep 16, 2011.

  1. StuF

    StuF Bit poster

    Messages:
    1
    I did a quick search and did not find anything on this topic. Apologies in advance if I missed something.

    Is it possible to run a Lion guest OS from a HD partition, analagous to running Windows from a bootcamp partition?

    I need to rebuild my Lion installation and would like to avoid having to take my working system offline while I install in the new partition.

    TIA
     
  2. joevt

    joevt Forum Maven

    Messages:
    1,207
    You could try making a Boot Camp virtual hard disk and modifying the DiskDescriptor.xml file to point to the partition where you want to install Mac OS X but Parallels will give an error when you try to start the virtual machine when it finds out that the partition is an HFS partition (unsupported partition type).

    If the partition is not an HFS partition before you create the virtual hard disk, (you can change the partition type to NTFS using gdisk) then you can create a Boot Camp virtual hard disk from it before booting the virtual machine into the installer.

    Once the installer has booted, you need to use Disk Utility from the installer to erase the partition to HFS. This will fail since the GPT table of the virtual hard disk is protected. So before booting the virtual machine, you need to edit the DiskDescriptor.xml file so that the GPT and MBR are not protected. After doing that, the install will work (ignore the warning that says the virtual machine tried to write over the boot record) but you won't see the partition on the host Mac side until you change the partition type back to HFS. Before booting the virtual machine, make sure the partition you will be installing to does not have any free space after it (use the gpt -r show -l command) because the Lion installer will try to use the free space but it will not be included in the virtual hard disk and so will cause a write error.

    Another problem is that the boot camp partition will have been converted into two partitions (one for Lion and one for Recovery HD) but the Recovery HD partition will not be listed in the GPT table of the real hard disk even though the real hard disk has the information. In that case, you could manually edit the partition table of the real hard disk so it matches the virtual hard disk.

    All that work might be more trouble than it's worth and dangerous. You might be better off installing Lion to a fixed size virtual hard disk. After installing has completed, you can change the .hds file extension to .dmg so you can mount it using Disk Utility. Then you can use Disk Utility to recover the installation from the .dmg to your real hard disk.

    There's no technical reason why Parallels can't allow selecting arbitrary partition types (such as HFS) for Boot Camp virtual hard disks. Parallels could even keep partition tables in sync after a virtual machine stops when Parallels would normally remount the partitions. At that time it could check if meta information (which is stored in the GPT and MBR partition tables) that correspond to the portions of the real hard disk that are writeable by the virtual hard disk has changed, then copy that changed information to the real hard disk's MBR and GPT. Currently, Parallels will not allow any changes to the MBR and GPT. For the purposes of syncing the partition tables, it could be made smart enough to ignore changes that only affect the writable portions of the virtual hard disk. An error should occur if a change affects the non-writable portions of the virtual hard disk.
     

Share This Page