As part of my preparation for next week’s WWDC conference, I’ve been working on ways to build virtual machines using VMware Fusion for testing. In previous years, I have used NetBoot-based solutions to help me with this process. With NetBoot going away though, I’ve started using bootstrappr as my replacement deployment tool.
Bootstrappr is designed to install packages and scripts, but in my case I’m having it install only one package: a firstboot package created by First Boot Package Install Generator.app. The firstboot package in turn installs a set of installer packages to configure the VM and install the software I want. For more details, please see below the jump.
Downloading bootstrappr
To download the bootstrappr files, use the following procedure:
1. Go to https://github.com/munki/bootstrappr
2. Click on the Clone or download button.
3. Click on the Download ZIP button.
Preparing a firstboot package
For details on how to prepare a firstboot package using First Boot Package Install Generator.app, please see the following blogpost:
https://derflounder.wordpress.com/2014/10/19/first-boot-package-install-generator-app/
For this example, I’ll be using a firstboot package named First Boot Package Install.pkg.
Configuring bootstrappr for deployment
1. In the downloaded bootstrappr files, locate the bootstrap directory.
2. Inside the bootstrap directory, add the First Boot Package Install.pkg installer package to the packages directory.
3. Run the make_dmg.sh script in the downloaded bootstrappr files to create a disk image with all of the bootstrappr files inside.
Running bootstrappr
On my own network, I’ve been using bootstrappr’s option of mounting a disk image which is hosted on a web server. This is described as Scenario #2: Disk image via HTTP in the bootstrappr usage scenarios. This allows me to centrally host the disk image and use it when building multiple VMs. However, for next week’s conference, I won’t have access to the web server which hosts the disk image. Instead, I’ll be taking the bootstrappr disk image with me and using a process similar to that described below to set up my VMs.
Converting the bootstrappr disk image to a VMware VMDK file
- Pre-requisites: VMware Fusion
1. Double-click the bootstrappr disk image to mount it.
2. Run the following command to get the disk image’s disk identifier:
diskutil list
3. Locate the identifier for the whole mounted disk image. For this example, it’s /dev/disk2
4. Run the commands below to copy the contents of the disk image to a .VMDK file:
First:
"/Applications/VMware Fusion.app/Contents/Library/vmware-rawdiskCreator" print /dev/disk_id_here
For this example, the command will look like this:
"/Applications/VMware Fusion.app/Contents/Library/vmware-rawdiskCreator" print /dev/disk2
Second:
"/Applications/VMware Fusion.app/Contents/Library/vmware-rawdiskCreator" create /dev/disk_id_here fullDevice /path/to/tempfile lsilogic
For this example, the command will look like this:
"/Applications/VMware Fusion.app/Contents/Library/vmware-rawdiskCreator" create /dev/disk2 fullDevice /Users/username/bootstrapr-staging lsilogic
Third:
"/Applications/VMware Fusion.app/Contents/Library/vmware-vdiskmanager" -r /path/to/tempfile.vmdk -t 0 /path/to/filename.vmdk
For this example, the command will look like this:
"/Applications/VMware Fusion.app/Contents/Library/vmware-vdiskmanager" -r /Users/username/bootstrapr-staging.vmdk -t 0 /Users/username/bootstrap.vmdk
The output of running these commands should look like this:
Once the VMDK file is built, attach it to a VM by using the process described in the link below:
Add an Existing Virtual Hard Disk: https://pubs.vmware.com/fusion-7/topic/com.vmware.fusion.help.doc/GUID-4B3FC5A0-E4A5-4C1B-9F0C-9536628CF4DB.html
Once the VMDK is ready and attached, use the procedure below to boot and configure a VM with an unconfigured copy of macOS installed:
1. Boot to Recovery
2. Launch Terminal
3. Run the following command:
/Volumes/bootstrap/run
4. Select the volume to install on (in this example, the volume is named Macintosh HD.)
The firstboot package included in the disk image is installed.
5. Once installation is completed, select the option to restart.
On restart, the First Boot Package Install workflow is able to suppress the Apple Setup Assistant and run its assigned installation tasks.