#!/bin/bash MULTIPATH_BINDINGS=/etc/multipath/bindings CASTVG=fccast get_disk_size () { diskpath=$1 #parted -s $diskpath unit b print | sed -n '/^Disk/s/[^:]\+: \([0-9]\+\)B/\1/p' # in case no disk label - parted is unable to output disk size, lets use old good fdisk fdisk -l $diskpath | sed -n '/^Disk/s/[^,]\+, \([0-9]\+\) bytes/\1/p' } for fc in $( cat $MULTIPATH_BINDINGS | sed -n '/^fc-/p' | sed 's/^fc-\([^ ]\+\) .*/\1/' ); do fcpath=/dev/mapper/fc-$fc lvpath=/dev/${CASTVG}/$fc lvs $lvpath > /dev/null 2>&1 if [ $? -ne 0 ]; then fcsize=$( get_disk_size $fcpath ) lvcreate -L ${fcsize}B -n $fc ${CASTVG} fi dd if=$fcpath of=$lvpath bs=1M done