- Timestamp:
- May 2, 2009, 6:53:34 PM (16 years ago)
- Location:
- trunk/scripts/pv-fixup
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/pv-fixup/lvmanip
r2285 r2321 2 2 exit 1 3 3 4 DISK=/dev/mapper/36090a028407d6e2b2589a45cdb9714894 SOURCE=/dev/mapper/36090a028407d6e2b2589a45cdb971489 5 5 6 6 # The name of the LVM archive to get data from … … 12 12 lvmextractint () { 13 13 perl -lne 'print $1 if (/'"$1"' = ([0-9]+)/)' 14 } 15 16 # Extract the first block of an lv to a file named part-$lv 17 getfirstblock () { 18 lvname="$1" 19 offset=$(grep -A16 $'\t'$lvname $ARCHIVE | grep pv0 | cut -f 2 -d ,); 20 if [ -z "$offset" ]; then echo "WARNING: LV not found"; 21 else 22 echo "Extracting $lvname from offset $offset" 23 dd if=$SOURCE of=part-$lvname bs=1M skip=$(( $offset * 8192 + 384 )) bs=512 count=1; 24 fi 14 25 } 15 26 … … 70 81 else 71 82 echo "# Extracting $lvname from offset $offset PEs with length $length PEs" 72 echo dd if=$ DISKof=/dev/xenvg/$lvname \83 echo dd if=$SOURCE of=/dev/xenvg/$lvname \ 73 84 skip=$(( $offset * 64 + 3 )) bs=64K count=$(( $length * 64 )) 74 85 fi … … 90 101 else 91 102 echo "# Extracting $lvname segment 2 from offset $offset PEs with length $length PEs" 92 echo dd if=$ DISKof=/dev/xenvg/$lvname bs=64K \103 echo dd if=$SOURCE of=/dev/xenvg/$lvname bs=64K \ 93 104 skip=$(($offset*64 + 3)) count=$(($length*64)) seek=$(($seek*64)) 94 105 fi -
trunk/scripts/pv-fixup/pv-fixup
r2272 r2321 36 36 } 37 37 38 lvsleft () {39 lvs -o name,devices xenvg \40 | perl -lane "print \$F[0] if (\$F[1] =~ m|$DISK|)"41 }42 43 38 vmstolvs () { 44 39 perl -pe 's/^/d_/;s/$/_hda/' … … 50 45 | xargs lvs -o size --units=g \ 51 46 | perl -lne '$total += $_; END { print $total; }' 47 } 48 49 lvsleft () { 50 lvs -o name,devices $VG \ 51 | perl -lane "print \$F[0] if (\$F[1] =~ m|$DISK|)" 52 52 } 53 53 … … 108 108 # - pvmove all the LVs back 109 109 110 # Doing this part with CLVM again. 111 112 lvsleft () { 113 lvs -o name,devices $VG \ 114 | perl -lane "print \$F[0] if (\$F[1] =~ m|$TMPDEV|)" 115 } 116 117 movelv () { 118 echo pvmoving $VG/$1... 119 lvchange -an $VG/$1 120 pvmove -i 10 -n $VG/$1 $2 121 lvchange -ay $VG/$1 122 } 123 124 movestuff () { 125 date 126 while read lv; do 127 echo MOVING: $lv >>/var/log/lvm2.log 128 movelv $lv $TMPDEV 129 date 130 done 131 } 132 133 moveall () { 134 date 135 for lv in $(lvsleft); do 136 echo MOVING: $lv >>/var/log/lvm2.log 137 movelv $lv $TMPDEV 138 date 139 done 140 } 141 110 142 #FOREACH host: 111 for lv in $(lvs -o lv_name --noheadings $VG); do 112 movelv $VG/$lv $TMPDEV 113 done 143 #set logging in /etc/lvm/lvm.conf 144 while sleep 1; do 145 echo MARK: $(date) >>/var/log/lvm2.log 146 done & 147 lvsleft | grep -xf <(invirt-listvms | yamlkeys | vmstolvs) \ 148 | movestuff >>/root/lvm/movelv.log 2>&1 149 moveall >>/root/lvm/movelv.log 2>&1 150 while true; do 151 kinit -k -45 152 sh -x status.sh 2>&1 | zwrite -c xvm-auto -i pvmove -O auto 153 sleep 1800 154 done & 114 155 #done 156 157 #suffix=.return-1; mv /var/log/lvm2.log lvm/lvm2.$suffix.log; mv lvm/movelv{,.$suffix}.log 115 158 116 159 # hopefully empty: … … 121 164 vgreduce $VG $TMPDEV 122 165 pvremove $TMPDEV 166 #FOREACH host: 123 167 dmsetup remove $TMPDM 168 #done 124 169 125 170 # - pvresize the new PV to use the whole space
Note: See TracChangeset
for help on using the changeset viewer.