09 Nov

Vagrant | Advanced

Build a custum Vagrant Box

Install Linux in Virtual Box

Run sudo without password

Create file /etc/sudoers.d/vagrant


Build Package

$ vagrant package --base <NAME_OF_VM> --output <OUTPUT_BOX_NAME>.box

For example:

$ vagrant package --base ubuntu_16.10_32 --output ubuntu_16.10_32.box

Add custom Vagrant Box to local vagrant repository

$ vagrant add box ubuntu_16.10_32 package/ubuntu_16.10_32.box

Build Vagrant Box from mac OS Installation Disk

First, run the following command to create a blank disk image:
hdiutil create -o /tmp/HighSierra.cdr -size 7316m -layout SPUD -fs HFS+J

Next, mount your blank image:

hdiutil attach /tmp/HighSierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build

Now you’re going to restore BaseSystem.dmg from the installer over to the newly mounted image:

asr restore -source /Applications/Install\ macOS\ High\ Sierra.app/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase

Note: Name of destination mount point has changed to “OS X Base System/System.”
Unmount the image:

hdiutil detach /Volumes/OS\ X\ Base\ System

And, finally, convert the image you created into an ISO file:

hdiutil convert /tmp/HighSierra.cdr.dmg -format UDTO -o /tmp/HighSierra.iso

Move the ISO to the desktop:

mv /tmp/HighSierra.iso.cdr ~/Desktop/HighSierra.iso

And you’ve got a bootable High Sierra ISO file!