Got a huge JBOD and you would like to RAID them?

It’s easy.
####First, figure out what Linux picked up the drives as.

fdisk -l > disks.txt
cat disks.txt | grep /dev | grep -v Disk

####Then i just copied that into notepad, removed all the “1s” and formatted like below.

####Create Array
mdadm –create –verbose /dev/md0 –level=6 –raid-devices=10 /dev/sd[cbeghdjlmf]

####Persist Array
mdadm –detail –scan >> /etc/mdadm.conf

or

mdadm –verbose –detail –scan >> /etc/mdadm.conf

####Check Details
mdadm –detail –brief /dev/md0
ARRAY /dev/md0 metadata=1.2 spares=4 name=SERVER.DOMAIN:0 UUID=bd220473:6d4c4ef4:bbc7eb74:ec9b7a0b

####Watch Build
watch -n 2 cat /proc/mdstat

####Conf file
/etc/mdadm.conf
DEVICE partitions
CREATE owner=root group=disk mode=0660 auto=yes
HOMEHOST SERVER.DOMAIN
MAILADDR someone@email.com

ARRAY /dev/md0 level=raid6 num-devices=56 metadata=1.2 spares=4 name=SERVER.DOMAIN:0 UUID=bd220473:6d4c4ef4:bbc7eb74:ec9b7a0b
devices=/dev/sdaa,/dev/sdab,/dev/sdac,/dev/sdad,/dev/sdae,/dev/sdaf,/dev/sdag,/dev/sdah,/dev/sdai,/dev/sdaj

####Create GPT label
parted /dev/md0 mklabel gpt

####Since our drives, and this array is more than 2TB, we have to use parted.
parted /dev/md0 mkpart primary xfs 0% 100%

####This makes a partition /dev/md0p1

####Install XFS.  xfsprogs and the mkfs.xfs utility automatically select the best stripe size and stripe ####width for underlying devices that support it, such as Linux software RAID devices.
yum install xfsprogs

####Format
mkfs.xfs /dev/md0p1

####Create mountpoint
mkdir /data

####Mount it
mount /dev/md0p1 /data

####Test it
touch /data/raid6_test.txt
ls -l /data/
echo “booyaa” > /data/raid6_test.txt
cat /data/raid6_test.txt

####Persist it
chattr -i /etc/fstab
nano /etc/fstab
/dev/md0p1    /data    xfs    defaults    0    0

chattr +i /etc/fstab

####Check mount
mount -av

####
[root@SERVER ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0p1            197T   39M  197T   1% /data

####If a disk fails, you have to fail it with mdadm and then remove it from the array.
mdadm /dev/md0 –fail /dev/sdcc1 –remove /dev/sdcc1

####To add disks, replacing the failed one.
mdadm –add /dev/md0 /dev/sdcc1

####To delete the array:

mdadm –stop /dev/md0

mdadm –remove /dev/md0

mdadm –zero-superblock /dev/sdc /dev/sdb /dev/sde /dev/sdg /dev/sdh /dev/sdd /dev/sdj /dev/sdl /dev/sdm /dev/sdf

Categories: Uncategorized

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *