Skip to content

Instantly share code, notes, and snippets.

@contato318
Last active January 3, 2019 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save contato318/19c3580ccb77cabc37fc0dc7184dd13c to your computer and use it in GitHub Desktop.
Save contato318/19c3580ccb77cabc37fc0dc7184dd13c to your computer and use it in GitHub Desktop.
#!/bin/bash
lista-vms () {
echo "###############################"
echo "VMS existentes: "
VBoxManage list vms
echo ""
}
lista-discos () {
echo "###############################"
echo "Insira os Servidores que serao migrados: "
read SERVIDORES
echo ""
echo "###############################"
echo "Nome dos discos: "
for i in $(echo $SERVIDORES | tr -s '|' '\n' | sed '/^$/d')
do
DISCOS=`VBoxManage showvminfo $i | egrep -i "vmdk|vdi" | awk {' print $5'} | cut -d/ -f3`
echo "$DISCOS"
DISCO_PATH=`VBoxManage showvminfo $i | egrep -i "vmdk|vdi" | awk '{print $4,$5}'`
echo "Caminho: $DISCO_PATH"
done
echo ""
}
convertendo-discos-kvm () {
echo "###############################"
echo "Iniciando convercao dos discos para kvm: "
for i in $(echo $DISCOS)
do
echo "$i"
VBoxManage clonehd "$DISCO_PATH" /tmp/disk.raw
#VBoxManage clonehd disk.vdi disk.raw --format raw
done
}
lista-vms
lista-discos
convertendo-discos-kvm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment