7 if [ "$1" = '-' ] ; then
9 elif [ -z "$instance" -o -z "$disk" ] ; then
10 echo "Usage: $0 instance disk"
14 test -z "$instance" && exit 1
16 instance=`gnt-instance list --no-headers -o name $instance | head -1`
18 node=`gnt-instance list -o pnode --no-headers $instance`
19 echo "# $instance on $node"
23 ssh $node lvs -o name,tags,vg_name,size | grep $instance | tee /dev/shm/$instace.$node.lvs | grep disk${disk}_data | while read lv origin vg size ; do
26 disk_nr=`echo $lv | cut -d. -f2 | tr -d a-z_`
27 echo "# $lv | $origin | $disk_nr"
29 cat <<__SHELL__ > /dev/shm/$instance.sh
31 lvcreate -L20480m -s -n$lv.snap /dev/$vg/$lv
33 lvcreate -L$size -n$instance.$disk_nr $target_vg
35 ionice dd if=/dev/$vg/$lv.snap of=/dev/$target_vg/$instance.$disk_nr bs=1M status=progress
37 lvremove -f /dev/$vg/$lv.snap
39 #rm -v /dev/shm/$instance.sh
42 scp /dev/shm/$instance.sh $node:/dev/shm/$instance.sh
44 ssh $node sh -xe /dev/shm/$instance.sh
47 echo "TEST: kvm -m 1024 -drive file=/dev/$target_vg/$instance.$disk_nr,format=raw,if=virtio -nographic -net nic -net user"
48 echo "after login: ifdown eth0 ; dhclient eth0"