5、磁盘划分
更新于:2024年3月25日
磁盘划分脚本
https://onedayxyy.cn/scripts/disk_parted/disk_fdisk-2024.1.1.sh
disk_fdisk-2024.1.1.sh
#!/bin/bash
k=0
for i in {1..8}
do
j=`echo $i|awk '{printf "%c",97+$i}'`
ID=`blkid /dev/sd$j | cut -b 11-54`
fdisk /dev/sd$j <<EOF
n
p
1
w
EOF
sleep 2
mkfs.xfs -f /dev/sd${j}1
mkdir /data$i
sleep 4
ID=`blkid /dev/sd${j}1 | cut -b 11-54`
let k++
if [ $k -lt 10 ];then
v_mount="$ID /data$k xfs defaults 0 0"
else
v_mount="$ID /data$k xfs defaults 0 0"
fi
echo $v_mount >> /etc/fstab
done
mount -a
https://onedayxyy.cn/scripts/disk_parted/disk_parted-2024.1.1.sh
disk_parted-2024.1.1.sh
#!/bin/bash
k=0
for i in {1..8}
do
j=`echo $i|awk '{printf "%c",97+$i}'`
ID=`blkid /dev/sd$j | cut -b 11-54`
parted -s /dev/sd$j "mkpart primary 0 -1"
parted /dev/sd$j <<EOF
mklabel gpt
mkpart primary 0 -1
ignore
print
quit
EOF
sleep 2
mkfs.xfs -f /dev/sd${j}1
mkdir /data$i
sleep 4
ID=`blkid /dev/sd${j}1 | cut -b 11-54`
let k++
if [ $k -lt 10 ];then
v_mount="$ID /data$k xfs defaults 0 0"
else
v_mount="$ID /data$k xfs defaults 0 0"
fi
echo $v_mount >> /etc/fstab
done
mount -a