Changeset 2321 for trunk


Ignore:
Timestamp:
May 2, 2009, 6:53:34 PM (16 years ago)
Author:
price
Message:

pv-fixup, lvmanip: last tweaks

This is from the very beginning of April, at the close of the LVM saga.
Somehow I never pushed.

Location:
trunk/scripts/pv-fixup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/pv-fixup/lvmanip

    r2285 r2321  
    22exit 1
    33
    4 DISK=/dev/mapper/36090a028407d6e2b2589a45cdb971489
     4SOURCE=/dev/mapper/36090a028407d6e2b2589a45cdb971489
    55
    66# The name of the LVM archive to get data from
     
    1212lvmextractint () {
    1313  perl -lne 'print $1 if (/'"$1"' = ([0-9]+)/)'
     14}
     15
     16# Extract the first block of an lv to a file named part-$lv
     17getfirstblock () {
     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
    1425}
    1526
     
    7081  else
    7182    echo "# Extracting $lvname from offset $offset PEs with length $length PEs"
    72     echo dd if=$DISK of=/dev/xenvg/$lvname \
     83    echo dd if=$SOURCE of=/dev/xenvg/$lvname \
    7384      skip=$(( $offset * 64 + 3 )) bs=64K count=$(( $length * 64 ))
    7485  fi
     
    90101  else
    91102    echo "# Extracting $lvname segment 2 from offset $offset PEs with length $length PEs"
    92     echo dd if=$DISK of=/dev/xenvg/$lvname bs=64K \
     103    echo dd if=$SOURCE of=/dev/xenvg/$lvname bs=64K \
    93104      skip=$(($offset*64 + 3)) count=$(($length*64)) seek=$(($seek*64))
    94105  fi
  • trunk/scripts/pv-fixup/pv-fixup

    r2272 r2321  
    3636}
    3737
    38 lvsleft () {
    39   lvs -o name,devices xenvg \
    40     | perl -lane "print \$F[0] if (\$F[1] =~ m|$DISK|)"
    41 }
    42 
    4338vmstolvs () {
    4439  perl -pe 's/^/d_/;s/$/_hda/'
     
    5045   | xargs lvs -o size --units=g \
    5146   | perl -lne '$total += $_; END { print $total; }'
     47}
     48
     49lvsleft () {
     50  lvs -o name,devices $VG \
     51    | perl -lane "print \$F[0] if (\$F[1] =~ m|$DISK|)"
    5252}
    5353
     
    108108#  - pvmove all the LVs back
    109109
     110# Doing this part with CLVM again.
     111
     112lvsleft () {
     113  lvs -o name,devices $VG \
     114    | perl -lane "print \$F[0] if (\$F[1] =~ m|$TMPDEV|)"
     115}
     116
     117movelv () {
     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
     124movestuff () {
     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
     133moveall () {
     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
    110142#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
     144while sleep 1; do
     145  echo MARK: $(date) >>/var/log/lvm2.log
     146done &
     147lvsleft | grep -xf <(invirt-listvms | yamlkeys | vmstolvs) \
     148 | movestuff >>/root/lvm/movelv.log 2>&1
     149moveall >>/root/lvm/movelv.log 2>&1
     150while true; do
     151  kinit -k -45
     152  sh -x status.sh 2>&1 | zwrite -c xvm-auto -i pvmove -O auto
     153  sleep 1800
     154done &
    114155#done
     156
     157#suffix=.return-1; mv /var/log/lvm2.log lvm/lvm2.$suffix.log; mv lvm/movelv{,.$suffix}.log
    115158
    116159# hopefully empty:
     
    121164vgreduce $VG $TMPDEV
    122165pvremove $TMPDEV
     166#FOREACH host:
    123167dmsetup remove $TMPDM
     168#done
    124169
    125170#  - pvresize the new PV to use the whole space
Note: See TracChangeset for help on using the changeset viewer.