20120914

One Whole VG for an LV


#!/pathtoshell
VG=$1
LV=$2
MOUNTPOINT=$3
MPATH=0
for i in `ls /sys/class/scsi_host/host*/scan`
  do echo "- - -" > $i; done
sleep 5
multipath -ll
echo -n "enter mpath:"
read MPATH
pvcreate /dev/mapper/${MPATH}
vgcreate -s 32 $VG /dev/mapper/${MPATH}
lvcreate -l 100%VG -n $LV $VG
mkfs.ext4 /dev/mapper/${VG}-${LV}
if [ ! -d $MOUNTPOINT ]
  then mkdir $MOUNTPOINT; fi
mount /dev/mapper/${VG}-${LV} $MOUNTPOINT
echo -e \
  "/dev/mapper/${VG}-${LV}" "\t" \
  "${MOUNTPOINT}" "\t" \
  "ext4" "\t" "defaults" "\t" "1 2" \
  >> /etc/fstab

No comments:

Post a Comment