My fork of the auto-create script is designed to create and configure virtual machines with Apple operating systems as the guest OS, hosted on a VMware ESXi server running on Apple hardware. The script assumes that the virtual machines are built using copied VMDK disk files, where the VMDK files are generated by AutoDMG and vfuse. For more details, see below the jump.

Building VMDK files

In the process I’m following, the workflow to generate the VMDK files works like this:

2. Once the disk image is generated, use vfuse to create VMDK files using a command similar to the one shown below:

3. vfuse will create a VM for VMware Fusion. To access the VMDK files, right-click on the VM and select Show Package Contents.

4. The VMDK files will be inside. The conversion process will create two files:

filename.vmdk

filename-flat.vmdk

This is expected behavior and both of these files will be needed.

Uploading VMDK files

Once the VMDK files are created and available, they need to be uploaded to a convenient location on an ESXi datastore. For information on how to upload these files, see the link below from the VMware documentation for vSphere:

The esxi_macos_vm_creation script will need to be stored on the ESXi server, so also upload it to a convenient location on an ESXi datastore.

Running the script

This script is designed to create and configure virtual machines running Apple operating systems, hosted on a VMware ESXi server running on Apple hardware. The script assumes that the virtual machines are built using copied VMDK disk files. In this case, the VMDK files will be the disk images created by AutoDMG and converted to VMDK files using vfuse.

Note: When creating the VM, you will need to provide the location of the filename.vmdk file . As long as filename.vmdk and filename-flat.vmdk are both available in the same directory on the datastore, ESXi will automatically also reference and include filename-flat.vmdk when creating the VM.

The script is designed to be stored on an ESXi datastore and run from the ESXi server’s command line interface, which is why it needed to be uploaded to an ESXi datastore in the previous step.

Usage:

/path/to/esxi_macos_vm_creation.sh -n -d -c -h -i -o -r -s -v -p

Options:

-n: Name of VM (required)

-d: Location of a VMDK disk file (required). Location must be in this format – /vmfs/volumes/datastore_number_here/path/to/filename_here.vmdk

-c: Number of virtual CPUs

-h: VMware Hardware Version

-i: Location of an ISO image. Location must be in this format – /vmfs/volumes/datastore_number_here/path/to/iso_file.iso

-o: Apple OS version

-r: RAM size in MB

-s: Disk size in GB

-v: VNC port between 5900 and 5909

-p: VNC password. Maximum password length is eight characters.

The script has several default variables set up:

ESXi datastore location for new VMs: /vmfs/volumes/datastore1Number of processors for new VMs: 2Amount of RAM for new VMs: 4096 MBsHard drive size for new VMs: 40 GBGuest OS: darwin14-64 (this is the OS setting for OS X Yosemite.)Hardware Version: 11 (this is the maximum Hardware Version available for ESXi 6.0.x)

The ESXi datastore value can be changed by editing the DATASTORE variable in the script. The other default values are overridden if alternate values are enabled by the script’s available options.

computername:~ username$ ssh root@esxi.demo.com
Password:
The time and date of this login have been sent to the system logs.
VMware offers supported, powerful system administration tools. Please
see www.vmware.com/go/sysadmintools for details.
The ESXi Shell can be disabled by an administrative user. See the
vSphere Security documentation for more information.
[root@esxi:~] /path/to/esxi_macos_vm_creation.sh -n macOSVM -d /vmfs/volumes/datastore1/template/filename.vmdk
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/datastore1/template/filename.vmdk'...
Clone: 100% done.
Powering on VM:
The Virtual Machine is now configured and the VM has been started up. The VM is set to use the following configuration:
Name: macOSVM
CPU: 2
RAM: 4096
Guest OS: darwin14-64
Hardware Version: 11
Hard drive size: 40
No ISO added.
VNC not enabled.
[root@esxi:~]

To set up a VM using a name with spaces and/or special characters, add quotation marks to the VM name:

To set up a VM named MacOS VM 10.12 using a VDMK stored on /vmfs/volumes/datastore1/template and named macos-vm.vmdk with 4 CPUs, 8 GBs of RAM, a 52 GB hard drive, set to HW Version 13, guest OS set to macOS Sierra and VNC enabled on port 5902 with the VNC password set to the word password:

Like this:

Related

How did you manage (if…) to solve the problem that virtual macs represent themselves with a question mark to other macs in the network (because of unknown hardware on OS side) as well as get iCloud stuff work (same reason)?