标签:last gre ash mkdir echo eof color efault 挂载磁盘
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 | wc -l` #查看是否已经挂载 6 if [ -n $disk ] ;then 7 if [ ! -n $flag ];then 8 expect -c " 9 spawn fdisk $disk 10 expect { 11 "Command" { send \"n\r\" ; exp_continue } 12 "Select" { send \"p\r\" ; exp_continue } 13 "Partition" { send \"1\r\" ; exp_continue } 14 "First" { send \"\r\" ; exp_continue } 15 "Last" { send \"\r\" ; exp_continue } 16 } 17 expect "Command" { send \"w\r\"} 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
标签:last gre ash mkdir echo eof color efault 挂载磁盘
原文地址:https://www.cnblogs.com/abkn/p/10299930.html