Ignore:
Timestamp:
Mar 25, 2009, 7:23:45 PM (16 years ago)
Author:
price
Message:

lvmanip: handle second-segment failures

File:
1 edited

Legend:

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

    r2273 r2274  
    2121  perl -ne 'print if ( /^(\s*)'"$1"' \{/ ... /^$1\}/ )' $ARCHIVE
    2222}
     23segment2 () {
     24  perl -ne 'print if ( /^(\s*)segment2 \{/ ... /^$1\}/ )'
     25}
     26
    2327
    2428# Generate a dd command to copy the LV data to /dev/xenvg/$lv
     
    4145  fi
    4246}
     47
     48# Generate a dd command to copy the LV data for the second segment.
     49ddlv2 () {
     50  lvname="$1"
     51  if ! lvinfo $lvname | grep -q 'segment_count = 2'; then
     52    echo "# WARNING: LV $lvname has other than two segments, skipping" >&2
     53    return 1
     54  fi
     55  offset=$(lvinfo $lvname | segment2 | perl -lne 'print $1 if (/"pv0", ([0-9]+)/)')
     56  length=$(lvinfo $lvname | segment2 | perl -lne 'print $1 if (/extent_count = ([0-9]+)/)')
     57  seek=$(lvinfo $lvname | segment2 | perl -lne 'print $1 if (/start_extent = ([0-9]+)/)')
     58
     59  if [ -z "$offset" ]; then
     60    echo "# WARNING: LV $lvname not found";
     61  else
     62    echo "# Extracting $lvname segment 2 from offset $offset PEs with length $length PEs"
     63    echo dd if=$DISK of=/dev/xenvg/$lvname bs=64K \
     64      skip=$(($offset*64 + 3)) count=$(($length*64)) seek=$(($seek*64))
     65  fi
     66}
Note: See TracChangeset for help on using the changeset viewer.