Created
October 5, 2016 17:12
-
-
Save lpenz/3901602f38f7b114379781bc2d6adb7d to your computer and use it in GitHub Desktop.
Create a package.box for vagrant (virtualbox) from the specified raw img file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IMG=${1?usage: $0 <img>} | |
NAME=wheezy32 | |
set -e -x | |
rm -f "${IMG}.vmdk" package.box | |
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" package.box | |
# VBoxManage unregistervm "$NAME" --delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment