Redhat操作系统磁盘挂载
yum -y install bc
2.执行命令查看每个节点未挂载的磁盘清单DEVICE_LIST
fdisk -l
3.修改脚本1中的DEVICE_LIST
#!/bin/sh #请按照实际硬件填写DEVICE_LIST DEVICE_LIST="/dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh" for DEVICE in $DEVICE_LIST do echo "*** create partition for $DEVICE ***" parted -s $DEVICE mklabel gpt mkpart gpt2t xfs 0% 100% PARTITION="$DEVICE""1" echo "*** formatting $PARTITION ***" mkfs.xfs -f $PARTITION done
4.修改脚本2中的PARTITION_LIST
#!/bin/sh #备份/etc/fstab cp /etc/fstab /etc/fstab.bak #请按照实际硬件填写PARTITION_LIST PARTITION_LIST="sdb1 sdc1 sdd1 sde1 sdf1 sdg1 sdh1" index=0 for PARTITION in $PARTITION_LIST do UUID=`blkid "/dev/""$PARTITION" | awk '{print $2}' | sed 's/\"//g'` echo "*** UUID $UUID ***" echo "*** add $PARTITION to /etc/fstab ***" index=`echo $index+1|bc` MOUNTDIR="/srv/bigdata/disk"$index echo "mkdir -p $MOUNTDIR" mkdir -p $MOUNTDIR echo "*** appending \"$UUID $MOUNTDIR xfs defaults 0 0\" to /etc/fstab ***" echo "$UUID $MOUNTDIR xfs defaults 0 0" >> /etc/fstab echo "" done #mount all partition mount -a #show mounted partitions df -h
5.执行脚本1,然后执行脚本2(每个节点)