Changes

Jump to navigation Jump to search
4,503 bytes added ,  19:32, 7 February 2019
Line 24: Line 24:  
sr0    1024M        rom  </nowiki>
 
sr0    1024M        rom  </nowiki>
   −
Disks order
+
blkid
  <nowiki>/dev/sdl <-- Up
+
  <nowiki>/dev/sdh: UUID="45dcb1c7-5dcd-8d8e-7830-0cdc8da5755c" UUID_SUB="c52532c2-fa0b-e5f2-9a71-166b20d63084" LABEL="Morpheus:0" TYPE="linux_raid_member"
/dev/sdk
+
/dev/sdj: UUID="45dcb1c7-5dcd-8d8e-7830-0cdc8da5755c" UUID_SUB="524b7cad-dd3d-cd84-2f4b-228f691fb660" LABEL="Morpheus:0" TYPE="linux_raid_member"
/dev/sdj
+
/dev/sdk: UUID="45dcb1c7-5dcd-8d8e-7830-0cdc8da5755c" UUID_SUB="f7105152-6eb2-3f7c-28a2-61f0f8c966d8" LABEL="Morpheus:0" TYPE="linux_raid_member"
/dev/sdi <-- Down</nowiki>
+
/dev/sdl: UUID="45dcb1c7-5dcd-8d8e-7830-0cdc8da5755c" UUID_SUB="a7dad691-d287-f1e2-17e2-76cbdd543b27" LABEL="Morpheus:0" TYPE="linux_raid_member"</nowiki>
 +
 
 +
mdadm -D /dev/md0
 +
 
 +
<nowiki>/dev/md0:
 +
          Version : 1.2
 +
    Creation Time : Mon Sep 10 20:22:45 2018
 +
        Raid Level : raid5
 +
    Used Dev Size : 18446744073709551615
 +
      Raid Devices : 4
 +
    Total Devices : 4
 +
      Persistence : Superblock is persistent
 +
 
 +
      Update Time : Fri Sep 21 03:16:52 2018
 +
            State : active, FAILED, Not Started
 +
    Active Devices : 3
 +
  Working Devices : 4
 +
    Failed Devices : 0
 +
    Spare Devices : 1
 +
 
 +
            Layout : left-symmetric
 +
        Chunk Size : 512K
 +
 
 +
Consistency Policy : unknown
 +
 
 +
              Name : Morpheus:0  (local to host Morpheus)
 +
              UUID : 45dcb1c7:5dcd8d8e:78300cdc:8da5755c
 +
            Events : 11291
 +
 
 +
    Number  Major  Minor  RaidDevice State
 +
      -      0        0        0      removed
 +
      -       0        0        1      removed
 +
      -      0        0        2      removed
 +
      -       0        0        3      removed
 +
 
 +
      -      8      176        0      sync  /dev/sdl
 +
      -      8      144        3      spare rebuilding  /dev/sdj
 +
      -      8      112        1      sync  /dev/sdh
 +
      -       8      160        2      sync  /dev/sdk
 +
</nowiki>
 
=== Create RAID 5 ===
 
=== Create RAID 5 ===
 
  sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=4 /dev/sdi /dev/sdj /dev/sdk /dev/sdl
 
  sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=4 /dev/sdi /dev/sdj /dev/sdk /dev/sdl
Line 42: Line 81:  
unused devices: <none>
 
unused devices: <none>
 
</nowiki>
 
</nowiki>
==== Create the filesystem ====
+
 
  sudo mkfs.ext4 -F /dev/md0
+
  <nowiki>rafa@Morpheus:~$ cat /proc/mdstat
==== Mount the filesystem ====
+
Personalities : [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid1] [raid10]
sudo mount /dev/md0 /mnt/md0
+
md0 : inactive sdk[2] sdj[4] sdh[1] sdl[0]
 +
      15627545950 blocks super 1.2
 +
     
 +
unused devices: <none>
 +
</nowiki>
    
=== Save the array layout ===
 
=== Save the array layout ===
Line 52: 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 ===
 +
sudo pvcreate /dev/md0
 +
sudo vgcreate lvm_group_name /dev/md0
 +
sudo lvcreate -L30G -nlogical_volume_group_name lvm_group_name
 +
sudo mkfs.ext4 /dev/lvm_group_name/logical_volume_group_name
 +
sudo echo '/dev/lvm_group_name/logical_volume_group_name /mnt/mountdir ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab
 +
 +
=== Using EXT4 ===
 +
===== Create the filesystem =====
 +
sudo mkfs.ext4 -F /dev/md0
 +
===== Mount the filesystem =====
 +
sudo mount /dev/md0 /mnt/md0
 +
 
Add mount option to fstab
 
Add mount option to fstab
 
  echo '/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab
 
  echo '/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab
   −
=== LVM and RAID Cheatsheet ===
+
=== TODO: Add a disk to RAID5 with LVM ===
 +
https://ubuntuforums.org/showthread.php?t=713936
 +
 
 +
 
 +
== 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 ==
 +
* Identify the failed drive with mdadm -D /dev/md0
 +
if=/dev/disk/by-id/scsi-drive-that-is-dying of=/dev/null
 +
* Remove the failed drive
 +
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/
 +
    control  lvm-music  lvm-transmission  lvm-video
 +
root@morpheus:~# dmsetup remove lvm-music
 +
root@morpheus:~# dmsetup remove lvm-transmission
 +
root@morpheus:~# dmsetup remove lvm-video
 +
root@morpheus:~# mdadm --stop /dev/md0
 +
    mdadm: stopped /dev/md0
 +
* Copy the partition table to the new disk
 +
https://www.howtoforge.com/tutorial/linux-raid-replace-failed-harddisk/
 +
 +
== Force manual resync ==
 +
sudo mdadm --stop /dev/md0
 +
sudo mdadm --assemble --run --force --update=resync /dev/md0 /dev/sdl /dev/sdh /dev/sdj /dev/sdk
 +
 +
== Check RAID status ==
 +
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 ==
 +
sudo mdadm --assemble --scan
 +
 +
== Send email alerts ==
 +
Edit /etc/mdadm.conf file:
 +
MAILADDR dustymabe@gmail.com
    
== References ==  
 
== References ==  

Navigation menu