当前位置:网站首页>【Shell脚本练习】将新加的磁盘批量添加到指定的VG中
【Shell脚本练习】将新加的磁盘批量添加到指定的VG中
2022-04-23 05:59:00 【Sebastien23】
需求描述
现有几百台服务器新加了一块10GB大小的虚拟磁盘,需要将这些磁盘都加到指定的VG中去。磁盘的设备文件名可能为 /dev/vdb
、/dev/vdc
、/dev/vdd
等(/dev/vda
是系统分区所在的磁盘)。
脚本编写
#!/bin/bash
echo "Summary of fdisk -l:"
fdisk -l | grep vd
fdisk -l | grep vd > ./checkDisk_fdisk_tmpfile
echo "Summary of pvscan:"
pvscan
pvscan > ./checkDisk_pvs_tmpfile
for x in /dev/vd[^a]*
do
echo "Checking ${x} ..."
if grep ${x} ./checkDisk_pvs_tmpfile
then
continue
else
echo "${x} is not used for PV."
if grep ${x} ./checkDisk_fdisk_tmpfile | grep '10.7 GB'
then
echo "${x} is 10GB. Now creating PV with ${x} ..."
pvcreate ${x}
vgextend rootvg ${x}
fi
fi
done
echo "All vdisk are checked. Summary of pvscan:"
pvscan
版权声明
本文为[Sebastien23]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Sebastien23/article/details/124256104
边栏推荐
猜你喜欢
js中entries(),keys(),values() , some(), Object.assign()遍历数组用法
Leak detection and vacancy filling (III)
TP5 uses redis
Parse PSD files and map them into components
freeCodeCamp----arithmetic_arranger练习
模仿扇贝短文阅读页面
JS implementation of web page rotation map
TP5 使用redis
阅读笔记:Meta Matrix Factorization for Federated Rating Predictions
postMan 传参总结
随机推荐
PHP unlimited classification and tree
fdfs启动
New features of ES6
mysql中sum (if)_mysql 中sum (if())
Leak detection and vacancy filling (IV)
The time format is incorrect, and an error is reported when running the SQL file
leetcode之爬楼梯方法数
New type of dark energy could solve Universe expansion mystery
Method of MySQL password expiration
数据可视化百度地图进一步优化
Thinkphp5 -- object (think \ response \ JSON) to array
Database programming of node
Promise(三)
ubuntu下搭建mysql环境 & 初识SQL
Kids and COVID: why young immune systems are still on top
TP5 使用redis
并发优化请求
China creates vast research infrastructure to support ambitious climate goals
offset和client獲取dom元素比特置信息
mysql密码过期的方法