sunnyadamm
2020-09-16 17:45:16 +08:00
以前平台写的,凑活用的,盘符那一块你自己处理下
Vg_Name=datavg
Lv_Name=datalv
Lv_Path=/dev/$Vg_Name/$Lv_Name
Mount_Point=/data
let ms=`fdisk -l| grep '/dev/vdb' | awk '{print $3}'|awk -F. '{print $1}'`
if [ $ms -gt 2048 ]
then
parted -s /dev/vdb mklabel gpt
parted -s /dev/vdb mkpart primary 1 100%
fi
fdisk /dev/vdb << EOF
n
p
1
w
EOF
echo 'Disk /dev/vdb sucessful'
pvcreate /dev/vdb1>/dev/null
vgcreate $Vg_Name /dev/vdb1>/dev/null
lvcreate -l `vgdisplay datavg|grep 'Free'|cut -d ' ' -f14` -n $Lv_Name /dev/$Vg_Name>/dev/null
[ `uname -r |cut -d. -f1` -le 2 ] && mkfs.ext4 $Lv_Path>/dev/null || mkfs.xfs $Lv_Path>/dev/null
mkdir $Mount_Point
[ `uname -r |cut -d. -f1` -le 2 ] && echo "$Lv_Path $Mount_Point ext4 defaults 0 0">>/etc/fstab
[ `uname -r |cut -d. -f1` -ge 3 ] && echo "$Lv_Path $Mount_Point xfs defaults 0 0">>/etc/fstab
mount -a