此脚本为不完全脚本,还未实现开机自动挂载分区,每个磁盘分为2个去,1分区为1G,2分区为2G。
#!/bin/bash
count=`fdisk -l|grep /dev/sd.*|grep -v '/dev/sda.*'|wc -l`
i=1
while [ $i -le $count ]
do
j=`echo $i|awk 'BEGIN{printf("%c\n",98+$i)}'` //注意/dev/sda是系统分区,不能格式化
fdisk /dev/sd$j <<FORMAT
n
p
1
+1G
n
p
2
+2G
w
wait
FORMAT
mkfs.ext3 "/dev/sd"$j"1"
mkfs.ext3 "/dev/sd"$j"2"
sleep 2
echo "****************************************************************"
echo "/dev/sd$j fomate is done"
echo "****************************************************************"
aaa=`echo "/sd$j"`1
bbb=`echo "/sd$j"`2
mkdir $aaa
mkdir $bbb
mount /dev/$aaa $aaa
mount /dev/$bbb $bbb
i=$[$i+1]
done
sleep 2
echo "****************************************************************"
fdisk -l |grep "/dev/sd.*"|grep -v "/dev/sda.*"
echo "****************************************************************"
df -h
echo "****************************************************************"