A bash script to part and format HDs in quantity
I need to test a JBOD box today with 45 harddrives , obviously I am not going to part and format these harddrive one by one , so I write a script.
What this script would do:
1.Using GPT to label/relabel the HD.
2.Parting the whole drive into one partition.
3.Formatting the partition into Xfs.
4.Mounting the partition into /mnt with the same name.
Since some drivers were finished before I run this script , so I use a list to specify which drives I need to operate.
#Used to initialize tons of disks
for disk in sdb sdc sdd sde
parted /dev/$disk <<ESXU
mkpart primary 4096s 100%
mkfs.xfs /dev/$disk$partnum -f
mount /dev/$disk$partnum /mnt/$disk$partnum
At the end , don't forget to edit the /etc/fstab , put in drives info accordingly , or the system won't mount them during booting.