#!/bin/bash
format_disk(){
arr_disk=(`fdisk -l|awk -F"[ :]" '{print $2}'|grep "sd[b-z]"|sort`)
i=2
for disk in ${arr_disk[*]}
do
echo Create ${disk},please wait.....
fdisk ${disk} <<EOF
n
p
1
w
q
EOF
echo Format ${disk}1,please wait .....
echo y|mkfs.ext4 ${disk}1 >/dev/null && echo format ${disk}1 successful!
bname=`basename ${disk}`
mdir=\/data${i}
mkdir $mdir && mount ${disk}1 $mdir
echo ${disk}1 $mdir ext4 defaults 0 0 >>/etc/fstab
i=`expr $i + 1`
done
}
format_disk
本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1227664