1 #!/bin/bash 2 set -e 3 disk(){ 4 disk=`fdisk -l | grep 128 | awk '{print $2}' | tr -d :` #磁盘名 5 flag=`df -h | grep $disk ` #查看是否已经挂载 6 if [ -n $disk ] ;then 7 if [ -n $flag ];then 8 expect -c " 9 spawn fdisk $disk 10 expect { 11 "Command" { send "n " ; exp_continue } 12 "Select" { send "p " ; exp_continue } 13 "Partition" { send "1 " ; exp_continue } 14 "First" { send " " ; exp_continue } 15 "Last" { send " " ; exp_continue } 16 } 17 expect "Command" { send "w "} 18 expect eof 19 " 20 mkdir /data1 21 mkfs.ext4 $disk -N 5242880 22 mount $disk /data1/ 23 sed -i '9a '$disk' /data1 ext4 defaults 0 0' /etc/fstab 24 else 25 echo "$disk already mount~" 26 fi 27 fi 28 29 } 30 31 32 disk
阿里云扩展系统盘
https://help.aliyun.com/document_detail/111738.html?spm=a2c4g.11186623.2.22.54081035WYrMmt#concept-ocb-htw-dhb