source: trunk/scripts/pv-fixup/lvmanip @ 2271

Last change on this file since 2271 was 2271, checked in by quentin, 16 years ago

LV manipulation shell functions

File size: 1.0 KB
Line 
1# The name of the LVM archive to get data from
2ARCHIVE=/etc/lvm/archive/xenvg_00685.vg
3
4# Extract the first block of an lv to a file named part-$lv
5getfirstblock () {
6lvname="$1"
7offset=$(grep -A16 $'\t'$lvname $ARCHIVE  | grep pv0 | cut -f 2 -d ,);
8if [ -z "$offset" ]; then echo "WARNING: LV not found";
9else
10echo "Extracting $lvname from offset $offset"
11dd if=/dev/mapper/36090a028407d6e2b2589a45cdb971489 of=part-$lvname bs=1M skip=$(( $offset * 8192 + 384 )) bs=512 count=1;
12fi
13}
14
15# Generate a dd command to copy the lv data to /dev/xenvg/$lv
16ddlv () {
17lvname="$1"
18offset=$(grep -A16 $'\t'$lvname $ARCHIVE  | grep pv0 | cut -f 2 -d ,);
19length=$(( $(grep -A16 $'\t'$lvname $ARCHIVE  | grep extent_count | cut -f 2 -d = | cut -f 1 -d '#') ));
20if [ -z "$offset" ]; then echo "# WARNING: LV $lvname not found";
21else
22echo "#Extracting $lvname from offset $offset with length $length"
23echo dd if=/dev/mapper/36090a028407d6e2b2589a45cdb971489 of=/dev/xenvg/$lvname bs=1M skip=$(( $offset * 8192 + 384 )) ibs=512 obs=4194304 count=$length
24fi
25}
Note: See TracBrowser for help on using the repository browser.