本文共 1224 字,大约阅读时间需要 4 分钟。
#!/bin/bashfunction fdisk_fun(){ fdisk $1 < >/dev/null 2>&1 }a='v'echo -ne "\033[32m Please confirm machine ,if is not ali,enter N|n.otherwise:\033[0m"read CHOICEif [ $CHOICE == 'N' -o $CHOICE == 'n' ]then a='s'fiif [ -f ./test.txt ]then rm -rf ./test.txtelse touch ./test.txt fdisk -l |grep -o "^Disk /dev/$a[hd][a-z]" >>./test.txtfin=1for disk in `ls -al /dev|grep -o "$a[hd][a-z]"|uniq -c|gawk '{if( $1< 2) print $2}'`do value=`grep $disk ./test.txt|wc -l` if [ $value == 1 ] then echo -e "\033[32m/dev/$disk can fdisk well\033[0m" read -p "Are you sure?(Y|y or N|n):" choice if [ $choice == 'Y' -o $choice == 'y' ] then if [ -d /data$n ] then mkdir /data$n fdisk_fun /dev/$disk ; mount /dev/$disk'1' /data$n sed -i '$a /dev/'$disk'1 /data'$n' xfs defaults,noatime,nodiratime 0 0' /etc/fstab let n+=1 fi else echo -e "\033[31mExitting\033[0m" exit 1 fi else echo -e "\033[31m$disk isn't a disk\033[0m" fidone
转载于:https://blog.51cto.com/linuxbo/1869562