Changeset 3147 in MondoRescue for branches/3.1/mindi/analyze-my-lvm
- Timestamp:
- Jun 19, 2013, 8:34:46 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/mindi/analyze-my-lvm
r2937 r3147 13 13 GetValueFromField() { 14 14 local res 15 sed s/' '/~/ "$1" | tr -s ' ' ' ' | sed s/'~ '/'~'/ | grep -i "$2~" | cut -d'~' -f2,3,4,5 | tr '~' ' ' | gawk '{ if ($2=="MB") {printf "%dm",$1;} else if ($2=="MiB") {printf "%dm",$1;} else if ($2=="KB") {printf "%dk",$1;} else if ($2=="KiB") {printf "%dk",$1;} else if ($2=="GB") {printf "%fg",$1;} else if ($2=="GiB") {printf "%fg",$1;} else if ($2=="TB") {printf "%dt",$1;} else if ($2=="TiB") {printf "%dt",$1;} else {print $0;};}'15 grep -i "$2" "$1" | perl -pi -e 's/\s*(.*)\s\s\s+(.+)$/$2/;s/\sT[i]*B/t/;s/\sG[i]*B/g/;s/\sM[i]*B/m/;s/\sK[i]*B/k/' 16 16 } 17 17 … … 54 54 # Exclude LVs member of that env var 55 55 if [ "$MINDI_EXCLUDE_DEVS" ] ; then 56 list_of_devices="`mindi -- readalllink $LV_full_string`"56 list_of_devices="`mindi --nolog --readalllink $LV_full_string 2> /dev/null`" 57 57 l="" 58 58 for d in $list_of_devices; do … … 84 84 device=$1 85 85 output="" 86 $LVMCMD lvdisplay $device > $fname86 $LVMCMD lvdisplay $device | cat > $fname 87 87 stripes=`GetValueFromField $fname "Stripes"` 88 88 stripesize=`GetValueFromField $fname "Stripe size (MByte)"`m … … 90 90 [ "$stripesize" = "k" ] && stripesize="" 91 91 allocation=`GetValueFromField $fname "LV Size"` 92 [ ! "`echo "$allocation" | grep "[k,m,g ]"`" ] && allocation="$allocation"m92 [ ! "`echo "$allocation" | grep "[k,m,g,t]"`" ] && allocation="$allocation"m 93 93 if echo "$allocation" | grep -E '^.*g$' > /dev/null 2> /dev/null ; then 94 94 val=`echo "$allocation" | sed s/g//` … … 127 127 128 128 129 130 131 129 ProcessVolumeGroup() { 132 130 local current_VG physical_volumes i list_of_devices VG_params … … 152 150 # If multipath check which type of devide are given, mpath prefered 153 151 for d in $list_of_devices; do 154 l="$l `mindi -- readalllink $d`"152 l="$l `mindi --nolog --readalllink $d 2> /dev/null`" 155 153 l="$l `GiveMapperOfdm $d`" 156 154 done … … 184 182 skip=0 185 183 l="" 186 l="$l `mindi -- readalllink $d`"184 l="$l `mindi --nolog --readalllink $d 2> /dev/null`" 187 185 l="$l `GiveMapperOfdm $d`" 188 186 list_of_devices="`echo $l | sort -u`" … … 207 205 for d in `cat $MINDI_TMP/pv.tmp2`; do 208 206 skip=0 209 l="$l `mindi -- readalllink $d`"207 l="$l `mindi --nolog --readalllink $d 2> /dev/null`" 210 208 l="$l `GiveMapperOfdm $d`" 211 209 list_of_devices="`echo $l | sort -u`" … … 239 237 GiveMapperOfdm () { 240 238 241 major=`stat - c "%t" $1 2> /dev/null`242 minor=`stat - c "%T" $1 2> /dev/null`239 major=`stat -L -c "%t" $1 2> /dev/null` 240 minor=`stat -L -c "%T" $1 2> /dev/null` 243 241 244 242 for i in `ls /dev/mapper/*`; do 245 mj=`stat - c "%t" $i`246 mn=`stat - c "%T" $i`243 mj=`stat -L -c "%t" $i` 244 mn=`stat -L -c "%T" $i` 247 245 if [ "$mj" = "$major" ] && [ "$mn" = "$minor" ]; then 248 246 echo "$i" 249 247 return 250 248 fi 249 done 250 echo $1 251 } 252 253 GiveVGLVOfdm () { 254 255 major=`stat -L -c "%t" $1 2> /dev/null` 256 minor=`stat -L -c "%T" $1 2> /dev/null` 257 258 for v in `vgs --noheadings | awk '{print $1}'`; do 259 for i in `ls /dev/$v/*`; do 260 mj=`stat -L -c "%t" $i` 261 mn=`stat -L -c "%T" $i` 262 if [ "$mj" = "$major" ] && [ "$mn" = "$minor" ]; then 263 echo "$i" 264 return 265 fi 266 done 251 267 done 252 268 echo $1 … … 292 308 293 309 ListAllLogicalVolumesSortedBydm() { 294 for d in `ListAllLogicalVolumes` ; do 295 dm=`mindi --readalllink $d | tail -1` 296 echo "$dm|$d" >> $MINDI_TMP/sorteddm 297 done 298 sort -t'|' $MINDI_TMP/sorteddm | cut -d'|' -f2 310 rm -f $MINDI_TMP/sorteddm 311 for d in `ListAllLogicalVolumes` ; do 312 dm=`mindi --nolog --readalllink $d 2> /dev/null | tail -1` 313 echo "$dm|$d" >> $MINDI_TMP/sorteddm 314 done 315 if [ -f $MINDI_TMP/sorteddm ]; then 316 cut -d'-' -f2- $MINDI_TMP/sorteddm | sort -t'|' -n | cut -d'|' -f2 317 fi 299 318 } 300 319 … … 333 352 # -------------------------------- main ----------------------------------- 334 353 354 # These exports are needed to avoid bad formating of display commands (, instead of . for separator e.g.) 355 # Fix #654 356 export LANG=C 357 export LANGUAGE=C 358 335 359 if [ "$1" = "--givemapperofdm" ] ; then 336 360 shift 337 361 if [ _"$1" != _"" ] ; then 338 362 GiveMapperOfdm $1 363 fi 364 exit 0 365 fi 366 367 if [ "$1" = "--givevglvofdm" ] ; then 368 shift 369 if [ _"$1" != _"" ] ; then 370 GiveVGLVOfdm $1 339 371 fi 340 372 exit 0
Note:
See TracChangeset
for help on using the changeset viewer.