7 # to specify target vg use VG enviroment varible like:
8 # VG=oscarvg ./gnt-lv2ssd.sh dataverse 0
10 if [ "$1" = '-' ] ; then
12 elif [ -z "$instance" -o -z "$disk" ] ; then
13 echo "Usage: $0 instance disk"
17 test -z "$instance" && exit 1
19 test ! -z "VG" && target_vg=$VG
21 instance=`gnt-instance list --no-headers -o name $instance | head -1`
23 node=`gnt-instance list -o pnode --no-headers $instance`
24 echo "# $instance on $node"
28 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
31 disk_nr=`echo $lv | cut -d. -f2 | tr -d a-z_`
32 echo "# $lv | $origin | $disk_nr"
34 cat <<__SHELL__ > /dev/shm/$instance.sh
36 lvcreate -L20480m -s -n$lv.snap /dev/$vg/$lv
38 lvcreate -L$size -n$instance.$disk_nr $target_vg
40 ionice dd if=/dev/$vg/$lv.snap of=/dev/$target_vg/$instance.$disk_nr bs=1M status=progress
42 lvremove -f /dev/$vg/$lv.snap
44 #rm -v /dev/shm/$instance.sh
47 scp /dev/shm/$instance.sh $node:/dev/shm/$instance.sh
49 ssh $node sh -xe /dev/shm/$instance.sh
52 echo "TEST: kvm -m 1024 -drive file=/dev/$target_vg/$instance.$disk_nr,format=raw,if=virtio -nographic -net nic -net user"
53 echo "after login: ifdown eth0 ; dhclient eth0"