下面是自己挂载脚本时写的脚本,不同环境不敢保证通用(在我这通用),请熟悉代码流程再使用!!!
#/bin/bash
item=(`lsblk |awk -F " " '$1!~/sda/{print $1}'|grep "sd"|grep -v sdb|xargs`)
num=01
dir=/srv/BigData/data
for var in ${item[@]}
do
parted -s /dev/${var} mklabel gpt
parted -s /dev/${var} mkpart logic 100M 100%
echo "y
"|mkfs.ext4 /dev/${var}
done
Blkid(`blkid /dev/sd* |awk -F [:" "] '$1!~/sda/{print $1}'|xargs`)
for var in ${Blkid[@]}
do
if [ ! -d "$dir$num" ];then
mkdir "${dir}${num}"
else
echo "the dir is exist"
fi
chmod 000 "${dir}${num}"
`partprobe`
uuid = `blkid $var`
echo UUID=${uuid:16:36} "${dir}${num}" ext4 default,noatime,nodiratime 1 0 >>/etc/fstab
let "num++"
done
mount -a
chown 2000:wheel "${dir}"*