#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbinexport PATH cp /etc/fstab /etc/fstab.bakif [ -n "$1" ];theni=1while [ $i -lt $1 ] domkdir /disk$ij=`echo $i|awk '{PRintf "%c",97+$i}'`parted /dev/vd$j <<EOFmklabel gptmkpart primary 0 -1ignorequitEOFecho "/n/n******/dev/vd${j} __was Fdisked! Waiting For 10 Second*****/n/n" sleep 1smkfs.ext4 /dev/vd${j}1if [ "$?" = "0" ];thenecho "/n/n*****sd${j}1 _________________was Formated, Waiting For.....****/n/n" filet i+=1sleep 1secho "/dev/vd${j}1 /disk$[$i +1] ext4 defaults 0 0" >>/etc/fstabdoneelseecho "parameter err,useage: please input server disk munber"fi2、使用fdisk工具脚本:#!/bin/bash #Used to fomat 6 disksPATH=/bin:/sbin:/usr/bin:/usr/sbinexport PATH i=1while [ $i -lt 4 ] doj=`echo $i|awk '{printf "%c",97+$i}'`fdisk /dev/sd$j <<EOFnp1wEOFecho "/n/n******/dev/sd${j} __was Fdisked! 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+=1sleep 1sdonetouch /test2mkdir /disk1mkdir /disk2mkdir /disk3cat << ESXU > /test2/dev/sdb1 /disk1 ext4 defaults 0 0/dev/sdc1 /disk2 ext4 defaults 0 0/dev/sdd1 /disk3 ext4 defaults 0 0ESXUcat /test2 >> /etc/fstabmount -achmod -R 777 /disk*
新闻热点
疑难解答