#!/bin/bash

VG_NAME=datavg

echo "n
p



t

8e
w
" | fdisk /dev/vdb
partprobe
vgcreate ${VG_NAME} /dev/vdb1
selfpesize=$(vgdisplay ${VG_NAME} | grep 'Total PE' | awk '{print $3}')
lvcreate -l ${selfpesize} -n lvdata ${VG_NAME}
mkfs.xfs /dev/mapper/${VG_NAME}-lvdata
mkdir -p /data
selffstab="/dev/mapper/${VG_NAME}-lvdata       /data          xfs    defaults        0 0"
echo "${selffstab}" >> /etc/fstab
mount -a


