# Linux LVM Tool完整版本: http://xin23.blog.51cto.com/1827266/1198836 (update 2013.5.13) # 脚本仅供交流学习使用! # 脚本当前版本为1.0.实现了物理卷的创建,移除,更改(启用/禁用分配),扫描,查看功能.#
# Linux LVM Tool完整版本: http://xin23.blog.51cto.com/1827266/1198836(update 2013.5.13)
# 脚本仅供交流学习使用!
# 脚本当前版本为1.0.实现了物理卷的创建,移除,更改(启用/禁用分配),扫描,查看功能.# 后续会补齐卷组和逻辑卷的管理,整合成一个Linux LVM TOOL.类似于AIX的SMIT.虽然,它只能管理LVM.# 脚本已在Red Hat Enterprise Linux 5.4 64bit上测试通过.原则上适用于RHEL 5和RHEL 6.# 欢迎提出改进意见.# 直接复制请注意标点符号.也可通过微盘下载文件,避免复制引起的问题:http://vdisk.weibo.com/s/zKW6M#!/bin/bash# Version 1.0# AUTHOR:Xin23 http://weibo.com/231988PV(){NextLine(){ echo ' '}Split(){ echo '-----------------------------------------------------------------------'}EchoTitle(){ echo "--------$Title-----------------------------------------"}ShowPVFirstMenu(){ echo ' Physical Volumn Main Menu Input Number To Choose! Create Physical Volumn ...... 1 Remove Physical Volumn ...... 2 Change Physical Volumn ...... 3 Show Physical Volumn ...... 4 Scan Physical Volumn ...... 5 Exit ...... 6' NextLine}GetChoice(){ read -p ' Input Your Choice: ' Var NextLine}ConfirmOperate(){ NextLine echo " Continue ...... y Return ...... n" NextLine GetChoice NextLine Run}Run(){ if [ $Var == y ] then $Parameter $Disk elif [ $Var == n ] then Split PV else ConfirmOperate fi}ChooseDisk(){ read -p " Please Choose Disk: (Example: /dev/sdc) " Disk NextLine}PVChange(){ echo ' Which Operate You Want To do ? ' NextLine echo ' ENABLE Allocatable ...... y DISABLE Allocatable ...... n' NextLine GetChoice}CheckPVChange(){ if [ $Var == y ] then Parameter='pvchange -x y' elif [ $Var == n ] then Parameter='pvchange -x n' else PVChange fi}PVShow(){ echo ' Which Physical Volumn You Want To Show ? ' NextLine echo ' All Physical Volumn ...... 1 Single Physical Volumn ...... 2' NextLine GetChoice}CheckPVShow(){ if [ $Var -eq 1 ] then pvdisplay elif [ $Var -eq 2 ] then pvdisplay $Disk fi}TestPVShow(){ if [ $Var -eq 1 ] then Disk=All elif [ $Var -eq 2 ] then EchoTitle NextLine ChooseDisk fi}ShowPVFirstMenuGetChoicecase $Var in "1") Title='Create Physical Volumn' Parameter=pvcreate EchoTitle NextLine ChooseDisk echo " Disk $Disk Will Be Convert To Physical Volumn" ConfirmOperate Status=0 ;; "2") Title='Remove Physical Volumn' EchoTitle Parameter=pvremove NextLine ChooseDisk echo " Disk $Disk Will Be Remove From Physical Volumn" ConfirmOperate Status=0 ;; "3") Title='Change Physical Volumn' EchoTitle NextLine PVChange CheckPVChange NextLine ChooseDisk echo " Physical Volumn $Disk Will Be Change" ConfirmOperate Status=0 ;; "4") Title='Show Physical Volumn' EchoTitle NextLine PVShow NextLine TestPVShow echo " Physical Volumn $Disk Will Be Show" NextLine CheckPVShow Status=0 ;; "5") Title='Scan Physical Volumn' EchoTitle NextLine pvscan Status=0 ;; "6") exit 0 ;; * ) echo ' Input Error,Retype!' PV ;;esacNeedContinue(){ if [ $Status -eq 0 ] then NextLine Split PV fi}NeedContinue}PV