linux 硬盘分区与挂载
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 硬盘分区与挂载相关的知识,希望对你有一定的参考价值。
#!/bin/bash function fdisk_fun() { fdisk $1 <<EOF n p 1 2048 w EOF mkfs.xfs $11 >>/dev/null 2>&1 } a=‘v‘ echo -ne "\033[32m Please confirm machine ,if is not ali,enter N|n.otherwise:\033[0m" read CHOICE if [ $CHOICE == ‘N‘ -o $CHOICE == ‘n‘ ] then a=‘s‘ fi if [ -f ./test.txt ] then rm -rf ./test.txt else touch ./test.txt fdisk -l |grep -o "^Disk /dev/$a[hd][a-z]" >>./test.txt fi n=1 for 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" fi done
本文出自 “黎明前的黑暗” 博客,谢绝转载!
以上是关于linux 硬盘分区与挂载的主要内容,如果未能解决你的问题,请参考以下文章