This script is not a complete script, has not implemented automatic mount partition, each disk is divided into 2, 1 partition for the 1g,2 partition of 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)} '//Note/DEV/SDA is a system partition and cannot be formatted
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 "****************************************************************"
Shell programming: Automatically format the hard drive and mount it