shell之lvm
#!/bin/bash
#this script for LVM
echo "Initial a disk..."
echo -e "\033[31mWarning: \033[0m"
fdisk -l | grep -o "^Disk /dev/[sv]d[a-z]"
read -p "What's disk Your choice:" DISK
if [ "$DISK" == 'quit' ] || [ "$DISK" == 'q' ]; then
echo "quit"
exit 7
fi
######################Check input ################################
until fdisk -l | grep -o "^Disk /dev/[sv]d[a-z]" | grep "^Disk $DISK$" &> /dev/null;do
read -p "Wrong option,your choice again:" DISK
if [ $DISK == quit ] ; then
echo "quit"
exit 7
fi
done
########################Check mount#############################
if mount | grep "$DISK" &> /dev/null;then
echo `mount | grep "^$DISK" | awk '{print $1}'` is busy
read -p "Will you continue?" CHOICE
until [ $CHOICE == 'y' -o $CHOICE == 'n' ] ; do
read -p "wrong choice ,please try again:" CHOICE
done
if [ $CHOICE == 'n' ] ;then
echo "$DISK is busy,initial disk stop..."
exit 9
else
for I in `mount | grep "$DISK" | awk '{print $1}'`;do
fuser -km $I
umount $I
echo "$I umount ok"
done
######################Continue building disk?##########################
read -p "will destroy all data, continue?" CHOICE
until [ $CHOICE == 'y' -o $CHOICE == 'n' ] ; do
read -p "wrong choice ,please try again:" CHOICE
done
if [ $CHOICE == 'n' ] ;then
echo "$DISK have exist data,initial disk stop..."
exit 9
else
dd if=/dev/zero of=$DISK bs=512 count=1
sync
sleep 3
#######################fdisk $DISK##############################
echo 'n
p
1
t
8e
w' | fdisk -cu $DISK &> /dev/null
sleep 2
fi
fi
else
echo 'n
p
1
t
8e
w' | fdisk -cu $DISK &> /dev/null
sleep 2
fi
#####################initial disk ####################################
read -p "Do you want to initial? " INITIAL
{
[ $INITIAL == Y ] || [ $INITIAL == y ] || [ $INITIAL == 'YES' ] || [ $INITIAL == 'yes' ]
} && {
read -p "Please input vg_disk: " VG_DISK
read -p "Please input lv_disk: " LV_DISK
read -p "Please input lvs_disk's size: " LVS_SIZE
read -p "Please input File system type: " LVS_TYPE
pvcreate ${DISK}1 >/dev/null 2>&1
vgcreate $VG_DISK ${DISK}1 > /dev/null 2>&1
lvcreate -L $LVS_SIZE -n $LV_DISK $VG_DISK > /dev/null 2>&1
mkfs.$LVS_TYPE /dev/$VG_DISK/$LV_DISK > /dev/null 2>&1
##########################mount disk###################################
read -p "Do you want to mount now: " LVS_MOUNT
{
[ $LVS_MOUNT == Y ] || [ $LVS_MOUNT == y ] || [ $LVS_MOUNT == 'YES' ] || [ $LVS_MOUNT == 'yes' ]
} && {
read -p "Please input mount point: " LVS_POINT
[ -d ${LVS_POINT} ] || mkdir -p ${LVS_POINT}
echo "/dev/$VG_DISK/$LV_DISK ${LVS_POINT} $LVS_TYPE defaults 0 0 " >> /etc/fstab
mount -a
} || exit
} || exit
最新文章
- [原创]java WEB学习笔记105:Spring学习---AOP介绍,相关概念,使用AOP,利用 方法签名 编写 AspectJ 切入点表达式
- lecture9-提高模型泛化能力的方法
- CF360B Levko and Array (二分查找+DP)
- 深入学习Heritrix---解析处理器(Processor)(转)
- IE 、Firefox、Chrome 浏览器在 F12 控制台下切换至不同框架介绍
- 从零开始学习jQuery (七) jQuery动画-让页面动起来!
- Spring aop 小例子demo
- 关于EsayUI中datagrid重复提交后台查询数据的问题
- Health Check - 每天5分钟玩转 Docker 容器技术(142)
- Android--APP性能测试工具GT的使用总结
- [Abp 源码分析]八、缓存管理
- [zz]蟑螂蚂蚁蚊子已不住在我家了!这个方法100%见效…
- mac显示影藏文件
- python接口自动化20-requests获取响应时间(elapsed)与超时(timeout) ok试了 获取响应时间的
- 【arc093f】Dark Horse(容斥原理,动态规划,状态压缩)
- ReactNative——UI1.登录界面样式设置
- Docker+Kubernetes(k8s)微服务容器化实践
- Hive之GROUP BY详解
- GDAL2.0编译——32位和64位
- Netstat 的 10 个基本用法