Linux RAID Array: Difference between revisions
DrEdWilliams (talk | contribs) (Created page with "== Creating a new RAID array == If it isn't already installed, load the mdadm package: yum -y install mdadm Get the list of disks in the system and identify the ones that yo...") |
(No difference)
|
Latest revision as of 01:40, 3 August 2019
Creating a new RAID array[edit]
If it isn't already installed, load the mdadm package:
yum -y install mdadm
Get the list of disks in the system and identify the ones that you want to include:
fdisk -l | grep GB
Identify if any arrays are already in place:
cat /proc/mdstat
Create the array -- generally, <mdevice> will start with /dev/md0
mdadm --create <mdevice> --chunk=64K --level=5 --raid-devices=<count> <list of drive devices>
If you get I/O errors, try chunk sizes in powers of 2 starting at 4K -- larger is better, but exactly divides the available space (i.e. you may waste space on each device that is less than a chunk). The errors may not come when creating the array; creating the filesystem is where the errors could occur.
mdadm --create <mdevice> --chunk=<chunksize> --level=5 --raid-devices=<count> <list of drive devices>
Check the status of the array:
cat /proc/mdstat
If you'll be mounting it directly, then create a filesystem on it:
mkfs -t xfs <mdevice>
Replacing a failing disk[edit]
Identify the disks involved:
- /dev/sdY - new disk (or partition /dev/sdY1)
- /dev/sdX - old failing disk
If replacing with a partition of a disk
mdadm /dev/mdN --add /dev/sdY1 --replace /dev/sdX --with /dev/sdY1
If replacing with a whole disk
mdadm /dev/mdN --add /dev/sdY1 --replace /dev/sdX --with /dev/sdY
Removing an MDADM Raid Array[edit]
Find out your arrays (md0, md1, etc..) using
sudo fdisk -l
Query your arrays to find out what disks are contained using
sudo mdadm --detail /dev/md0
... using the appropriate /dev/md* device ...
Unmount the array first, otherwise it fails with "device is busy".
sudo umount /dev/md0
Shut down the array using
sudo mdadm --stop /dev/md0
And here's the magic key: zero the superblock FOR EACH drive so it doesn't try to rebuild the array
sudo mdadm --zero-superblock /dev/sdX
Repeat for each drive in the array ...