Create a gist now

Instantly share code, notes, and snippets.

@ardrabczyk /vb.sh
Last active Feb 18, 2016

What would you like to do?
vb.sh: create a new virtualbox machine
#!/usr/bin/env sh
# vb.sh: create a new virtualbox machine
#
## (c) 2016, Arkadiusz Drabczyk, arkadiusz@drabczyk.org
if [ "$#" -lt 2 ]
then
echo Usage: "$0" \<MACHINE-NAME\> \<ISO\> [RAM] [DISK] [TYPE]
echo Example:
echo ./vb.sh \"Slackware x64 14.1\" slackware64-14.1-install-dvd.iso
echo RAM is 256 megabytes if not explicitly requested.
echo Disk is 20 gigabytes if not explicitly requested.
echo Type is Linux_64 if not explicitly requested.
exit 1
fi
ram=${3:-256}
hdd=${4:-20000}
type=${5:-Linux_64}
set -e
vboxmanage createvm --name "$1" \
--ostype "$type" \
--register
vboxmanage modifyvm "$1" \
--memory "$ram" \
--usb on
vboxmanage createhd --filename "$PWD/${1}.vdi" \
--size "$hdd"
vboxmanage storagectl "$1" \
--name "IDE Controller" \
--add ide
vboxmanage storageattach "$1" \
--storagectl "IDE Controller" \
--port 0 \
--device 0 \
--type hdd \
--medium "$PWD/${1}.vdi"
vboxmanage storageattach "$1" \
--storagectl "IDE Controller" \
--port 1 \
--device 0 \
--type dvddrive \
--medium "$2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment