Skip to content

Instantly share code, notes, and snippets.

@HoffmannP
Created December 12, 2013 00:59
Show Gist options
  • Save HoffmannP/7921504 to your computer and use it in GitHub Desktop.
Save HoffmannP/7921504 to your computer and use it in GitHub Desktop.
Creating a copy of you harddrives for a virtual machine copy
#!/bin/bash
## VM Clone ##
VM="$1" # "MeinRechner"
System="Debian_64"
isoFolder="$2" #"/root/VirtualBox VMs/MeinRechner"
strgCtl="sata"
VBM="/usr/bin/VBoxManage"
$VBM createvm --name $VM --ostype $System --register
$VBM storagectl $VM --name $strgCtl --add sata
i=0; for dev in /dev/sd?; do
$VBM internalcommands createrawvmdk -filename $(basename $dev).vmdk -rawdisk $dev
$VBM storageattach $VM --storagectl $strgCtl --port $i --type hdd --medium $(basename $dev).vmdk
let i=$i+1;
done;
for iso in $isoFolder/*.iso; do
$VBM storageattach $VM --storagectl $strgCtl --port $i --type dvddrive --medium $iso
let i=$i+1;
done;
$VBM modifyvm $VM --memory 2048
$VBM modifyvm $VM --cpus 2
$VBM modifyvm $VM --boot1 dvd
$VBM showvminfo $VM | less
echo VBoxHeadless -s $VM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment