Format Data Disk - solusi247/YAVA GitHub Wiki

List all available disk (non OS)

[root@yava00 ~]# parted -l | grep "\/dev\/sd"
Disk /dev/sda: 1000GB (OS)
Disk /dev/sdb: 1000GB
Disk /dev/sdc: 1000GB
Disk /dev/sdd: 1000GB

Create format script:

[root@yava00 ~]# cat format-disk.sh
#!/usr/bin/env bash
i=0
for DISK in b c d; do
    i=$((i + 1))
    j=$(printf "%02d" $i )
    echo "===== $DISK $j ========="
    # create 1 partition each disk
    parted -s /dev/sd${DISK} mklabel gpt
    parted -s /dev/sd${DISK} mkpart primary 1 100%
    # Format partition
    mkfs.ext4 -L u${j} -m 0 /dev/sd${DISK}1
    # Create mount point
    mkdir /u${j}
    echo "LABEL=u${j}   /u${j}  ext4    defaults,noatime,nodiratime     0       0" >> /etc/fstab
done

mount -a

Copy to all node and execute.