Changes

Jump to navigation Jump to search
1,355 bytes added ,  19:32, 7 February 2019
Line 95: Line 95:  
Enable the array at boot time
 
Enable the array at boot time
 
  sudo update-initramfs -u
 
  sudo update-initramfs -u
 
+
== Create Filesystem ==
 
=== Using LVM ===
 
=== Using LVM ===
 
  sudo pvcreate /dev/md0
 
  sudo pvcreate /dev/md0
Line 116: Line 116:       −
=== LVM and RAID Cheatsheet ===
+
== LVM and RAID Cheatsheet ==
 
https://gist.github.com/plepe/52ecc9f18efb32c68d18
 
https://gist.github.com/plepe/52ecc9f18efb32c68d18
 +
== Add HOT SPARE drive ==
 +
mdadm --add /dev/md0 /dev/sdh1
 +
hdparm -S 180 /dev/[sh]d[a-z]  # makes disks to stop spining after 15 mins of inactivity
 +
Add this command to the end of the file /etc/rc.d/rc.local to ensure that it is executed every time the system is booted:
 +
 +
<source lang=bash>#!/bin/sh
 +
#
 +
# This script will be executed *after* all the other init scripts.
 +
# You can put your own initialization stuff in here if you don't
 +
# want to do the full Sys V style init stuff.
 +
 +
touch /var/lock/subsys/local
 +
hdparm -S 180 /dev/[sh]d[a-z]</source>
 +
 
== Replace Failed Drive ==
 
== Replace Failed Drive ==
 
* Identify the failed drive with mdadm -D /dev/md0
 
* Identify the failed drive with mdadm -D /dev/md0
Line 123: Line 137:  
* Remove the failed drive
 
* Remove the failed drive
 
  mdadm /dev/md0 --remove /dev/sda
 
  mdadm /dev/md0 --remove /dev/sda
 +
* Add it again
 +
mdadm --manage /dev/mdN -a /dev/sdd1
 +
If a RAID is operated with a spare disk, it will jump in for the disk set to faulty. A rebuild is performed automatically. The disk set to faulty appears in the output of mdadm -D /dev/mdN as faulty spare.
 +
 +
To put it back into the array as a spare disk, it must first be removed using
 +
mdadm --manage /dev/mdN -r /dev/sdX1
 +
and then added again
 +
mdadm --manage /dev/mdN -a /dev/sdd1
 +
 
  root@morpheus:~# ls /dev/mapper/
 
  root@morpheus:~# ls /dev/mapper/
 
     control  lvm-music  lvm-transmission  lvm-video
 
     control  lvm-music  lvm-transmission  lvm-video
Line 130: Line 153:  
  root@morpheus:~# mdadm --stop /dev/md0
 
  root@morpheus:~# mdadm --stop /dev/md0
 
     mdadm: stopped /dev/md0
 
     mdadm: stopped /dev/md0
 +
* Copy the partition table to the new disk
 +
https://www.howtoforge.com/tutorial/linux-raid-replace-failed-harddisk/
   −
== Rebuild Array ==
+
== Force manual resync ==
 
  sudo mdadm --stop /dev/md0
 
  sudo mdadm --stop /dev/md0
 
  sudo mdadm --assemble --run --force --update=resync /dev/md0 /dev/sdl /dev/sdh /dev/sdj /dev/sdk
 
  sudo mdadm --assemble --run --force --update=resync /dev/md0 /dev/sdl /dev/sdh /dev/sdj /dev/sdk
Line 138: Line 163:  
  mdadm -D /dev/md0
 
  mdadm -D /dev/md0
    +
== Simulate disk failure ==
 +
sudo mdadm /dev/md0 --fail /dev/sdXX
 +
sudo mdadm /dev/md0 --remove /dev/sdXX
 +
sudo mdadm /dev/md0 --add /dev/sdXX
 
== Recover ARRAY ==
 
== Recover ARRAY ==
 
  sudo mdadm --assemble --scan
 
  sudo mdadm --assemble --scan
 +
 +
== Send email alerts ==
 +
Edit /etc/mdadm.conf file:
 +
MAILADDR dustymabe@gmail.com
    
== References ==  
 
== References ==  

Navigation menu