Back up a script [plain] # for creating a VM image by copying it. /Bin/sh machine = $1 mac = $2 ip = $3 if [-z "$ machine"]; then echo "usage: sh $0 machine mac ip "exit fi source_bytes = 'fdisk-ucl/dev/vbd/test00 | grep test00 | grep-Eo" [0-9] + bytes "| cut- d ""-f1 'source_m =$ ($ source_bytes/1024/1024 )) echo "creating new logic volumn $ machine" lvcreate-L $ {source_M} M-n $ machine vbd echo "copy data from lv test00" dd if =/dev/vbd/test00 =/dev/vbd/$ machine bs = 1 M count = $ source_M echo "mount new created logic volumn" kpartx-av/dev/vbd/$ machine echo "scan volumn group" vgscan echo "rename volumn group to $ machine" vgrename test00 $ machine echo "load volumn group $ machine" vgchange-ay $ machine echo "mount logic volumn lv_root" mount/dev/$ machine /lv_root/mnt echo "modify fstab to new volumn group name $ machine" sed-I "s/test00/$ machine/g"/mnt/etc/fstab sed-I "s /test00/$ machine/g "/mnt/etc/sysconfig/network if [-n" $ mac "]; then sed-I "s/00: 16: 3E: 38: 01: e6/$ mac/g "/mnt/etc/sysconfig/network-scripts/ifcfg-eth0 fi if [-n" $ ip "]; then sed-I "s/192.168.1.230/$ ip/g"/mnt/etc/sysconfig/network-scripts/ifcfg-eth0 fi echo "umount lv_root" umount/mnt echo "mount first partition of vbd-$ machine "mount/dev/mapper/vbd-$ {machine} p1/mnt echo" change menu. lst to $ machine "sed-I" s/test00/$ machine/g "/mnt/grub/menu. lst echo "umount vbd-$ machine" umount/mnt echo "disable vg" vgchange-an $ machine echo "disable $ machine" kpartx-d/dev/vbd/$ machine