linux 批量硬盘格式化分区并挂载

#!/bin/bash

mkdir /data{1..6}
disks=("/dev/sdb" "/dev/sdc" "/dev/sdd" "/dev/sde" "/dev/sdf" "/dev/sdg")

for i in "${!disks[@]}";do
    disk="${disks[$i]}"
    echo "yes"|parted -m -s $disk mklabel "gpt"
    parted -m -s $disk mkpart primary 0% 100%
    partprobe "$disk"
    partition="${disk}1"
    mkfs.xfs "$partition"
    mount_point="/data$((i+1))"
    mount "$partition" "$mount_point"
done

发表评论

评论列表,共 0 条评论

    暂无评论