linux批量新增自动分区挂载大于2T磁盘脚本
#!/bin/bash
#Used to fomat 11 datas
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
i=1
while [ $i -lt 11 ]
do
j=`echo $i|awk ‘{printf “%c”,97+$i}’`
parted /dev/sd$j <
mkpart primary 0 -1
ignore
quit
ESXU
echo “/n/n******/dev/sd${j} __was Fdataed! Waiting For 10 Second*****/n/n”
sleep 1s
mkfs.ext4 /dev/sd${j}1
if [ “$?” = “0” ];then
echo “/n/n*****sd${j}1 _________________was Formated, Waiting For 5 Second****/n/n”
fi
let i+=1
sleep 1s
done
touch /test2
mkdir /data1
mkdir /data2
mkdir /data3
mkdir /data4
mkdir /data5
mkdir /data6
mkdir /data7
mkdir /data8
mkdir /data9
mkdir /data10
cat << ESXU > /test2
/dev/sdb1 /data1 ext4 defaults 0 0
/dev/sdc1 /data2 ext4 defaults 0 0
/dev/sdd1 /data3 ext4 defaults 0 0
/dev/sde1 /data4 ext4 defaults 0 0
/dev/sdf1 /data5 ext4 defaults 0 0
/dev/sdg1 /data6 ext4 defaults 0 0
/dev/sdh1 /data7 ext4 defaults 0 0
/dev/sdi1 /data8 ext4 defaults 0 0
/dev/sdj1 /data9 ext4 defaults 0 0
/dev/sdk1 /data10 ext4 defaults 0 0
ESXU
cat /test2 >> /etc/fstab
mount -a
chmod -R 777 /data*
rm -rf /test2