install windows 10 using ide disk and virtio.iso drivers
[gnt-info] / gnt-lv2ssd.sh
1 #!/bin/sh -e
2
3 instance=$1
4 disk=$2
5 target_vg=ssd
6
7 # to specify target vg use VG enviroment varible like:
8 # VG=oscarvg ./gnt-lv2ssd.sh dataverse 0
9
10 if [ "$1" = '-' ] ; then
11         read instance disk
12 elif [ -z "$instance" -o -z "$disk" ] ; then
13         echo "Usage: $0 instance disk"
14         exit 1
15 fi
16
17 test -z "$instance" && exit 1
18
19 test ! -z "VG" && target_vg=$VG
20
21 instance=`gnt-instance list --no-headers -o name $instance | head -1`
22
23 node=`gnt-instance list -o pnode --no-headers $instance`
24 echo "# $instance on $node"
25
26 found_lvm=0
27
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
29         found_lvm=1
30
31         disk_nr=`echo $lv | cut -d. -f2 | tr -d a-z_`
32         echo "# $lv | $origin | $disk_nr"
33
34 cat <<__SHELL__ > /dev/shm/$instance.sh
35
36         lvcreate -L20480m -s -n$lv.snap /dev/$vg/$lv
37
38         lvcreate -L$size -n$instance.$disk_nr $target_vg
39         
40         ionice dd if=/dev/$vg/$lv.snap of=/dev/$target_vg/$instance.$disk_nr bs=1M status=progress
41
42         lvremove -f /dev/$vg/$lv.snap
43
44         #rm -v /dev/shm/$instance.sh
45 __SHELL__
46
47         scp /dev/shm/$instance.sh $node:/dev/shm/$instance.sh
48
49         ssh $node sh -xe /dev/shm/$instance.sh
50
51
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"
54 done
55