Created
March 15, 2011 03:56
-
-
Save tbatchelli/870284 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# register-vm.sh <path-to-vm> [<dest-dir>] (default dest-dir is ~/vmfest) | |
models_dir={$2-~/vmfest}/models | |
nodes_dir={$2-~/vmfest}/nodes | |
mkdir -p $models_dir | |
mkdir -p $nodes_dir | |
echo "Registering image $1" | |
source_path=$1 | |
file_name=$(basename $source_path) | |
dest_path=$models_dir/$file_name | |
vm_name="vmfest-HD-register-hack" | |
echo "Cloning to $dest_path" | |
VBoxManage clonehd $source_path $dest_path | |
# all this is needed to ensure that the cloned hd is properly registered | |
VBoxManage createvm --name $vm_name --register | |
VBoxManage storagectl $vm_name --name "sata" --add sata | |
VBoxManage storageattach $vm_name --storagectl "sata" --port 0 --device 0 --mtype immutable --type hdd --medium $dest_path | |
VBoxManage unregistervm $vm_name --delete | |
# make the hd immutable | |
VBoxManage modifyhd $dest_path --type immutable | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment