Code Monkey home page Code Monkey logo

virtualbox-osx's Introduction

VirtualBox OSX Image - Creation Tool

Creating Virtual Machines can be a painful process, especially for those who don't have a strong background in system administration.

While there is a lot of good information to be found online, virtually every tutorial/guide requires a non-trivial amount of manual tweaking to get a working system up and running.

This project completely automates the process of creating an OSX virtual machine that will run on Apple hardware.

LEGAL NOTICE:

Apple specifies limits on the creation/usage of OSX virtual machines in the EULA.

(iii) to install, use and run up to two (2) additional copies or instances of the Apple Software within virtual operating system environments on each Mac Computer you own or control that is already running the Apple Software.

Source: http://apple.stackexchange.com/a/20969/19755

If you need to run multiple configurations here's a guide on how to use snapshots.

Usage

  1. Verify that 'Install OS X El Capitan.app' is in the /Applications directory
  2. Run ./virtualbox-osx.sh

Note: The script will output to ~/VirtualBox VMs/OSX-El-Capitan

How it works

  1. An install ISO is created from the .app file
  2. A VirtualBox VDisk file is created
  3. The VDisk is attached (ie not mounted) as a fake physical disk
  4. The VDisk is formatted as a JHFS+ volume
  5. The VDisk is detached
  6. A new VirtualBox VM is created with the VDisk + ElCapitan.iso attached and a few 'sane' defaults

Note: The VM will boot into the OSX installer. After installation is complete, don't forget to detach the install disc (ie ElCapitan.iso).

Default Settings

  • VDisk - 32GB (fixed)
  • Architecture - x64
  • Chipset - PIIX3
  • BootType - EFI
  • RAM - 4GB
  • VRAM - 128MB

Note: This setup has been verified on an iMac (Late2009). The settings are currently hardcoded in virtualbox-osx.sh if you need/want to make changes.

Files

  • virtualbox-osx.sh

    Creates an OSX virtualbox profile + vdisk image

  • osx-install-iso.sh [name] [dir]

    Creates an install disk iso from the stock Install OS X El Capitan.app

  • vdi-attach.sh [vdisk-path]

    Attaches a VirtualBox VDI (Virtual Disk Image) as if it were a physical disk using fairy dust and magic

Nerd Stuff

Pain to the A... Holla

While the install.app contains everything needed to create an installer.iso, making it work requires a number of hacks.

  1. Create a install.cdr file formatted as JHFS+ and allocate enough space for the install files
  2. Attach the install.cdr
  3. Load install.cdr with 'System Restore' so it'll boot with a minimal OSX environment
  4. Remove a symlink that would points to a 'System Restore' specific packages directory
  5. Copy the install packages from install.app
  6. Detach install.cdr
  7. Convert install.cdr to install.iso

Note: Why Apple doesn't provide a utility to automate this process is beyond me. Maybe the 'unwashed masses' aren't ready for the awesome power of a fresh OSX install. Somebody call a 'Genuis'.

Puppies Farting Rainbows and a Bodybuilding Unicorn

Fairy dust and magic can be both wonderful and terrifying. Seeing a comment that says // here be magic is usually a really, really bad sign. Since you're still reading (such a trooper, you are) I'll attempt to explain the details of mounting a VDI as a fake disk sans any excessive 'hand waving'.

Mounting disk images is nothing new. At the OS level, it simply maps a new volume and uses the contents of the image as if it were raw disk data.

Virtual Disks don't work with standard mounting tools because they contain additional metadata at the head of the raw binary data. To make things more comples, the metadata length is not fixed.

The vdi-attach.sh script solves that issue by decoding the header length field using nothin but standard POSIX CLI tools.

To attach the disk, it calls hdid (ie the precursor to hdiutil) including an offset (calculated previously) where it can start reading the raw disk data.

Note: While hdiutil is an obvious improvement from hdid, it would be really cool if they would add this functionality back in. hdid is officially deprecated so there's no telling how long until it's removed altogether.

virtualbox-osx's People

Contributors

evanplaice avatar

Stargazers

 avatar Nick Blake avatar Jon Walsh avatar Victor Argote avatar David Stapp avatar JC avatar Wenbo Jie avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

onixspot

virtualbox-osx's Issues

verbose mode option

a suggestion to add a verbose mode to see what is going on in the beginning or add a bash spinner to know that the installer is working.

the installer worked great out of the box otherwise and loved seeing the virtual box vm added and running automatically.

Still requires extra config

Thanks for these scripts, they were very helpful. However, for me the machine would continuously reboot before getting to the point of launching the GUI (that is never launching it). By executing the following commands it resolved the issue for me (not sure if all needed or just some).

Note this is on a Macbook pre-2009 with 10.11 host and 10.11 guest.

VBoxManage modifyvm "OSX-El-Capitan" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "OSX-El-Capitan" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "OSX-El-Capitan" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "OSX-El-Capitan" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "OSX-El-Capitan" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "OSX-El-Capitan" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.