Created
March 19, 2012 19:41
-
-
Save jsomara/2125558 to your computer and use it in GitHub Desktop.
use virt-clone & virt-edit to clone a qemu vm
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/sh | |
# clonio | |
# replace /home/jsomara/images with where you're copying your image from | |
# usage sudo sh clonio.sh rhel-6.2-base zoidberg | |
# rhel-6-2-base.img is in /home/jsomara/images/rhel-6-2-base.img | |
# zoidberg.img ends up in /home/jsomara/images | |
# thanks to jeckersb | |
virt-clone -o $1 -n $2 -f /home/jsomara/images/$2.img | |
MAC=$(cat /etc/libvirt/qemu/$2.xml | grep 'mac address' | sed -r "s/^[^']+'([^']+)'.*/\1/") | |
virt-edit -d $2 /etc/sysconfig/network-scripts/ifcfg-eth0 -e 's/^HWADDR.*/HWADDR="'$MAC'"/' | |
virt-edit -d $2 /etc/sysconfig/network -e 's/^HOSTNAME=.*/HOSTNAME="'$2'"/' | |
guestfish -d $2 -i rm /etc/udev/rules.d/*persistent-net* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment