From: Quentin Smith Date: Wed, 25 Mar 2009 03:25:12 +0000 (-0400) Subject: LV manipulation shell functions X-Git-Url: http://xvm.mit.edu/gitweb/invirt/scripts/pv-fixup.git/commitdiff_plain/ec46c89878c5eec920bf681ede8bc9480caca240 LV manipulation shell functions svn path=/trunk/scripts/pv-fixup/; revision=2271 --- diff --git a/lvmanip b/lvmanip new file mode 100644 index 0000000..44b61ca --- /dev/null +++ b/lvmanip @@ -0,0 +1,25 @@ +# The name of the LVM archive to get data from +ARCHIVE=/etc/lvm/archive/xenvg_00685.vg + +# Extract the first block of an lv to a file named part-$lv +getfirstblock () { +lvname="$1" +offset=$(grep -A16 $'\t'$lvname $ARCHIVE | grep pv0 | cut -f 2 -d ,); +if [ -z "$offset" ]; then echo "WARNING: LV not found"; +else +echo "Extracting $lvname from offset $offset" +dd if=/dev/mapper/36090a028407d6e2b2589a45cdb971489 of=part-$lvname bs=1M skip=$(( $offset * 8192 + 384 )) bs=512 count=1; +fi +} + +# Generate a dd command to copy the lv data to /dev/xenvg/$lv +ddlv () { +lvname="$1" +offset=$(grep -A16 $'\t'$lvname $ARCHIVE | grep pv0 | cut -f 2 -d ,); +length=$(( $(grep -A16 $'\t'$lvname $ARCHIVE | grep extent_count | cut -f 2 -d = | cut -f 1 -d '#') )); +if [ -z "$offset" ]; then echo "# WARNING: LV $lvname not found"; +else +echo "#Extracting $lvname from offset $offset with length $length" +echo dd if=/dev/mapper/36090a028407d6e2b2589a45cdb971489 of=/dev/xenvg/$lvname bs=1M skip=$(( $offset * 8192 + 384 )) ibs=512 obs=4194304 count=$length +fi +}