Skip to content

Instantly share code, notes, and snippets.

@willscripted
Created January 11, 2013 02:20
Show Gist options
  • Save willscripted/4507446 to your computer and use it in GitHub Desktop.
Save willscripted/4507446 to your computer and use it in GitHub Desktop.
Script to kill and replace practice vms
#!/bin/bash
for i in `seq 1 8`;
do
name="userv-00$i"
echo $name
# Remove old
vboxmanage controlvm $name poweroff
vboxmanage storageattach $name --storagectl SATA\ Controller --port 0 --type hdd --device 0 --medium none
vboxmanage closemedium disk ../$name/$name.vdi --delete
# Create new
vboxmanage clonehd ubuntu-12.04-basebox.vdi $name.vdi
mv ./$name.vdi ../$name/
# Attach
vboxmanage storageattach $name --storagectl SATA\ Controller --medium ../$name/$name.vdi --type hdd --port 0
vboxmanage startvm $name --type headless
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment