3 which pvdisplay >/dev/null 2>&1 && pvdisplay $device >/dev/null 2>&1
8 echo " LVM (linear allocation scheme)"
25 # Step 3: Get pysical extent number
27 pvname="`pvdisplay -c $device 2>/dev/null | awk -F: '{print $1,$2,$8}' | sed -e 's/^ *//'`"
29 if [ -z "$pvname" ]; then
30 echo "! $device is not a physical volume" 1>&2
34 pesize="${pvname##* }"
38 pesize="`dc -e "$pesize 2 * p"`" #`"
39 pestart="`pvs --unit s -ope_start $device 2>/dev/null | sed -n -e 's/ *//g' -e 's/S.*$//' -e '$p'`"
40 penum="`dc -e "$sector $pestart - $pesize ~ n [ ] n p"`" #`"
41 subsector="${penum% *}"
44 echo "device $pvname pv"
45 echo "offset $pestart"
48 echo "subsector $subsector"
51 # Step 4: Find associated logical volume
53 lestart="$(vgdisplay -v $vgname 2>/dev/null | awk '/LV Name/{print $3}' | while read lvname; do \
54 lvdisplay -m $lvname 2>/dev/null \
55 | awk -v RS="\n *\n( --- Segments ---\n)?" \
60 '$0 ~ "Physical volume[ \t]+" pvname && $14<=penum && $16>=penum{print lvname,$4,$14}'; \
63 if [ -z "$lestart" ]; then
64 echo "# pysical extent $penum of $pvname is not mapped in any logical volume" 1>&2
68 lvname="${lestart%% *}"
69 lestart="${lestart#* }"
70 firstpe="${lestart#* }"
71 lestart="${lestart% *}"
72 lenum="`dc -e "$penum $firstpe - $lestart + p"`" #`"
74 echo "device $lvname lv"
78 fssector="`dc -e "$lenum $pesize * $subsector + p"`" #`"
80 echo "sector $fssector"