Skip to content

Instantly share code, notes, and snippets.

@lpenz lpenz/img2vagrant
Created Oct 5, 2016

What would you like to do?
Create a for vagrant (virtualbox) from the specified raw img file
IMG=${1?usage: $0 <img>}
set -e -x
rm -f "${IMG}.vmdk"
VBoxManage convertfromraw "$IMG" "${IMG}.vmdk" --format vmdk
VBoxManage unregistervm "$NAME" --delete || :
VBoxManage createvm --name "$NAME" --ostype Ubuntu --register
VBoxManage modifyvm "$NAME" --memory 1024 --acpi on --vram 32 --pae on
VBoxManage modifyvm "$NAME" --nic1 nat
VBoxManage modifyvm "$NAME" --natpf1 ssh,tcp,,2022,,22
VBoxManage storagectl "$NAME" --name 'IDE Controller' --add ide --controller PIIX4
VBoxManage storageattach "$NAME" --storagectl 'IDE Controller' --port 0 --device 0 --type hdd --medium "${IMG}.vmdk"
vagrant box remove -f "$NAME" || :
vagrant package --base "$NAME"
vagrant box add "$NAME"
# VBoxManage unregistervm "$NAME" --delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.