一、通过管理员选择创建、格式化、挂载新添加的磁盘脚本

#! /bin/bash
echo "=============================="
PS3="chose which disk you want to create:"
select W in `ls /dev/sd*|grep -o 'sd[b-z]'|uniq` quit
do
 case $W in
 sda)
 fdisk -l /dev/sda
 break;;
 sd[b-z])
 echo "n
  p

  w" | fdisk /dev/$W
 mkfs.xfs -i size=512 /dev/${W}"1" &>/dev/null
 mkdir -p /data/${W}"1" &>/dev/null
 echo -e "/dev/${W}"1" /data/${W}"1" xfs defaults 0 0\n"  /etc/fstab
 mount -a &>/dev/null
 break;;
 quit)
 break;;
 *)
 echo "wrong disk,plwase chesk again";;
 esac
done

二、自动创建、格式化、挂载新添加的磁盘脚本

#!/bin/bash
for V in $(ls /dev/sd[b-z])
do
 echo -e "n\np\n\n\n\nw\n" |fdisk $V
 mkfs.xfs -i size=512 ${V}1 &>/dev/null
 sleep 1
 M=$(echo "$V" |awk -F "/" '{print $3}')
 mkdir -p /data/${M}1 &>/dev/null
 echo -e "${V}1 /data/${M}1 xfs defaults 0 0\n" /etc/fstab
 mount -a &>/dev/null
done
标签:
shell脚本挂载新添加的磁盘,shell脚本格式化新添加的磁盘

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
白云城资源网 Copyright www.dyhadc.com