Skip to content

Instantly share code, notes, and snippets.

@yellow5
Created November 3, 2016 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yellow5/21d0ae7d71bede7a0909844eafb8d3f9 to your computer and use it in GitHub Desktop.
Save yellow5/21d0ae7d71bede7a0909844eafb8d3f9 to your computer and use it in GitHub Desktop.
Script to reload a locally managed vagrant base box with a VMware Fusion provider.
#!/bin/bash
# Save the current directory.
pushd ./
# Change to the directory that contains the VM.
cd ~/Documents/Virtual\ Machines.localized/Debian\ Jessie\ 64\ -\ Base.vmwarevm/
# Defragment and shrink the virtual disk.
/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -d Virtual\ Disk.vmdk
/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k Virtual\ Disk.vmdk
# Move the previous box to a backup and create a new one.
mv jessie64.box ../jessie64.box.bak
tar cvzf jessie64.box ./*
# Update the base box with vagrant.
vagrant box add --provider vmware_fusion --force debian/jessie64 jessie64.box
# Restore the shell to the directory where execution started.
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment