disk-mount.sh
yum install -y parted
sleep 1s
i=0
b=1
for dis in `fdisk -l | grep "/dev/sd*" | grep -v "sda" | awk '{if($2~/sd/) print substr($2,0,8)}'`
do
disk=$dis
echo $disk
parted $disk mklabel gpt
echo -e "n\\n1\\n\\n\\nw" |fdisk $disk
disk_part=$disk$b
mkfs.xfs -f $disk_part
sleep 1s
uuid=`blkid $disk_part | awk '{print $2}'|awk -F"\"" '{print $2}'`
#创建分区
mkdir -p /export/data/$i
#挂载
mount $disk_part /export/data/$i
#把uuid写入开机自动挂载
echo "UUID=${uuid} /export/data/$i xfs defaults 0 0" >> /etc/fstab
i=$(($i + 1))
done
echo ----测试fstab文件-----
mount -a
echo ----查看挂载情况------
lsblk
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45