Monday, May 13, 2013

scripting mdadm raid creation starting from a bare disk

I learned today that you can drive fdisk by just using echo. echo commands with no arguments serve as '/n' so you can take the defaults for starting and ending cylinder etc. Using fd "Linux raid auto" for the partition type.
for disk in $(ls /dev/disk/by-path/pci-0000:03:00.0-sas*lun-0);
do
  echo "zeroing $disk"
  dd if=/dev/zero of=$disk bs=1M count=10
  sync

  echo "creating RAID paritions on SAS disks"
  (echo n; echo p; echo 1; echo ; echo; echo t; echo fd; echo w) | fdisk $disk

  echo "verifying..."
  (echo p; echo q) | fdisk $disk
done
This is just a sample of the script found here:

https://github.com/ppetraki/storage-tools/blob/master/create-mdraid-from-scratch.sh

Which will take your disks from bare block devices all the way to running md and create the config.

No comments:

Post a Comment