因客户需要,才写出的这个脚本,私藏不太好,所以就放出来吧!
脚本地址放在傲游主机的博客,这样也算是宣传了。。。
注意:仅在CentOS系统中成功运行,不确定此脚本能否在其他版本系统运行!
警告:本人不负责此脚本带来的任何问题,请确保在新VPS内运行,以免数据丢失!
wget http://blog.aoyouhost.com/scripts/AutoMountLVM.sh chmod 775 AutoMountLVM.sh ./AutoMountLVM.sh | tee AutoMountLVM.log;
附脚本全文:
#/bin/bash #Auto LVM for XenSystem #wget http://blog.aoyouhost.com/scripts/AutoMountLVM.sh; chmod 775 AutoMountLVM.sh; ./AutoMountLVM.sh | tee AutoMountLVM.log; # 海棠姐姐 echo "AoyouHost Auto LVM for XenSystem" echo echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "Operating risk, only use new VPS" echo "Press Ctrl + C to cancel" echo "Any key to continue" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" read -n 1 vgName=`vgdisplay | grep 'VG Name' | awk '{print $NF}'` echo "VG Name:"$vgName lvPath=`lvdisplay | grep 'LV Path' | awk '{print $NF}' | head -n 1` echo "LV Path:"$lvPath #Create lv fdisk /dev/xvdb <<EOF n p 1 t 8e w EOF pvcreate /dev/xvdb1 #Add LV to VG vgextend $vgName /dev/xvdb1 #Find VG Free Size vgSize=`vgdisplay | grep 'Free PE / Size' | awk '{print $(NF-1)}'` vgFreeSizeUnit=`vgdisplay | grep 'Free PE / Size' | awk '{print $(NF)}'` #Add LV Size echo `lvresize -L +${vgSize%.*}$vgFreeSizeUnit $lvPath` lvresize -L +${vgSize%.*}$vgFreeSizeUnit $lvPath #Find VG Free Size vgSize=`vgdisplay | grep 'Free PE / Size' | awk '{print $(NF-1)}'` vgFreeSizeUnit=`vgdisplay | grep 'Free PE / Size' | awk '{print $(NF)}'` #Add LV Size lvresize -L +$vgSize$vgFreeSizeUnit $lvPath resize2fs $lvPath #Show LV Size echo echo Disk Size:`lvdisplay | grep "LV Size" | awk '{print $(NF-1)}' | head -n 1`GB rm -rf AutoMountLVM.sh