RAID | MDADM
Creating RAID and mounting it
Is [[Formatting - Drives]] needed? Do that first, then come back.
See if mdadm is installed or notmdadm
If not, install it
apt install mdadm
Check for all storage drives in systemlsblk
Create the RAID with the drive you are going to usemdadm --create /dev/md111((create your own file name)) --level=5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
Check to see if the array is in progresscat /proc/mdstat
Check the block ID for the new virtual drive/sblkid
Make a File System on that new drivemkfs.ext4 /dev/md111
(find your own disk location)
mkfs.ext4 - .ext4 means the "type" of file. shown on "sudo blkin" then state locate of the file its going to be
Create a location to mount the new virtual drive/s
"/" is a good place to start
Mount the RAID to the storage locationmount /dev/md111 /sirstorage
Check to see if the RAID is in the location you createddf -h
sudo mdadm --detail /dev/md111
<----Local RAID location
Add array to the fstab file | this will mount the array every time the computer starts up. You can do this with as many mounts/drives as you like. nano /etc/fstab
look at the headers and include this under the correct header
File system: `/dev/md111` mount point: `/storage/location` type: `ext4` options: `errors=remount-ro` put zeros on the rest.
Test to see if array mount workedumount /storage/location
mount -a
**Reboot!!**
Reboot the system, just in case. Make sure the array is still mounting after reboot. If its there, you are good to go son!
Need to extend your RAID? Go find that one. "Extending RAID"
Extending RAID
Prepare new disk
Need to partition? Do it now. I'll wait...
Setup: The current RAID has 4 drives and we want to add a 5th drive. The current array is "md111" and we have already checked drives on the system lsblk
to see which drive we will be adding "sdd1"
Add disk to RAIDmdadm --add /dev/md111 /dev/sdd1
mdadm --add /current/drive/array (array that already has the other raid dirves in it) /new/drive/to/add (the 1 drive that you will be adding)
Grow RAID:mdadm --grow --raid-devices=4 /dev/md111
This will grow your current array to accept a new drive
Now that you have expanded the underlying partition, you must now resize your filesystem to take advantage of it.
You may want to perform an fsck on the file system first to make sure there are no underlying issues before attempting to resize the file system
Integrity Check: e2fsck -f /dev/md111
Resize array: resize2fs /dev/md111
Mount it: mount /dev/md111 /your/new/local/location
Check RAID rebuild status or Current statuscat /proc/mdstat
Sources you can use:
https://raid.wiki.kernel.org/index.php/Growing
Troubleshooting RAID
Setup: Our current RAID array with 5 drives in it is "md111". Its location is /dev/md111
Resize the blocksresize2fs -f /dev/md111
Stop Arraymdadm --stop /dev/md111
Auto scan for arraysmdadm --assemble --scan
Once the new mdadm.conf was ready, execute "sudo update-initramfs -u" This updats the conf file used by initramfs.sudo update-initramfs -u