Tags Archives: RAID

Einführung in das Thema RAID (auf Deutsch)

 

Das Thema dieser Presentation heißt RAID

 

 

Das Thema RAID – Überblick

 

Das Akronym RAID steht für „Redundant Array of Inexpensive Disks“ (zu Deutsch: redundantes Array günstiger Festplatten).

 

RAID ist also eine Storage oder Plattenspeichersystem bestehend aus einen Satz von mehreren Festplatten, die zusammen eine große Plattenspeichereinheit bilden.

 

Welche Punkte werde ich hier besprechen?

 

Ein Überblick und kurze Einführung geben in das Thema RAID

 

 

Die Fragen beantworten:

 

– Wozu nützt man ein RAID-system?

 

– Was sind die verschiedenen RAID-systeme, ein Überblick über ihre Eigenschaften

 

– Welches RAID-system sollte man verwenden – für welchen Zweck im Einsatz, also was will man damit erreichen?

 

 

Also, zuerst….

 

Was ist RAID?

 

 

RAID ist eine Möglichkeit, einzelne physische Laufwerke zu einem grösseren Plattenverbund zusammenzubauen.

 

Ein RAID-Set stellt alle physischen Laufwerke als eine logische Festplatte auf einem Server dar.

 

Die logische Festplatte wird als Logical Unit Number (LUN) bezeichnet.

 

Aus Sicht des Benutzers oder eines Anwendungsprogramms unterscheidet sich ein RAID-System nicht von einem einzelnen Speichermedium.

 

Bei einem RAID geht hier nicht um Speicherkapazitätserweiterung, sondern

 

Man will hier zwei Dingen erreichen:

 

erhöhtes Performanz – bei Datentransfer, Schreib-/Lesegeschwindigkeiten und Ausfallsichereit  

 

und

 

die Chancen von Datenverlust vermeiden bzw möglichst verringen.

 

 

Vorteile und Nachteile von RAID

Fileserver ohne RAID – sehr hohes Risiko von Dienst- und Datenverlust bei technischer Störung.

 

VORTEILE

 

Zu den Vorteilen von RAID gehören:

 

  • Man hat im Prinzip kein SPOF Single Point of Failure

 

 

Also, es geht um zwei verschiedende Sachen:

 

Performanz bzw. Leistung: schnelles schreiben bzw lesen. 

 

Vermeiden von Datenverlust bei Plattenausfall

 

Ausfallsicherheit – gibt es physikalische Plattentechnische Fehler, also zuverlässigkeit, ununterbrochenes Betrieb..

 

dabei können gespeicherte Datenmengen besser geschützt werden..

 

Erweitern des Plattenspeichervolumens ist auch mit einem RAID möglich.

 

 

NACHTEILE

 

Das Verkleinern eines bestehenden RAID-Systems ist in der Regel nicht möglich.

 

  • obwohl in der Prazis ist dies nicht so entscheidend, denn Plattenspeicherbedarf wächst eher ununterbrochen in den meisten Fällen.

 

Neue Erweiterungsplatten und auch Ersatzplatten beim Plattenausfall sollten eher von gleicher Grüße bzw technische Spezifikationen sein, sonst kann das Einbau in der Praxis problematisch sein!

 

 

Datenrettung nach Plattenausfahl und -ersatz kann manchmal langwierig und komplizert werden: Rebuid des RAIDs kann mehrere Stunden oder sogar noch Tagen dauern.

 

Hierum hängt es auch zT davon ab was für ein RAID-System, sprich “RAID Level” man verwendet.

 

 

an dieser Stelle wichtig zu merken …

 

  • RAID ist kein BACKUP! Ganz wichtig zu verstehen. Backupsysteme für Anwenderdaten und Systemdaten sind nach wie vor erforderlich, aber das ist ein ganz anderes zusätzliches Thema für sich.

 

  • RAID ist kein Logical Volume System – das kann man ggbfs zusätzlich installieren – aber, ist ein anderes Thema für sich, was wir hier nicht besprechen können.

 

 

RAID-Implementierungen: Software und Hardware

 

Also es gibt zwei grundsätzliche RAID-Implementationen:

 

auf Software- und auf Hardware-basis. 

 

Software-RAID

 

Von Software-RAID spricht man, wenn die RAID Steuerung komplett softwareseitig oder Betriebsystemmässig implementiert ist.

 

Auch der Begriff “Host-based RAID” wird manchmal genannt, da nicht das Speicher-Subsystem, sondern der eigentliche Computer die RAID-Verwaltung durchführt.

 

Die einzelnen Festplatten sind in diesem Fall meist über einfache Festplattencontroller am Computer angeschlossen

oder es werden externe Storage-Geräte wie Disk-Arrays von Unternehmen wie EMC, Promise, AXUS, Proware oder Hitachi Data Systems (HDS) an den Computer angeschlossen, zb über USB Port.

 

Vorteile von Software-RAID:

 

  • kein spezieller RAID-Controller oder Hardware benötigt wird. Die Steuerung wird von der RAID-Software erledigt – entweder als Teil des Betriebssystems oder als Zusatzsoftwaremodul installiert.
  • – Relativ einfach zu implementieren

 

 

Nachteile von SW-RAID

 

  • erhöhte Auslastung des CPUs und Systembus als bei einem Hardware-RAID. 
  • Meist kein Datencache dabei.
  • System ist von dem einzigen Computer – PC/Server abhängig… muss gebootet werden, techn probleme – wird das RAID auch davon betroffen.

 

 

Hardware-RAID

 

die dazugehörende Festplatten und die RAID-Controller Elektronik sind in einer eigens dafür gebauten Hardwareeinheit eingebaut.

 

Besonders im Rechenzentrumsumfeld befindet er sich häufiger in einem eigenen Gehäuse, einem Disk-Array, in dem auch die Festplatten untergebracht sind.

 

Professionelle Enterprise-Ebene Hardware-RAID-Implementierungen verfügen über eigene eingebettete CPUs; sie nutzen große, zusätzliche Cache-Speicher und bieten somit höchsten Datendurchsatz und entlasten dabei gleichzeitig den Hauptprozessor und haben ihre eigenen LAN- oder Hochperformanz SAN-Netz kabelanschluss Interfaces.

 

Wichtiger Bestandteil von eine SAN or Storage Area Network ist ein RAID-basiertes Plattenspeichersystem.

 

SANs bilden einer hochgeschwindigkeitsnetzwerk für sich, meist mit glassfaser oder FiberChannel oder andere Kabelverbindungen manchmal direkt an Servern oder an Routern mit dem LAN-Ethernet/Fast-Ethernet verbunden.

In der Regel gibt es auch redundante Netzverbindungen um vor Kabelstörungen oder Netzinterface Schnittstellen problemen zu beugen.

 

 

Einfachere Hardware-RAID Variante:

 

Durch eine durchdachte Handhabung und einen soliden Herstellersupport wird gerade auch bei Störungen eine bestmögliche Unterstützung des Systemadministrators erreicht. Einfache Hardware-RAID-Implementierungen bieten diese Vorteile nicht in gleichem Maße und stehen daher in direkter Konkurrenz zu Software-RAID-Systemen.

 

Dabei gibt es auch ganz einfache SCSI host adapters… für einfache systeme, oft desktops oder für einfaches Serverbetrieb im ganz kleinen Unternehmen. Adaptec SCSI-Hostadapters, im Server eingebaut.

 

Im unteren Preissegment (praktisch ausschließlich für IDE/ATA- oder SATA-Festplatten) werden sogenannte Host-RAID-Implementierungen angeboten.

Rein äußerlich ähneln diese Lösungen den Hardware-RAID-Implementierungen.

 

Meistens sind diese Implementierungen aber nur auf unteren levels von RAID (RAID 0 und RAID 1 beschränkt.

 

Beispiele von HW-RAID Systemen sind: Cisco, HP/HPE Hewlett-Packard, NetApp, Dell und IBM, unter anderem.

 

übrigens funktioneren RAIDs mit konventionellen manuellen festplatten sowie mit SSD solid state platten – allerdings sind die SSDs zur Zeit noch relativ kostenaufwendig für große Datenmengen.

 

 

 
RAID Levels  

 

RAID-Levels bestimmen, wie die Daten für die Platten gespeichert werden.

 

um für Datenschutz bei Plattenversagen zu sorgen. das bestimmt:

  • wie viele Platten gleichzeitig ausfallen dürfen, und 
  • wie viel Plattenspeicherkapazätit zur Verfügung steht

 

 

Um RAID und seine Vorteile vollständig zu verstehen, ist es wichtig, die verschiedenen RAID-Levels zu verstehen

RAID 0: Festplatten-Striping
RAID 1: Festplattenspiegelung (mirroring)
RAID 1+0: Festplattenspiegelung und Striping (manchmal RAID 10 genannt)

RAID 2: Striping und Hamming-Code-Parität
RAID 3: Paritätsfestplatte
RAID 4: Paritätsfestplatte und Block-Level-Striping

RAID 5: Festplatten-Striping mit Parität

RAID 5+0: Festplatten-Striping und verteilte Parität

RAID 6: Festplatten-Striping mit doppelter Parität
Adaptives RAID: Option zur Verwendung von RAID 3 oder RAID 5
RAID 7: Nicht-Standard mit Caching

 

Verschachteltes RAID bezieht sich auf Kombinationen von RAID-Leveln, wie RAID 10 (RAID 1+0) und RAID 50 (RAID 5+0).

 

RAID-Level können in drei Kategorien unterteilt werden: Standard, Nicht-Standard und verschachtelt (nested).

 

Standard-RAID-Level bestehen aus den grundlegenden RAID-Typen mit den Nummern 0 bis 6.

 

Ein Nicht-Standard-RAID-Level ist auf die Standards eines bestimmten Unternehmens oder Open-Source-Projekts festgelegt. Nicht-Standard-RAID umfasst RAID 7, adaptives RAID, RAID S und Linux md RAID 10.

Verschachteltes RAID bezieht sich auf Kombinationen von RAID-Leveln, wie RAID 10 (RAID 1+0) und RAID 50 (RAID 5+0).

 

 

Welches RAID-Level Sie verwenden, sollte von der Art der Anwendung abhängen, die Sie auf Ihrem Server ausführen.

 

RAID 0 ist am schnellsten,

RAID 1 ist am zuverlässigsten

RAID 5 ist eine gute Kombination aus beidem.

 

Welches RAID für Ihr Unternehmen am besten geeignet ist hängt von der:

 

  • gewünschten Datenredundanz,
  • der Länge des Aufbewahrungszeitraums,
  • der Anzahl der Festplatten,

 

was Ihnen wichtiger ist: Datensicherung gegenüber der Leistungsoptimierung

 

 

RAID 0: Festplatten-Striping

 

Alle Daten werden in Chunks auf alle SSDs oder HDDs verteilt.

 

RAID 0 bietet eine hohe Leistung,

 

RAID 0 verwendet keine Festplattenparität verfügt also nicht über Datenredundanz oder Fehlertoleranz.

 

Im Grunde genommen ist RAID 0 im Endeffekt wie eine grössere Festplatte – aber es besteht hier als mehr als nur 1 Platte, das bedeutet erhöhtes Ausfahllrisiko.

 

Vorteile:

 

Man gewinnt mehr Plattenspeicher, aber mit erhöhtes Ausfallrisiko. Hier geht es um Leistung und Speicherplatz.

RAID 0 ist einfach zu implementieren

niedrigsten Kosten aller RAID-Typen,

 

Nachteile:

 

RAID 0 hat den schlechtesten Datenschutz von allen RAID-Leveln. Da RAID 0 keine Parität hat, sind beim Ausfall einer Festplatte die Daten auf dieser Festplatte nicht verfügbar, bis sie von einer anderen Festplatte neu geschrieben werden können.

 

Geeignet für: Das Fehlen von Redundanz bedeutet, dass RAID 0 zur Datenspeicherung für nicht unternehmenskritische Anwendungen verwendet werden sollte.

 

Es ist gut geeignet für Anwendungen wo Daten mit hoher Geschwindigkeit gelesen und geschrieben werden sollen.

 

 

RAID 1: Festplattenspiegelung – Disk Mirroring

 

RAID 1 verwendet Festplattenspiegelung, dh alle Daten auf zwei separate physische Festplatten geschrieben werden.

 

Die Festplatten sind im Wesentlichen Spiegelbilder voneinander. Wenn eine einzelne Festplatte ausfällt, können die Daten von der anderen Festplatte wiederhergestellt werden. RAID 1 erfordert mindestens zwei Festplattenlaufwerke.

 

 

Vorteile: Die Spiegelung von Festplatten ist gut für schnelle Lesevorgänge. RAID 1 ist auch für Disaster-Recovery-Situationen nützlich, da es ein sofortiges Failover bietet. Wenn das primäre Laufwerk nicht mehr funktioniert, kann das sekundäre, gespiegelte Laufwerk übernehmen, da die Daten, das Betriebssystem und die Anwendungssoftware dort repliziert sind.

 

 

Nachteile: Die Schreibgeschwindigkeiten sind langsamer, da die Daten zweimal auf die Festplatten geschrieben werden müssen. Ein weiterer Nachteil von RAID 1 ist, dass sich der benötigte Speicherplatz verdoppelt, da alle Daten zweifach gespeichert werden.

 

 

Geeignet für: RAID 1 eignet sich gut für Hochleistungs- und Hochverfügbarkeitsanwendungen, einschließlich E-Mail, Betriebssysteme und Transaktionsanwendungen. Seine Failover-Fähigkeit macht es zu einer guten Wahl für unternehmenskritische Anwendungen.

 

 

RAID 1+0: Plattenspiegelung und Striping

 

RAID 1+0, das auch als RAID 10 bezeichnet wird, ist ein verschachtelter RAID-Level, der Festplattenspiegelung und Striping kombiniert.

Die Daten werden normalerweise zuerst gespiegelt und dann gestriped. Die Spiegelung von Striped-Sets erfüllt die gleiche Aufgabe, ist aber weniger fehlertolerant als Striping-Spiegelsets. RAID 1+0 erfordert mindestens vier physische Festplatten.

 

Vorteile: RAID 10 profitiert von den Leistungsmöglichkeiten, die durch die Verwendung von RAID 0 bereitgestellt werden.

 

Die Daten werden auf zwei oder mehr Laufwerke verteilt, und mehrere Lese-/Schreibköpfe auf den Laufwerken können gleichzeitig auf Teile der Daten zugreifen, was zu einer schnelleren Verarbeitung führt.

 

Da es RAID 1 verwendet, sind die Daten von RAID 10 vollständig geschützt. Wenn das ursprüngliche Laufwerk ausfällt oder nicht verfügbar ist, kann die Spiegelkopie die Daten übernehmen.

 

 

Nachteile: Wenn Sie ein Laufwerk in einem Stripe-Set verlieren, müssen Sie auf Daten aus dem anderen Stripe-Set zugreifen, da Stripe-Sets keine Parität haben.

 

Bei der Verwendung von RAID 1 werden die Daten bei RAID 10 vollständig dupliziert, wodurch sich die erforderliche Speicherkapazität verdoppelt. Da mindestens vier Festplatten erforderlich sind, ist RAID 10 teurer als andere RAID-Level.

 

Geeignet für: Die Redundanz und hohe Leistung von RAID 10 machen es zu einer guten Wahl für Vorgänge, die minimale Ausfallzeiten erfordern. Es ist auch optimal für E/A-intensive Anwendungen, wie E-Mail, Webserver, Datenbanken und Anwendungen, die eine hohe Festplattenleistung benötigen.

 

 

RAID 2: Striping und Hamming-Code-Parität

 

 

RAID 2 striped Daten auf Bit-Ebene und verwendet den Hamming-Code, um Parität zu bieten und Fehler zu erkennen. Die Parität liefert eine Prüfsumme über die auf die Festplatten geschriebenen Daten. Die Paritätsinformationen werden zusammen mit den Originaldaten geschrieben.

 

Der Server, der auf die Daten eines hardwarebasierten RAID-Sets zugreift, weiß nie, wenn eines der Laufwerke im RAID-Set defekt ist. Wenn das passiert, verwendet der Controller die Paritätsinformationen, die auf den weiterhin funktionierenden Festplatten im RAID-Satz gespeichert sind, um die verlorenen Daten wiederherzustellen.

 

 

Vorteile: Ein wesentlicher Vorteil von RAID 2 ist die Datensicherheit. Die durch den Hamming-Code bereitgestellte Parität sorgt für Datenredundanz und Fehlertoleranz.

 

Nachteile: RAID 2 ist komplexer als andere RAID-Level. Es ist auch kostspieliger als einige andere Level, da es ein zusätzliches Laufwerk erfordert.

 

 

Geeignet für: Heutzutage werden Hamming-Codes bereits in den Error Correction Codes von Festplatten verwendet, sodass RAID 2 nicht mehr eingesetzt wird.

 

 

 

RAID Levels 3 & 4

 

 

3 & 4 kommen in der Praxis relativ selten vor:

 

RAID 3: Paritätsfestplatte (Parity Disk)

 

RAID 3 verwendet eine Paritätsfestplatte, um die von einem RAID-Controller erzeugten Paritätsinformationen auf einer separaten Festplatte von den eigentlichen Datenfestplatten zu speichern, anstatt sie mit den Daten zu stripen, wie bei RAID 5. RAID 3 erfordert mindestens drei physische Festplatten.

 

Vorteile: RAID 3 bietet einen hohen Durchsatz und ist daher eine gute Wahl für die Übertragung großer Datenmengen.

 

Nachteile: RAID 3 erfordert ein zusätzliches Laufwerk für die Parität. Da die Paritätsdaten auf einem separaten Laufwerk gespeichert werden, ist die Leistung von RAID 3 schlecht, wenn viele kleine Datenanforderungen vorliegen, wie bei einer Datenbankanwendung.

 

Geeignet für: RAID 3 funktioniert gut bei Anwendungen, die eine lange, sequenzielle Datenübertragung erfordern, zum Beispiel Videoserver.

 

 

RAID 4: Paritätsfestplatte und Block-Level-Striping

 

RAID 4 verwendet eine dedizierte Paritätsfestplatte zusammen mit Block-Level-Striping über Festplatten hinweg, um Daten zu schützen. Bei RAID 4 wird die Anzahl der Bits auf mehreren Festplatten addiert und die Summe auf der separaten Paritätsfestplatte gespeichert. Diese gespeicherten Bits werden zur Datenwiederherstellung verwendet, wenn eine Platte ausfällt.

 

Vorteile: Striping ermöglicht das Lesen von Daten von jeder Festplatte. RAID 4 ist gut für sequentiellen Datenzugriff geeignet.

 

Nachteile: Die Verwendung einer dedizierten Paritätsplatte kann zu Leistungsengpässen bei Schreibvorgängen führen, da alle Schreibvorgänge an die dedizierte Platte gehen müssen.

 

Geeignet für: Da inzwischen Alternativen wie RAID 5 verfügbar sind, wird RAID 4 nicht mehr häufig verwendet.

 

 

RAID 5: Festplatten Striping mit Parätit

 

 

RAID 5 verwendet Festplatten-Striping mit Parität. Wie bei anderen RAID-Leveln, die Striping verwenden, werden die Daten über alle Festplatten im RAID-Set verteilt. Die Paritätsinformationen, die zur Rekonstruktion der Daten im Falle eines Festplattenausfalls benötigt werden, sind ebenfalls diagonal über die Festplatten im RAID-Set verteilt.

 

RAID 5 ist die gängigste RAID-Methode, da sie ein gutes Gleichgewicht zwischen Leistung und Verfügbarkeit erreicht. RAID 5 erfordert mindestens drei physische Festplatten.

 

 

Vorteile: Die kombinierte Verwendung von Daten-Striping und Parität verhindert, dass eine einzelne Festplatte zu einem Engpass wird. RAID 5 bietet einen guten Durchsatz und eine Leistung, die der von RAID 0 entspricht. Da die Paritätsdaten über alle Festplatten im RAID-Satz verteilt sind, ist RAID 5 einer der sichersten RAID-Typen und bietet Datenredundanz und Zuverlässigkeit. RAID-5-Laufwerke können im laufenden Betrieb ausgetauscht werden, wodurch Ausfallzeiten vermieden werden.

 

Nachteile: Die Schreibleistung auf RAID-5-Laufwerken ist aufgrund der Paritätsdatenberechnung langsamer als die Leseleistung. Dieser RAID-Level leidet auch unter längeren Wiederherstellungszeiten und möglichem Datenverlust, wenn ein zweites Laufwerk während einer Wiederherstellung ausfällt. RAID 5 erfordert außerdem einen anspruchsvolleren Controller als andere RAID-Level.

 

 

 

Geeignet für: RAID 5 ist eine gute Option für Anwendungs- und Dateiserver mit einer begrenzten Anzahl von Laufwerken.

 

 

RAID 5+0: Festplatten-Striping und verteilte Parität

 

RAID 5+0, auch bekannt als RAID 50, ist ein weiterer verschachtelter RAID-Level, der Striping und verteilte Parität kombiniert, um die Vorteile von beiden zu nutzen. RAID
50 hat eine Mindestanforderung von sechs Festplatten.

 

 

Vorteile: RAID 50 bietet eine schnellere Schreibleistung als RAID 5. Seine Datenschutzfunktionen sind ebenfalls eine Stufe über RAID 5, und die Wiederherstellungszeit ist schneller. Im Falle eines Festplattenausfalls wird die Leistung nicht so stark beeinträchtigt wie bei RAID 5, da nur eines der RAID-5-Arrays betroffen ist.

 

 

Nachteile: Da RAID 50 sechs Festplatten benötigt, ist es potenziell teurer als andere RAID-Typen. Und wie RAID 5 benötigt es auch einen anspruchsvolleren Controller und synchronisierte Festplatten.

 

Geeignet für: RAID 50 eignet sich gut für Anwendungen, die eine hohe Zuverlässigkeit erfordern, und für solche, die mit hohen Datenübertragungsraten und -anforderungen zurechtkommen müssen.

 

 

 

RAID Levels 6 & 7

 

6 & 7 kommen auch selten vor:

 

RAID 6: Festplatten-Striping mit doppelter Parität

 

RAID 6 erhöht die Zuverlässigkeit, indem Daten auf mehrere Festplatten verteilt werden und E/A-Operationen sich überlappen können, um die Leistung zu verbessern. RAID 6 verwendet zwei Paritäts-Stripes, die zwei Festplattenausfälle innerhalb des RAID-Sets zulassen, bevor Daten verloren gehen. RAID 6 ermöglicht die Datenwiederherstellung bei gleichzeitigen Laufwerksausfällen, was bei Laufwerken mit größerer Kapazität und längeren Wiederherstellungszeiten häufiger vorkommt. RAID 6 erfordert mindestens vier Laufwerke.

 

Vorteile: Die doppelte Parität bei RAID 6 schützt vor Datenverlusten, wenn ein zweites Laufwerk ausfällt. Der prozentuale Anteil der nutzbaren Datenspeicherkapazität steigt mit dem Hinzufügen von Festplatten zu einem RAID-6-Array. Jenseits des Minimums von vier Festplatten verbraucht RAID 6 weniger Speicherkapazität als RAID-Level, die Spiegelung verwenden.

 

 

Nachteile: RAID 6 hat eine geringere Leistung als RAID 5. Die Leistung kann erheblich beeinträchtigt werden, wenn zwei Festplatten gleichzeitig wiederhergestellt werden müssen. RAID 6 kann teurer sein, da es zwei zusätzliche Festplatten für die Parität benötigt. RAID 6 erfordert einen speziellen Controller, und RAID-Controller-Coprozessoren werden oft mit RAID 6 verwendet, um Paritätsberechnungen durchzuführen und die Schreibleistung zu verbessern.

 

 

Geeignet für: RAID 6 ist eine gute Option für die langfristige Datenspeicherung. Es wird häufig für Laufwerke mit großer Kapazität verwendet, die für die Archivierung oder plattenbasierte Datensicherung eingesetzt werden. Mit mehr Datenschutzfunktionen als RAID 5 ist RAID 6 auch eine gute Wahl für unternehmenskritische Anwendungen.

 

 

Adaptives RAID: Option zur Verwendung von RAID 3 oder RAID 5

 

 

Adaptives RAID lässt den RAID-Controller herausfinden, wie die Parität auf den Festplatten gespeichert werden soll. Er wählt zwischen RAID 3 und RAID 5, je nachdem, welcher RAID-Settyp bei der Art der Daten, die auf die Festplatten geschrieben werden, besser funktioniert.

 

 

RAID 7: Nicht-Standard mit Caching

 

 

RAID 7 ist ein Nicht-Standard-RAID-Level – basierend auf RAID 3 und RAID 4 -, der Caching hinzufügt und proprietäre Hardware erfordert. Dieser RAID-Level ist im Besitz und unter dem Warenzeichen der inzwischen aufgelösten Storage Computer Corporation.

 

 

 

Welches RAID-Level Sie verwenden, sollte von der Art der Anwendung abhängen, die Sie auf Ihrem Server ausführen.

 

RAID 0 ist am schnellsten.

 

RAID 1 ist am zuverlässigsten und RAID 5 ist eine gute Kombination aus beidem.

 

Welches RAID für Ihr Unternehmen am besten geeignet ist, hängt von der gewünschten Datenredundanz, der Länge des Aufbewahrungszeitraums, der Anzahl der Festplatten, mit denen Sie arbeiten, und der Bedeutung ab, die Sie der Datensicherung gegenüber der Leistungsoptimierung beimessen.

 

 
RAID Rebuilds 

 

bei einem Rebuild “erholt” sich das RAID nach einem Ausfall und Austausch einer defekten Platte.

 

Die verlorenen Daten werden aus den Sicherungsinformationen wiederhergestellt und damit das Austauschlaufwerk

gefüllt.

 

Wichtig zu beachten ist: ein weiterer Ausfall eines Laufwerks während eines Rebuilds wird in der Regel zu Datenverlust führen!

 

Die gebräuchlichsten RAID Levels in der Prazis sind die RAID Levels 0, 1, 5 und 10.

 

 

Welches RAID-Level Wählen?

 

Welches RAID-System sollte man idealerweise einsetzen?

 

Das hängt von Anforderungen davon ab:

  • hohe Verfügbarheit, ununterbrochenes Betrieb
  • wie viel Plattenspeicher man braucht, und nicht zuletzt auch:
  • KOSTEN! Budget nicht zuletzt – immer ein wichtiges Faktor

 

 

  • Kleine Unternehmen, ein-man Betrieb, freiberufler – Anwaltskanzleien usw: SW Raid, eventuell NAS system angehängt. Mit RAID 1 oder 5.

 

  • grössere Unternehmen: HW-Raid, sehr grosse Betriebe: SAN-Netz: RAID 5 oder 6. Besser wäre RAID 10 oder 20.

 

Noch wichtig zu erwähnen:

 

Hot Spare – sollte man auch einplanen, damit schnell ersetzt werden. Sorgen auch dafür dass ausreichend Spares verfügbar sind.

 

Wichtig ist dass die vom gleichen Groöse und Bautype sind wie die anderen, um kompatabilitätsproblemen zu vermeiden! MEHRERE SPARES BEREITHALTEN!

 

 

Continue Reading

ZFS: Installing & Configuring ZFS on CentOS

ZFS is a file system created by Sun Microsystems, first shipped with Solaris but now available for other LINUX and UNIX operating systems.

 

 

ZFS uses virtual storage pools known as zpools.

 

A conventional RAID array is an abstraction layer that sits between the filesystem and a set of disks. This system presents the entire array as a virtual “disk” device which from the filesystem’s perspective is indistinguishable from an actual real single disk.

 

ZFS goes much further than this, including functionality that you normally require two or three separate software or operational layers in a Linux operating system.

 

ZFS is effectively a logical volume manager, a RAID system, and a filesystem all combined together in the one filesystem.

 

ZFS is designed to handle large amounts of storage and also to prevent data corruption. ZFS can handle up to 256 quadrillion Zettabytes of storage – the Z in ZFS stands for Zettabyte File System).

 

ZFS can in fact handle files up to 16 exabytes in size.

 

ZFS features

 

High storage capacity

Data integrity

Protection against data corruption

Efficient data protection

Date compression

 

 

A traditional RAID is separate from the filesystem. In traditional systems, one can mix and match RAID levels and filesystems.

 

Traditional RAID can be implemented in hardware. However, no hardware controller is required to implement  RAIDZ.

 

Note that RAIDZ is integrated with ZFS.  It cannot be used with any other filesystem.

 

 

 

Installing zfs on Centos 7

 

 

 

[root@centos7vm1 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@centos7vm1 ~]#
[root@centos7vm1 ~]#

 

yum install http://download.zfsonlinux.org/epel/zfs-release.el7_9.noarch.rpm

 

 

[root@centos7vm1 ~]#
[root@centos7vm1 ~]# yum install http://download.zfsonlinux.org/epel/zfs-release.el7_9.noarch.rpm
Loaded plugins: fastestmirror, langpacks
zfs-release.el7_9.noarch.rpm | 5.3 kB 00:00:00
Examining /var/tmp/yum-root-JLgnzc/zfs-release.el7_9.noarch.rpm: zfs-release-1-7.9.noarch
Marking /var/tmp/yum-root-JLgnzc/zfs-release.el7_9.noarch.rpm to be installed
Resolving Dependencies
–> Running transaction check
—> Package zfs-release.noarch 0:1-7.9 will be installed
–> Finished Dependency Resolution
base/7/x86_64
updates/7/x86_64/primary_db | 15 MB 00:00:09

Dependencies Resolved

=======================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================
Installing:
zfs-release noarch 1-7.9 /zfs-release.el7_9.noarch 2.9 k

Transaction Summary
=======================================================================================================================================
Install 1 Package

Total size: 2.9 k
Installed size: 2.9 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : zfs-release-1-7.9.noarch 1/1
Verifying : zfs-release-1-7.9.noarch 1/1

Installed:
zfs-release.noarch 0:1-7.9

Complete!
[root@centos7vm1 ~]#

 

There are two ways ZFS module can be loaded to the kernel, DKMS and kABI. The difference between these is that if you install DKMS based ZFS module, and then for some reason you update the kernel of your operating system, the ZFS kernel module must be recompiled again.

 

Otherwise it won’t work. But the kABI based ZFS module has the upper hand in that it doesn’t require recompilation if the kernel of the operating system is updated.

 

In this lab I will install the kABI based ZFS kernel module.

 

When you install the ZFS repository on CentOS 7, the DKMS based repository is enabled by default. So you have to disable DKMS based repository and enable the kABI based repository.

 

To disable the DKMS based ZFS repository and enable kABI based ZFS repository, first open the yum configuration file of ZFS with a text editor with the following command:

 

nano /etc/yum.repos.d/zfs.repo

 

for DKMS based ZFS repository:

 

First change the enabled=1 to enabled=0 to disable the DKMS based ZFS repository.

 

and for kABI based ZFS repository:

 

change the enabled=0 to enabled=1 to enable the kABI based ZFS repository.

 

 

Now you can install ZFS File System on your CentOS 7 with the following command:

 

yum install zfs

 

 

[root@centos7vm1 ~]# yum install zfs
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* base: mirror.pulsant.com
* centos-ceph-nautilus: mirror.bytemark.co.uk
* centos-nfs-ganesha28: mirror.netweaver.uk
* epel: ftp.nluug.nl
* extras: mirror.netweaver.uk
* updates: mirrors.vinters.com
zfs-kmod | 2.9 kB 00:00:00
zfs-kmod/x86_64/primary_db | 175 kB 00:00:01
ceph-noarch 184/184
Resolving Dependencies
–> Running transaction check
—> Package zfs.x86_64 0:2.0.7-1.el7 will be installed
–> Processing Dependency: zfs-kmod = 2.0.7 for package: zfs-2.0.7-1.el7.x86_64
–> Processing Dependency: libzpool4 = 2.0.7 for package: zfs-2.0.7-1.el7.x86_64
–> Processing Dependency: libzfs4 = 2.0.7 for package: zfs-2.0.7-1.el7.x86_64
–> Processing Dependency: libuutil3 = 2.0.7 for package: zfs-2.0.7-1.el7.x86_64
–> Processing Dependency: libnvpair3 = 2.0.7 for package: zfs-2.0.7-1.el7.x86_64
–> Processing Dependency: libzpool.so.4()(64bit) for package: zfs-2.0.7-1.el7.x86_64
–> Processing Dependency: libzfs_core.so.3()(64bit) for package: zfs-2.0.7-1.el7.x86_64
–> Processing Dependency: libzfs.so.4()(64bit) for package: zfs-2.0.7-1.el7.x86_64
–> Processing Dependency: libuutil.so.3()(64bit) for package: zfs-2.0.7-1.el7.x86_64
–> Processing Dependency: libnvpair.so.3()(64bit) for package: zfs-2.0.7-1.el7.x86_64
–> Running transaction check
—> Package kmod-zfs.x86_64 0:2.0.7-1.el7 will be installed

 

Downloading packages:
(1/6): libnvpair3-2.0.7-1.el7.x86_64.rpm | 32 kB 00:00:00
(2/6): libuutil3-2.0.7-1.el7.x86_64.rpm | 26 kB 00:00:00
(3/6): libzfs4-2.0.7-1.el7.x86_64.rpm | 219 kB 00:00:01
(4/6): kmod-zfs-2.0.7-1.el7.x86_64.rpm | 1.4 MB 00:00:02
(5/6): zfs-2.0.7-1.el7.x86_64.rpm | 595 kB 00:00:00
(6/6): libzpool4-2.0.7-1.el7.x86_64.rpm | 1.2 MB 00:00:02
—————————————————————————————————————————————
Total 861 kB/s | 3.5 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libnvpair3-2.0.7-1.el7.x86_64 1/6
Installing : libuutil3-2.0.7-1.el7.x86_64 2/6
Installing : libzfs4-2.0.7-1.el7.x86_64 3/6
Installing : libzpool4-2.0.7-1.el7.x86_64 4/6
Installing : kmod-zfs-2.0.7-1.el7.x86_64 5/6
Installing : zfs-2.0.7-1.el7.x86_64 6/6
Verifying : kmod-zfs-2.0.7-1.el7.x86_64 1/6
Verifying : zfs-2.0.7-1.el7.x86_64 2/6
Verifying : libuutil3-2.0.7-1.el7.x86_64 3/6
Verifying : libzpool4-2.0.7-1.el7.x86_64 4/6
Verifying : libzfs4-2.0.7-1.el7.x86_64 5/6
Verifying : libnvpair3-2.0.7-1.el7.x86_64 6/6

Installed:
zfs.x86_64 0:2.0.7-1.el7

Dependency Installed:
kmod-zfs.x86_64 0:2.0.7-1.el7 libnvpair3.x86_64 0:2.0.7-1.el7 libuutil3.x86_64 0:2.0.7-1.el7 libzfs4.x86_64 0:2.0.7-1.el7
libzpool4.x86_64 0:2.0.7-1.el7

Complete!
[root@centos7vm1 ~]#

 

 

 

next do a reboot and then run the following command to check whether ZFS kernel module is loaded.

 

lsmod | grep zfs

 

If you don’t see any output, then ZFS kernel module is not loaded. In that case, run the following command to load the ZFS kernel module manually.

 

 modprobe zfs

 

 

next add some disks

 

using fdisk, I added a 5GB virtual SCSI disk /dev/sda

 

and then created 10 partitions of 400MB each.

 

You can check what disks you have with the following command:

 

$ sudo lsblk

 

or with fdisk -l

 

 

Disk /dev/sda: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

 

 

[root@centos7vm1 ~]# lsmod | grep zfs
[root@centos7vm1 ~]# modprobe zfs
[root@centos7vm1 ~]# lsmod | grep zfs
zfs 4224878 0
zunicode 331170 1 zfs
zzstd 460780 1 zfs
zlua 151526 1 zfs
zcommon 94285 1 zfs
znvpair 94388 2 zfs,zcommon
zavl 15698 1 zfs
icp 301775 1 zfs
spl 96750 6 icp,zfs,zavl,zzstd,zcommon,znvpair
[root@centos7vm1 ~]#

 

[root@centos7vm1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 5G 0 disk
sr0 11:0 1 1024M 0 rom
vda 252:0 0 10G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 9G 0 part
├─centos-root 253:0 0 8G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
[root@centos7vm1 ~]#

 

Next I am going to partition the /dev/sda scsi disk of 5gb that I just added, into 11 partitions of 400MB each:

 

[root@centos7vm1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 5G 0 disk
├─sda1 8:1 0 400M 0 part
├─sda2 8:2 0 400M 0 part
├─sda3 8:3 0 400M 0 part
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 400M 0 part
├─sda6 8:6 0 400M 0 part
├─sda7 8:7 0 400M 0 part
├─sda8 8:8 0 400M 0 part
├─sda9 8:9 0 400M 0 part
├─sda10 8:10 0 400M 0 part
├─sda11 8:11 0 400M 0 part
└─sda12 8:12 0 400M 0 part
sr0 11:0 1 1024M 0 rom
vda 252:0 0 10G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 9G 0 part
├─centos-root 253:0 0 8G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
[root@centos7vm1 ~]#

 

 

fdisk -l /dev/sda

 

[root@centos7vm1 ~]#
[root@centos7vm1 ~]# fdisk -l /dev/sda

 

Disk /dev/sda: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x7157d815

 

Device Boot Start End Blocks Id System
/dev/sda1 2048 821247 409600 83 Linux
/dev/sda2 821248 1640447 409600 83 Linux
/dev/sda3 1640448 2459647 409600 83 Linux
/dev/sda4 2459648 10485759 4013056 5 Extended
/dev/sda5 2461696 3280895 409600 83 Linux
/dev/sda6 3282944 4102143 409600 83 Linux
/dev/sda7 4104192 4923391 409600 83 Linux
/dev/sda8 4925440 5744639 409600 83 Linux
/dev/sda9 5746688 6565887 409600 83 Linux
/dev/sda10 6567936 7387135 409600 83 Linux
/dev/sda11 7389184 8208383 409600 83 Linux
/dev/sda12 8210432 9029631 409600 83 Linux
[root@centos7vm1 ~]#

 

 

Create a ZFS Pool

 

 

A ZFS pool combines drives together to perform single storage. Pools should always be created on disks which are currently not in use.

 

So when the storage needs to be expanded simply add drives to the pool to increase overall storage capacity.

 

 

You can create a ZFS pool using different devices: 

using whole disks

using disk slices

using files

 

You can name your ZFS pool anything you wish.

 

A new directory with the same name as your ZFS pool will be created in the / directory.

 

 

You also specify your storage devices or disk drives when you create a ZFS pool.

 

let’s create an initial pool with the name FILES

 

zpool create FILES /dev/sda1 /dev/sda2

 

[root@centos7vm1 ~]# zpool create FILES /dev/sda1 /dev/sda2
[root@centos7vm1 ~]# cd /

 

[root@centos7vm1 /]# ls -l

 

drwxr-xr-x 2 root root 2 Apr 12 13:35 FILES

 

You can run the following command to list all the available ZFS pool of your system:

 

zpool list

 

[root@centos7vm1 /]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
FILES 768M 105K 768M – – 0% 0% 1.00x ONLINE –
[root@centos7vm1 /]#

 

 

just copied some files across to /FILES from another machine using rsync

 

[root@centos7vm1 IT_BOOKS]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
FILES 768M 581M 187M – – 52% 75% 1.00x ONLINE –
[root@centos7vm1 IT_BOOKS]#

 

By default, a ZFS pool is only writeable by the root user. If you as an ordinary user want to write to the ZFS pool, you have to change the permission of the ZFS pool.

 

You can run the following command to change the permission of your ZFS pool:

 

chown -Rfv kevin:kevin /FILES

 

 

 

 

3 Types of ZFS Storage Pools

 

There are three types of pools that can be created in ZFS:

 

Striped Pool
Mirrored Pool
Raid Pool

 

 

Each offers its own sets of advantages and disadvantages.

 

 

It is important to decide which type of pool is going to be used since once the pool is created it cannot be undone.

 

 

In order to change pool type, a new pool would need to be created, then all data migrated from the old pool to the new pool, then deleting the old pool.

 

 

Creating a Striped Pool

 

This is the basis ZFS storage pool where incoming data is dynamically striped across all disks in the pool. Although this offers maximum write performance, it also comes with a price. Any single failed drive will make the pool completely unusable and data loss will occur.

 

Besides the performance, the biggest advantage of striped pools is total storage capacity is equal to the total size of all disks. We can use the following command to create a ZFS striped pool:

 

$ zpool create /dev/sdX /dev/sdX

 

To increase the size of the striped pool, we can simply add a drive using the following command:

 

$ zpool add /dev/sdX

 

It is important to note here that, when a new disk is added to a striped pool, ZFS will not redistribute existing data over to the new disk, but will favour the newly added disk for new incoming data. The only way to redistribute existing data is to delete, then recopy the data in which case data will be stripped on all disks.

 

 

Creating a Mirrored Pool

 

As the name suggests, this pool consists of mirrored disks.

There are no restrictions on how the mirror can be formed. The main caveat when using the mirrored pool is that we lose 50% of total disk capacity due to the mirroring.

 

 

To create a mirror pool of just two disks:

 

zpool create mirror /dev/sda /dev/sdb

 

To expand a mirror pool we simply need to add another group of the mirrored disk:

 

zpool add mirror /dev/sdd /dev/sde /dev/sdf

 

 

Dynamic strip – is the very basic pool which can be created with a single disk or a concatenation of disk. We have already seen zpool creation using a single disk in the example of creating zpool with disks. Lets see how we can create concatenated zfs pool.

 

 

When adding another mirror group, data is striped on to the new mirrored group of the disk. Although it is rare, it is also possible to create a mirror of more than two disks:

 

zpool create FILES /dev/sda1 /dev/sda2

 

 

zpool list

 

[root@centos7vm1 ~]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
FILES 768M 111K 768M – – 0% 0% 1.00x ONLINE –
[root@centos7vm1 ~]#

 

 

after copying some files to the pool /FILES, it now looks like this:

 

[root@centos7vm1 ~]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
FILES 768M 581M 187M – – 65% 75% 1.00x ONLINE –
[root@centos7vm1 ~]#

 

 

This configuration does not provide any redundancy. Hence any disk failure will result in a data loss.

 

Also note that once a disk is added in this fashion to a zfs pool may not be removed from the pool again.

 

The only way to free the disk is to destroy entire pool. This happens due to the dynamic striping nature of the pool which uses both disk to store the data.

 

 

the next stage up from a striped pool is a mirrored pool:

 

 

Mirrored pool –  2 way mirror

 

 

A mirrored pool provides you the redundancy which enables us to store multiple copies of data on different disks.

Here you can also detach a disk from the pool as the data will be available on the another disks.

 

zpool create MIRROREDPOOL mirror /dev/sda5 /dev/sda6

 

ls -l

drwxr-xr-x 2 root root 2 Apr 12 14:08 MIRROREDPOOL

 

[root@centos7vm1 /]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
FILES 768M 581M 187M – – 65% 75% 1.00x ONLINE –
MIRROREDPOOL 384M 100K 384M – – 0% 0% 1.00x ONLINE –
[root@centos7vm1 /]#

 

 

3 way mirrored pool

 

this has 3 disks:

 

zpool create MIRROR3DISKPOOL mirror /dev/sda7 /dev/sda8 /dev/sda9

 

[root@centos7vm1 /]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
FILES 768M 581M 187M – – 64% 75% 1.00x ONLINE –
MIRROR3DISKPOOL 384M 102K 384M – – 0% 0% 1.00x ONLINE –
MIRROREDPOOL 384M 130M 254M – – 3% 33% 1.00x ONLINE –
[root@centos7vm1 /]#

 

 

 

Creating a ZFS File System

 

ZFS filesystems are created inside ZFS storage pools using the zfs create command. The create subcommand takes a single argument: the name of the filesystem to be created.

 

The filesystem name is specified as a path name beginning from the name of the pool:

 

pool-name/[filesystem-name/]filesystem-name

 

The pool name and initial filesystem names in the path define the location where the new filesystem will be created. The last name in the path specifies the name of the filesystem to be created.

 

example:

 

zfs create RAIDZ1/filesystem1

 

 

df
RAIDZ1 256M 130M 127M 51% /RAIDZ1
MIRROR3DISKPOOL 256M 130M 127M 51% /MIRROR3DISKPOOL
RAIDZ2 255M 130M 126M 51% /RAIDZ2
RAIDZ3 256M 130M 127M 51% /RAIDZ3
tmpfs 150M 0 150M 0% /run/user/0
RAIDZ1/filesystem1 127M 128K 127M 1% /RAIDZ1/filesystem1
[root@centos7vm1 RAIDZ1]#

 

 

 

To destroy a pool

 

 

To destroy a ZFS filesystem, use the zfs destroy command. The specified filesystem will then be automatically unmounted, unshared and deleted.

 

NOTE that if the filesystem to be destroyed is busy and can’t be unmounted, then the zfs destroy command will fail. To destroy an active filesystem, use the -f option.

 

 

 

[root@centos7vm1 MIRROR3DISKPOOL]# zpool destroy FILES
[root@centos7vm1 MIRROR3DISKPOOL]# zpool destroy MIRROREDPOOL
[root@centos7vm1 MIRROR3DISKPOOL]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
MIRROR3DISKPOOL 384M 130M 254M – – 2% 33% 1.00x ONLINE –
[root@centos7vm1 MIRROR3DISKPOOL]#
[root@centos7vm1 MIRROR3DISKPOOL]#
[root@centos7vm1 MIRROR3DISKPOOL]#

 

[root@centos7vm1 RAIDZ1]# zfs destroy RAIDZ1/filesystem1
[root@centos7vm1 RAIDZ1]#

 

df
RAIDZ1 262016 132736 129280 51% /RAIDZ1
MIRROR3DISKPOOL 262016 132736 129280 51% /MIRROR3DISKPOOL
RAIDZ2 260480 132224 128256 51% /RAIDZ2
RAIDZ3 262016 132736 129280 51% /RAIDZ3
tmpfs 153076 0 153076 0% /run/user/0
[root@centos7vm1 RAIDZ1]#

 

 

Creating RAID-Z pools

 

Now we can also have a pool similar to a RAID-5 configuration called as RAID-Z. RAID-Z are of 3 types raidz1 (single parity) and raidz2 (double parity) and rzidz3 (triple parity). Lets us see how we can configure each type.

 

Minimum disk requirements for each type

 

Minimum disks required for each type of RAID-Z

 

raidz1 – 2 disks
raidz2 – 3 disks
raidz3 – 4 disks

 

 

 

Creating a Raidz1 Pool

 

 

to create a raidz1:

 

 

zpool create <pool name> raidz disk1 disk2

 

eg

(sda7,8,9 are in use for MIRRORED3DISKPOOL)

zpool create RAIDZ1 raidz /dev/sda1 /dev/sda2

 

 

Creating a raidz2 Pool

 

 

eg

 

zpool create RAIDZ2 raidz2 /dev/sda3 /dev/sda5 /dev/sda6

 

[root@centos7vm1 /]# zpool destroy RAIDZ1
[root@centos7vm1 /]# zpool destroy RAIDZ2
[root@centos7vm1 /]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
MIRROR3DISKPOOL 384M 130M 254M – – 2% 33% 1.00x ONLINE –
[root@centos7vm1 /]# zpool create RAIDZ1 raidz /dev/sda1 /dev/sda2

 

[root@centos7vm1 /]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
MIRROR3DISKPOOL 384M 130M 254M – – 2% 33% 1.00x ONLINE –
RAIDZ1 768M 240K 768M – – 0% 0% 1.00x ONLINE –

 

[root@centos7vm1 /]# zpool create RAIDZ2 raidz2 /dev/sda3 /dev/sda5 /dev/sda6
[root@centos7vm1 /]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
MIRROR3DISKPOOL 384M 130M 254M – – 2% 33% 1.00x ONLINE –
RAIDZ1 768M 201K 768M – – 0% 0% 1.00x ONLINE –
RAIDZ2 1.12G 360K 1.12G – – 0% 0% 1.00x ONLINE –
[root@centos7vm1 /]#

 

 

Creating a raidz3 Pool

 

 

zpool create RAIDZ3 raidz3 /dev/sda10 /dev/sda11 /dev/sda12 /dev/sda13

 

 

[root@centos7vm1 ~]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
MIRROR3DISKPOOL 384M 130M 254M – – 2% 33% 1.00x ONLINE –
RAIDZ1 768M 228K 768M – – 0% 0% 1.00x ONLINE –
RAIDZ2 1.12G 405K 1.12G – – 0% 0% 1.00x ONLINE –

 

[root@centos7vm1 ~]# zpool create RAIDZ3 raidz3 /dev/sda10 /dev/sda11 /dev/sda12 /dev/sda13
[root@centos7vm1 ~]# 

 

 

[root@centos7vm1 /]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 736M 0 736M 0% /dev
tmpfs 748M 0 748M 0% /dev/shm
tmpfs 748M 8.7M 739M 2% /run
tmpfs 748M 0 748M 0% /sys/fs/cgroup
/dev/mapper/centos-root 8.0G 2.8G 5.3G 35% /
/dev/vda1 1014M 202M 813M 20% /boot
MIRROR3DISKPOOL 256M 130M 127M 51% /MIRROR3DISKPOOL
RAIDZ1 256M 130M 127M 51% /RAIDZ1
RAIDZ2 255M 130M 126M 51% /RAIDZ2
RAIDZ3 256M 130M 127M 51% /RAIDZ3
tmpfs 150M 0 150M 0% /run/user/0
RAIDZ1/fs1 127M 128K 127M 1% /RAIDZ1/fs1

 

[root@centos7vm1 /]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
MIRROR3DISKPOOL 384M 130M 254M – – 2% 33% 1.00x ONLINE –
RAIDZ1 768M 259M 509M – – 0% 33% 1.00x ONLINE –
RAIDZ2 1.12G 389M 763M – – 0% 33% 1.00x ONLINE –
RAIDZ3 1.50G 519M 1017M – – 0% 33% 1.00x ONLINE –
[root@centos7vm1 /]#
[root@centos7vm1 /]#

 

 

 

Basic ZFS Commands

 

 

zfs list

 

[root@centos7vm1 RAIDZ1]# zfs list
NAME USED AVAIL REFER MOUNTPOINT
MIRROR3DISKPOOL 130M 126M 130M /MIRROR3DISKPOOL
RAIDZ1 130M 126M 130M /RAIDZ1
RAIDZ2 129M 125M 129M /RAIDZ2
RAIDZ3 130M 126M 130M /RAIDZ3
[root@centos7vm1 RAIDZ1]#

 

[root@centos7vm1 RAIDZ1]# zfs list -o name,sharenfs,mountpoint
NAME SHARENFS MOUNTPOINT
MIRROR3DISKPOOL off /MIRROR3DISKPOOL
RAIDZ1 off /RAIDZ1
RAIDZ2 off /RAIDZ2
RAIDZ3 off /RAIDZ3
[root@centos7vm1 RAIDZ1]#

 

[root@centos7vm1 RAIDZ1]# zfs get mountpoint RAIDZ1
NAME PROPERTY VALUE SOURCE
RAIDZ1 mountpoint /RAIDZ1 default
[root@centos7vm1 RAIDZ1]#

 

 

zpool status

 

 

root@centos7vm1 RAIDZ1]# zpool status
pool: MIRROR3DISKPOOL
state: ONLINE
config:

NAME STATE READ WRITE CKSUM
MIRROR3DISKPOOL ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
sda7 ONLINE 0 0 0
sda8 ONLINE 0 0 0
sda9 ONLINE 0 0 0

errors: No known data errors

pool: RAIDZ1
state: ONLINE
config:

NAME STATE READ WRITE CKSUM
RAIDZ1 ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
sda1 ONLINE 0 0 0
sda2 ONLINE 0 0 0

errors: No known data errors

pool: RAIDZ2
state: ONLINE
config:

NAME STATE READ WRITE CKSUM
RAIDZ2 ONLINE 0 0 0
raidz2-0 ONLINE 0 0 0
sda3 ONLINE 0 0 0
sda5 ONLINE 0 0 0
sda6 ONLINE 0 0 0

errors: No known data errors

pool: RAIDZ3
state: ONLINE
config:

NAME STATE READ WRITE CKSUM
RAIDZ3 ONLINE 0 0 0
raidz3-0 ONLINE 0 0 0
sda10 ONLINE 0 0 0
sda11 ONLINE 0 0 0
sda12 ONLINE 0 0 0
sda13 ONLINE 0 0 0

errors: No known data errors
[root@centos7vm1 RAIDZ1]#

 

 

 

[root@centos7vm1  ~]# zpool status -x
all pools are healthy
[root@centos7vm1  ~]# 

 

 

Mounting ZFS Filesystems

 

ZFS automatically mounts filesystems when filesystems are created or when the system boots.

 

Use of the zfs mount command is necessary only when you need to change mount options, or explicitly mount or unmount filesystems.

 

[root@centos7vm1 RAIDZ1]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 753628 0 753628 0% /dev
tmpfs 765380 0 765380 0% /dev/shm
tmpfs 765380 8912 756468 2% /run
tmpfs 765380 0 765380 0% /sys/fs/cgroup
/dev/mapper/centos-root 8374272 3127172 5247100 38% /
/dev/vda1 1038336 240956 797380 24% /boot
RAIDZ1 261888 132736 129152 51% /RAIDZ1
MIRROR3DISKPOOL 262016 132736 129280 51% /MIRROR3DISKPOOL
RAIDZ2 260480 132224 128256 51% /RAIDZ2
RAIDZ3 262016 132736 129280 51% /RAIDZ3
tmpfs 153076 0 153076 0% /run/user/0

 

[root@centos7vm1 RAIDZ1]# zfs mount RAIDZ1/filesystem1
[root@centos7vm1 RAIDZ1]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 753628 0 753628 0% /dev
tmpfs 765380 0 765380 0% /dev/shm
tmpfs 765380 8912 756468 2% /run
tmpfs 765380 0 765380 0% /sys/fs/cgroup
/dev/mapper/centos-root 8374272 3127172 5247100 38% /
/dev/vda1 1038336 240956 797380 24% /boot
RAIDZ1 261888 132736 129152 51% /RAIDZ1
MIRROR3DISKPOOL 262016 132736 129280 51% /MIRROR3DISKPOOL
RAIDZ2 260480 132224 128256 51% /RAIDZ2
RAIDZ3 262016 132736 129280 51% /RAIDZ3
tmpfs 153076 0 153076 0% /run/user/0
RAIDZ1/filesystem1 129280 128 129152 1% /RAIDZ1/filesystem1
[root@centos7vm1 RAIDZ1]#

 

Note: zfs list – this will still show the filesystem even if it is unmounted. You need to do df in order to check if it is unmounted.

 

zfs list merely shows whether the filesystem exists or not, not whether it is mounted or not.

 

 

 

Sharing ZFS Filesystems

 

 

By default, all ZFS filesystems are unshared. To share a new filesystem via NFS, you first must set the zfs share option such as follows:

 

zfs set sharenfs=on RAIDZ1/filesystem1

 

or for read-write for an entire pool:

 

zfs set sharenfs=’rw’ RAIDZ1

 

or, for read-only sharing:
 
 
 
zfs set sharenfs=ro  RAIDZ1/filesystem1 

 

You can also share all ZFS file systems on the system by using the -a option.

 

zfs share -a

 

You can also set sharing only for a specific computer:

 

zfs set sharenfs=’rw=@192.168.122.0/24′ RAIDZ1

 

 

You can use the colon (:) symbol to allow access to the ZFS pool pool1 from multiple network subnets or IP addresses:

 

eg

 

zfs set sharenfs=’rw=@192.168.122.0/24:@192.168.132.0/24′ RAIDZ1

 

 

 

You can verify whether the sharenfs property is correctly set on the ZFS pool RAIDZ1:

 

zfs get sharenfs RAIDZ1

 

[root@centos7vm1 RAIDZ1]# zfs set sharenfs=’rw’ RAIDZ1
[root@centos7vm1 RAIDZ1]# zfs get sharenfs RAIDZ1
NAME PROPERTY VALUE SOURCE
RAIDZ1 sharenfs rw local
[root@centos7vm1 RAIDZ1]#

 

 

Unsharing ZFS File Systems

 

ZFS file systems are automatically shared or unshared during boot, creation, and destruction, but file systems sometimes need to be explicitly unshared.

 

For this use the zfs unshare command. For example:

 

zfs unshare RAIDZ1/filesystem1

 

 

 

Failing a ZFS Drive

 

 

for this test, we are going to fail a drive in the 3-drive pool RAIDZ1:

 

 

# zpool status RAIDZ1
pool: RAIDZ1
state: ONLINE
config:

NAME STATE READ WRITE CKSUM
RAIDZ1 ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
sda1 ONLINE 0 0 0
sda2 ONLINE 0 0 0

errors: No known data errors
[root@centos7vm1 RAIDZ1]#

 

 

 
 
 
was no difference, so I then removed the sda2 partition using fdisk-
 
 
and then rebooted. This time it took effect:
 
 
sda2 is no longer present. Neither in fdisk definition (partition table) nor in ZFS:
 
 
 
 
 
 
[root@centos7vm1  ~]# fdisk -l /dev/sda
 
 
Disk /dev/sda: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x7157d815
 
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      821247      409600   83  Linux
/dev/sda3         1640448     2459647      409600   83  Linux
/dev/sda4         2459648    10485759     4013056    5  Extended
/dev/sda5         2461696     3280895      409600   83  Linux
/dev/sda6         3282944     4102143      409600   83  Linux
/dev/sda7         4104192     4923391      409600   83  Linux
/dev/sda8         4925440     5744639      409600   83  Linux
/dev/sda9         5746688     6565887      409600   83  Linux
/dev/sda10        6567936     7387135      409600   83  Linux
/dev/sda11        7389184     8208383      409600   83  Linux
/dev/sda12        8210432     9029631      409600   83  Linux
/dev/sda13        9031680     9850879      409600    0  Empty
/dev/sda14        9852928    10485759      316416   83  Linux
[root@centos7vm1  ~]# 
 
 
 
 
[root@centos7vm1  ~]# zpool status -v RAIDZ1
  pool: RAIDZ1
 state: DEGRADED
status: One or more devices could not be used because the label is missing or
invalid.  Sufficient replicas exist for the pool to continue
functioning in a degraded state.
action: Replace the device using ‘zpool replace’.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-4J
config:
 
 
 
NAME                      STATE     READ WRITE CKSUM
RAIDZ1                    DEGRADED     0     0     0
  raidz1-0                DEGRADED     0     0     0
    sda1                  ONLINE       0     0     0
    13088115050400177900  UNAVAIL      0     0     0  was /dev/sda2
 
 
 
errors: No known data errors
[root@centos7vm1  ~]# 

 

 

To replace the drive… as I dont have any free drives (ie partitions) left, I simply re-ran fdisk and recreated the sda2 partition. 
 
 
Then rebooted and ran the zpoool replace command:
 
 
the drive was then restored successfully to the pool….
 
 
 
[root@centos7vm1  ~]# zpool replace RAIDZ1 /dev/sda2
[root@centos7vm1  ~]# zpool status -v RAIDZ1
  pool: RAIDZ1
 state: ONLINE
  scan: resilvered 130M in 00:00:01 with 0 errors on Tue Apr 12 19:14:47 2022
config:
 
 
NAME        STATE     READ WRITE CKSUM
RAIDZ1      ONLINE       0     0     0
  raidz1-0  ONLINE       0     0     0
    sda1    ONLINE       0     0     0
    sda2    ONLINE       0     0     0
 
 
errors: No known data errors
[root@centos7vm1  ~]# 
 

 

Note the “resilvered” status shown – this is the rebuild of the zfs pool after replacing the drive

 

 

 

Listing  ZFS Properties

 

 

[root@centos7vm1 ~]# zpool get all RAIDZ1
NAME PROPERTY VALUE SOURCE
RAIDZ1 size 768M –
RAIDZ1 capacity 33% –
RAIDZ1 altroot – default
RAIDZ1 health ONLINE –
RAIDZ1 guid 17775474607569600445 –
RAIDZ1 version – default
RAIDZ1 bootfs – default
RAIDZ1 delegation on default
RAIDZ1 autoreplace off default
RAIDZ1 cachefile – default
RAIDZ1 failmode wait default
RAIDZ1 listsnapshots off default
RAIDZ1 autoexpand off default
RAIDZ1 dedupratio 1.00x –
RAIDZ1 free 508M –
RAIDZ1 allocated 260M –
RAIDZ1 readonly off –
RAIDZ1 ashift 0 default
RAIDZ1 comment – default
RAIDZ1 expandsize – –
RAIDZ1 freeing 0 –
RAIDZ1 fragmentation 0% –
RAIDZ1 leaked 0 –
RAIDZ1 multihost off default
RAIDZ1 checkpoint – –
RAIDZ1 load_guid 4470113783087180867 –
RAIDZ1 autotrim off default   

 

 

 

.. this is just a short extract of the output from the command…

[root@centos7vm1 ~]#

 

Continue Reading

MDADM RAID Commands

mdadm modes

 

mdadm has seven modes:

 

Assemble

 

Used the most, but mostly runs in the background. Every time the system is booted, assemble will need to run.

 

Assemble scans the drives, looks for superblocks, and rebuilds the arrays.

You need an initramfs when booting off a raid array – because mdadm is a user-space program.

 

If the root partition is located on an array then we have a catch-22 situation: we can’t boot until we have the root partition in read-write live mode, and we can’t have root until we’ve booted and are then able to run mdadm.

 

Create

 

This is used a lot in practice: it is used to create arrays, and writes the superblocks for arrays that have them.

 

It also initialises to make sure the disks of a mirror are identical, or that the parities in an arry are correct.

 

Grow

 

Grow takes care of all operations relating to changing the size of an array, such as changing raid level, changing the number of active devices, adding disks, etc.

 

Manage

 

Manage is the default mode for mdadm. It is used primarily to add and remove devices. Manage has a number of additional options such as –add which are also found in grow mode

 

Build

This is an older mode, used to (re)create an array. It should only be used with care.

 

Misc

 

This covers a number of other actions.

 

 

 

 

mdadm Command Overview

 

root@asus:~#
root@asus:~# mdadm –manage –help
Usage: mdadm arraydevice options component devices…

This usage is for managing the component devices within an array.
The –manage option is not needed and is assumed if the first argument
is a device name or a management option.
The first device listed will be taken to be an md array device, any
subsequent devices are (potential) components of that array.

Options that are valid with management mode are:
–add -a : hotadd subsequent devices to the array
–re-add : subsequent devices are re-added if there were
: recent members of the array
–remove -r : remove subsequent devices, which must not be active
–fail -f : mark subsequent devices a faulty
–set-faulty : same as –fail
–replace : mark device(s) to be replaced by spares. Once
: replacement completes, device will be marked faulty
–with : Indicate which spare a previous ‘–replace’ should
: prefer to use
–run -R : start a partially built array
–stop -S : deactivate array, releasing all resources
–readonly -o : mark array as readonly
–readwrite -w : mark array as readwrite
root@asus:~# 

 

 

Some Basic mdadm Commands

 

To display detailed information about a RAID device, use mdadm -D with the RAID device to query:

 

mdadm -D /dev/md0

 

How to automount RAIDs on reboot:

 

Note that the UUIDs used in mdadm.conf are related to the MD RAID device driver array, whereas the UUIDs used in fstab are related to filesystems on the RAID array – a subtle difference.

 

You have to use filesystem UUID numbers for the fstab which are different to the mdadm.conf ones.

 

You can list them with

 

blkid /dev/disk/by-id/md-uuid-${UUID}

 

Alternatively you can use

 

blkid ${RAID_DEVICE}.

 

 

[root@centos1vm ~]# mdadm -D /dev/md127
/dev/md127:
Version : 1.2
Creation Time : Sat Apr 9 00:48:11 2022
Raid Level : raid1
Array Size : 1527808 (1492.00 MiB 1564.48 MB)
Used Dev Size : 1527808 (1492.00 MiB 1564.48 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

Update Time : Sat Apr 9 11:53:15 2022
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Consistency Policy : resync

Name : centos1vm:RAID50 (local to host centos1vm)
UUID : 66470135:4f0bd96a:357fe54e:2baa3a7b
Events : 17

Number Major Minor RaidDevice State
0 9 1 0 active sync /dev/md1
1 9 2 1 active sync /dev/md2
[root@centos1vm ~]#

 

 

the above is actually a RAID50: consisting of two RAID5s (md1 and md2 respectively)

 

see below:

 

 

 

[root@centos1vm ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Sat Apr 9 00:41:10 2022
Raid Level : raid5
Array Size : 1529856 (1494.00 MiB 1566.57 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Sat Apr 9 11:53:15 2022
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID5a (local to host centos1vm)
UUID : 57784eb2:7d894249:e368bbd6:4fef82a1
Events : 20

Number Major Minor RaidDevice State
0 8 25 0 active sync /dev/sdb9
1 8 26 1 active sync /dev/sdb10
2 8 27 2 active sync /dev/sdb11
4 8 28 3 active sync /dev/sdb12

 

 

[root@centos1vm ~]# mdadm -D /dev/md2
/dev/md2:
Version : 1.2
Creation Time : Sat Apr 9 00:41:25 2022
Raid Level : raid5
Array Size : 1529856 (1494.00 MiB 1566.57 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Sat Apr 9 11:53:15 2022
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID5b (local to host centos1vm)
UUID : cb67bc06:d32061ea:eda8873f:c15b9fbf
Events : 20

Number Major Minor RaidDevice State
0 8 29 0 active sync /dev/sdb13
1 8 30 1 active sync /dev/sdb14
2 8 31 2 active sync /dev/sdb15
4 259 0 3 active sync /dev/sdb16
[root@centos1vm ~]#

 

 

 

 

This displays RAID level, the array size, the health of the individual drives, the UUID of the array, and the component devices and their current roles.

 

You can get shortened details for an array, eg to add to the /dev/mdadm/mdadm.conf file, by using –brief or -b flags with the -D:

 

mdadm -Db /dev/md0

 

[root@centos1vm ~]# mdadm -Db /dev/md127
ARRAY /dev/md127 metadata=1.2 name=centos1vm:RAID50 UUID=66470135:4f0bd96a:357fe54e:2baa3a7b
[root@centos1vm ~]# mdadm -Db /dev/md1
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
[root@centos1vm ~]# mdadm -Db /dev/md2
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=cb67bc06:d32061ea:eda8873f:c15b9fbf
[root@centos1vm ~]#

 

 

To get a quick human-readable overview of a RAID device, use the -Q option:

 

mdadm -Q /dev/md127

 

[root@centos1vm ~]# mdadm -Q /dev/md1
/dev/md1: 1494.00MiB raid5 4 devices, 0 spares. Use mdadm –detail for more detail.
/dev/md1: device 0 in 2 device active raid1 /dev/md/RAID50. Use mdadm –examine for more detail.

[root@centos1vm ~]# mdadm -Q /dev/md2
/dev/md2: 1494.00MiB raid5 4 devices, 0 spares. Use mdadm –detail for more detail.
/dev/md2: device 1 in 2 device active raid1 /dev/md/RAID50. Use mdadm –examine for more detail.

[root@centos1vm ~]# mdadm -Q /dev/md127
/dev/md127: 1492.00MiB raid1 2 devices, 0 spares. Use mdadm –detail for more detail.
[root@centos1vm ~]#

 

 

 

 

Display all Disks

 

you can display a list of all disks on the system with lsblk:

 

 

[root@centos1vm ~]#
[root@centos1vm ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 9G 0 part
├─cs_centos–base-root 253:0 0 8G 0 lvm /
└─cs_centos–base-swap 253:1 0 1G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
├─sdb1 8:17 0 500M 0 part
│ └─md127 9:127 0 1.5G 0 raid10 /RAID10
├─sdb2 8:18 0 500M 0 part
│ └─md127 9:127 0 1.5G 0 raid10 /RAID10
├─sdb3 8:19 0 500M 0 part
│ └─md127 9:127 0 1.5G 0 raid10 /RAID10
├─sdb4 8:20 0 1K 0 part
├─sdb5 8:21 0 500M 0 part
│ └─md127 9:127 0 1.5G 0 raid10 /RAID10
├─sdb6 8:22 0 500M 0 part
├─sdb7 8:23 0 500M 0 part
├─sdb8 8:24 0 500M 0 part
├─sdb9 8:25 0 500M 0 part
│ └─md1 9:1 0 1.5G 0 raid5
│ └─md125 9:125 0 1.5G 0 raid1 /RAID50
├─sdb10 8:26 0 500M 0 part
│ └─md1 9:1 0 1.5G 0 raid5
│ └─md125 9:125 0 1.5G 0 raid1 /RAID50
├─sdb11 8:27 0 500M 0 part
│ └─md1 9:1 0 1.5G 0 raid5
│ └─md125 9:125 0 1.5G 0 raid1 /RAID50
├─sdb12 8:28 0 500M 0 part
│ └─md1 9:1 0 1.5G 0 raid5
│ └─md125 9:125 0 1.5G 0 raid1 /RAID50
├─sdb13 8:29 0 500M 0 part
│ └─md2 9:2 0 1.5G 0 raid5
│ └─md125 9:125 0 1.5G 0 raid1 /RAID50
├─sdb14 8:30 0 500M 0 part
│ └─md2 9:2 0 1.5G 0 raid5
│ └─md125 9:125 0 1.5G 0 raid1 /RAID50
├─sdb15 8:31 0 500M 0 part
│ └─md2 9:2 0 1.5G 0 raid5
│ └─md125 9:125 0 1.5G 0 raid1 /RAID50
├─sdb16 259:0 0 500M 0 part
│ └─md2 9:2 0 1.5G 0 raid5
│ └─md125 9:125 0 1.5G 0 raid1 /RAID50
├─sdb17 259:1 0 500M 0 part
│ └─md127 9:127 0 1.5G 0 raid10 /RAID10
├─sdb18 259:2 0 500M 0 part
│ └─md127 9:127 0 1.5G 0 raid10 /RAID10
└─sdb19 259:3 0 500M 0 part
sr0 11:0 1 9.2G 0 rom
[root@centos1vm ~]#

 

 

 

Adding Capacity to a RAID

 

 

Adding a new device to a mirror raid won’t change the size of the raid. This is because the new device will store an extra copy of the data and there won’t be any extra net space created.

 

But adding a device to a parity array will normally increase the space available.

 

 

For example, if we have a 3 by 4TB using raid-5, then that gives us an 8TB sized raid.

 

Adding a fourth 4TB will give us a 12TB raid. But note that we have to run the resize process in order to utilize it.

 

the syntax is

mdadm --add /dev/<md device> /dev/<disk you are adding>
mdadm --grow --raid-devices=<expanded total no of devices> /dev/<md device>

 

example: 

[root@centos1vm ~]# mdadm –add /dev/md/RAID10 /dev/sdb17
mdadm: added /dev/sdb17
[root@centos1vm ~]#

 

[root@centos1vm ~]# mdadm –grow –raid-devices=5 /dev/md/RAID10
[root@centos1vm ~]#

 

 

To allow recovery after unexpected power failure, an additional option –backup-file= can be specified. Make sure this file is on a different disk!

 

mdadm –grow –raid-devices=4 –backup-file=/root/grow_md0.bak /dev/md0

 

 

 
so we now have 5 disks in this array:
 
 
watch cat /proc/mdstat
 
 
md127 : active raid10 sdb17[4] sdb5[3] sdb2[1] sdb3[2] sdb1[0]
      1274880 blocks super 1.2 512K chunks 2 near-copies [5/5] [UUUUU]

 

next do an unmount:

 

umount /dev/md/RAID10

 

 

[root@centos1vm ~]# umount /dev/md/RAID10
[root@centos1vm ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 653280 0 653280 0% /dev
tmpfs 672308 0 672308 0% /dev/shm
tmpfs 672308 8884 663424 2% /run
tmpfs 672308 0 672308 0% /sys/fs/cgroup
/dev/mapper/cs_centos–base-root 8374272 3198204 5176068 39% /
/dev/sda1 1038336 356816 681520 35% /boot
/dev/md125 1470992 881312 496908 64% /RAID50
tmpfs 134460 0 134460 0% /run/user/0
[root@centos1vm ~]#

 

 

followed by a file integrity check:

 

e2fsck -f /dev/md127

 

then resize filesystem:

 

resize2fs /dev/md127

 

 

[root@centos1vm ~]# resize2fs /dev/md127
resize2fs 1.45.6 (20-Mar-2020)
Please run ‘e2fsck -f /dev/md127’ first.

 

[root@centos1vm ~]# e2fsck -f /dev/md127
e2fsck 1.45.6 (20-Mar-2020)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Inode 2 ref count is 5, should be 4. Fix<y>? yes
Pass 5: Checking group summary information
Inode bitmap differences: -(1121–2189)
Fix<y>? yes

 

/dev/md127: ***** FILE SYSTEM WAS MODIFIED *****
/dev/md127: 1120/63744 files (1.1% non-contiguous), 118303/254976 blocks
[root@centos1vm ~]#
[root@centos1vm ~]#

 

 

 

After mdadm completes growing the array it does not automatically modify /etc/mdadm.conf.

 

This will mean mdadm will not be able to locate the grown device /dev/md0.

 

So you next need to edit /etc/mdadm.conf and correct the num-devices information set for your raid.

 

 

 

[root@centos1vm etc]#
[root@centos1vm etc]# mdadm –detail –scan
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=afc89f2b:03016129:218a6a68:2dd2e6e5
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
ARRAY /dev/md/RAID10 metadata=1.2 name=centos1vm:RAID10 UUID=60ae2e29:c1621782:65c1b59c:67c9d0b4
INACTIVE-ARRAY /dev/md126 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md/RAID50 metadata=1.2 name=centos1vm:RAID50 UUID=66470135:4f0bd96a:357fe54e:2baa3a7b
[root@centos1vm etc]# blkid /dev/md/RAID10
/dev/md/RAID10: UUID=”7e92383a-e2fb-48a1-8602-722d5c394158″ BLOCK_SIZE=”4096″ TYPE=”ext4″
[root@centos1vm etc]#

 

taking the blkid UUID output as shown above, put the new UUID in the /etc/mdadm.conf:

 

7e92383a-e2fb-48a1-8602-722d5c394158

 

so it now looks like this:

 

[root@centos1vm etc]# mdadm –detail –scan
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=afc89f2b:03016129:218a6a68:2dd2e6e5
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
ARRAY /dev/md/RAID10 metadata=1.2 name=centos1vm:RAID10 UUID=60ae2e29:c1621782:65c1b59c:67c9d0b4
INACTIVE-ARRAY /dev/md126 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md/RAID50 metadata=1.2 name=centos1vm:RAID50 UUID=66470135:4f0bd96a:357fe54e:2baa3a7b
[root@centos1vm etc]#

 

so it now looks like this: 

 

[root@centos1vm etc]# mdadm –detail /dev/md/RAID10

/dev/md/RAID10:
Version : 1.2
Creation Time : Sat Apr 9 12:10:16 2022
Raid Level : raid10
Array Size : 1274880 (1245.00 MiB 1305.48 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 5
Total Devices : 5
Persistence : Superblock is persistent

Update Time : Mon Apr 11 17:51:54 2022
State : clean
Active Devices : 5
Working Devices : 5
Failed Devices : 0
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 60ae2e29:c1621782:65c1b59c:67c9d0b4
Events : 59

Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 18 1 active sync /dev/sdb2
2 8 19 2 active sync /dev/sdb3
3 8 21 3 active sync /dev/sdb5
4 259 1 4 active sync /dev/sdb17
[root@centos1vm etc]#

 

 

you can see the new disk sdb17 listed.

 

 

finally do, 

root@centos1vm etc]# mdadm –assemble –scan

 

and then remount:

 

and then remount:

mount /dev/md127 /RAID10

 

df

/dev/md127 987480 440788 479316 48% /RAID10
[root@centos1vm etc]#

 

 

Adding More Disks 

 

a recap…

 

 

ADD – then grow – then resize!

 

 

mdadm –add /dev/md/RAID10 /dev/sdb18

 

mdadm –grow –raid-devices=6 /dev/md/RAID10

 

umount /dev/md/RAID10

 

e2fsck -f /dev/md127

 

resize2fs /dev/md127

 

 

[root@centos1vm ~]# mdadm –grow –raid-devices=6 /dev/md/RAID10
mdadm: Need 1 spare to avoid degraded array, and only have 0.
Use –force to over-ride this check.

 

[root@centos1vm ~]# mdadm –add /dev/md/RAID10 /dev/sdb18
mdadm: added /dev/sdb18

 

[root@centos1vm ~]# mdadm –grow –raid-devices=6 /dev/md/RAID10

 

[root@centos1vm ~]# umount /dev/md/RAID10

 

[root@centos1vm ~]# e2fsck -f /dev/md127
e2fsck 1.45.6 (20-Mar-2020)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/md127: 1120/63744 files (1.1% non-contiguous), 118303/254976 blocks

 

[root@centos1vm ~]# resize2fs /dev/md127
resize2fs 1.45.6 (20-Mar-2020)
Resizing the filesystem on /dev/md127 to 382464 (4k) blocks.
The filesystem on /dev/md127 is now 382464 (4k) blocks long.

[root@centos1vm ~]#

 

then edit the mdadm.conf for the new UUID for the expanded raid:

 

old UUIID:

 

[root@centos1vm ~]# mdadm –detail –scan
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=afc89f2b:03016129:218a6a68:2dd2e6e5
ARRAY /dev/md/RAID10 metadata=1.2 name=centos1vm:RAID10 UUID=60ae2e29:c1621782:65c1b59c:67c9d0b4
INACTIVE-ARRAY /dev/md126 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md/RAID50 metadata=1.2 name=centos1vm:RAID50 UUID=66470135:4f0bd96a:357fe54e:2baa3a7b
[root@centos1vm ~]#

 

new UUID:

 

[root@centos1vm ~]# blkid /dev/md/RAID10
/dev/md/RAID10: UUID=”7e92383a-e2fb-48a1-8602-722d5c394158″ BLOCK_SIZE=”4096″ TYPE=”ext4″
[root@centos1vm ~]#

 

change this to the new UUID:
7e92383a-e2fb-48a1-8602-722d5c394158

 

[root@centos1vm ~]# nano /etc/mdadm.conf
[root@centos1vm ~]#

 

[root@centos1vm ~]#
[root@centos1vm ~]# cat /etc/mdadm.conf
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=afc89f2b:03016129:218a6a68:2dd2e6e5
ARRAY /dev/md/RAID10 metadata=1.2 name=centos1vm:RAID10 UUID=7e92383a-e2fb-48a1-8602-722d5c394158
INACTIVE-ARRAY /dev/md126 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md/RAID50 metadata=1.2 name=centos1vm:RAID50 UUID=66470135:4f0bd96a:357fe54e:2baa3a7b
[root@centos1vm ~]#

 

 

check with:

 

[root@centos1vm ~]# mdadm –detail /dev/md/RAID10
mdadm: Unknown keyword INACTIVE-ARRAY
/dev/md/RAID10:
Version : 1.2
Creation Time : Sat Apr 9 12:10:16 2022
Raid Level : raid10
Array Size : 1529856 (1494.00 MiB 1566.57 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 6
Total Devices : 6
Persistence : Superblock is persistent

Update Time : Mon Apr 11 18:21:46 2022
State : clean
Active Devices : 6
Working Devices : 6
Failed Devices : 0
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 60ae2e29:c1621782:65c1b59c:67c9d0b4
Events : 99

Number Major Minor RaidDevice State
0 8 17 0 active sync set-A /dev/sdb1
1 8 18 1 active sync set-B /dev/sdb2
2 8 19 2 active sync set-A /dev/sdb3
3 8 21 3 active sync set-B /dev/sdb5
4 259 1 4 active sync set-A /dev/sdb17
5 259 2 5 active sync set-B /dev/sdb18
[root@centos1vm ~]#

 

 

then remount, and you can see that as we now have 6 disks, we now have 1.5G available instead of 1GB:

 

[root@centos1vm ~]# mount /dev/md/RAID10 /RAID10

 

[root@centos1vm ~]#
[root@centos1vm ~]#
[root@centos1vm ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 638M 0 638M 0% /dev
tmpfs 657M 0 657M 0% /dev/shm
tmpfs 657M 8.7M 648M 2% /run
tmpfs 657M 0 657M 0% /sys/fs/cgroup
/dev/mapper/cs_centos–base-root 8.0G 3.1G 5.0G 39% /
/dev/sda1 1014M 349M 666M 35% /boot
/dev/md125 1.5G 861M 486M 64% /RAID50
tmpfs 132M 0 132M 0% /run/user/0
/dev/md127 1.5G 431M 933M 32% /RAID10
[root@centos1vm ~]#

 

 

 

 

To start a RAID

 

 

To start all arrays defined in the config file /etc/mdadm.conf or /proc/mdstat, type:

 

mdadm –assemble –scan

 

To start a specific array, you can pass it in as an argument to mdadm –assemble:

 

mdadm –assemble /dev/md0

 

This should work if the raid is defined in the configuration file.

 

If the correct definition for the raid is missing from the config file, the raid can still be started by specifying the component disk devices:

 

mdadm –assemble /dev/md0 /dev/sda /dev/sdb /dev/sdc /dev/sdd

 

Once the raid is assembled, it can be mounted as usual:

 

eg

 

mount /dev/md0 /mnt/md0

 

The raid should now be accessible at the mount point.

 

 

 

Adding a Spare Device to a Raid

 

Spare disks or devices can be added to any raid that offer redundancy (such as RAID 1, 5, 6, or 10).

 

The spare disk will not be actively used by the raid unless an active device fails. When this happens, the raid will resync the data to the spare drive to repair the array to full health.

 

Spares cannot be added to non-redundant raids (RAID 0) because the array will not survive the failure of a drive.

 

 

 

To add a spare, use the mdadm –add command:

eg

 

mdadm /dev/md0 –add /dev/sde

 

Provided the raid is not in a degraded state, the new device will be added as a spare.

 

If the device is currently degraded, the resync operation will immediately begin and will utilize the spare disk just added to replace the faulty drive.

 

 

After you add a spare, update the configu file to include the newly added disk:

 

in /etc/mdadm/mdadm.conf and append your current configuration:

 

 

mdadm –detail –brief /dev/md0 | sudo tee -a /etc/mdadm/mdadm.conf

 

 

Increasing the Number of Active Disks in a RAID

 

You can enlarge a RAID by increasing the number of active disks within the array.

 

The exact procedure will depends slightly on the RAID level of the array.

 

For RAID 1 or 10

 

First add the new disk as a spare:

 

mdadm /dev/md0 –add /dev/sde

 

Then find out the current number of RAID devices in the array:

 

mdadm –detail /dev/md0

 

 

Next reconfigure the array to include an additional active device. This spare will be used to meet the extra drive requirement:

 

mdadm –grow –raid-devices=3 /dev/md0

 

The array will now reconfigure with an additional active disk.

 

You can view the current syncing progress with:

 

cat /proc/mdstat

 

You can continue using the raid while the process completes.

 

 

For RAID 5 or 6

 

Add the new device as a spare, as shown in the previous example for Raid 1/10:

 

mdadm /dev/md0 –add /dev/sde

 

Ascertain the current number of RAID devices in the array:

 

mdadm –detail /dev/md0

 

Next, reconfigure the array to have an additional active disk. This spare will be used to satisfy the extra drive requirement.

 

When growing a RAID 5 or RAID 6 array, make sure you include an additional option called –backup-file.

 

This should point to a location outside the raid where a backup file containing critical information will be stored during the grow process, after which it is automatically deleted. In the event of something going wrong, the data contained in the backup file is used to rebuild the raid to its original pre-expansion state.

 

mdadm –grow –raid-devices=4 –backup-file=/root/md0_grow.bak /dev/md0

 

The raid will now reconfigure with the additional active disk.

 

To view the progress of syncing the data in real-time type:

 

cat /proc/mdstat

 

You can continue using the raid during this process.

 

Finally, once the grow process has completed, you MUST then run a resize filesystem command.

 

This is necessary in order to expand the filesystem on the raid to utilize the additional space:

 

eg

 

resize2fs /dev/md0

 

The expanded raid is now complete and ready for full use.

 

 

 

To remove a raid disk

 

For a device to be removed, first mark it as “failed” within the raid.

 

You can check if there is a failed device by using mdadm –detail:

 

mdadm –detail /dev/md0

 

If you need to remove a drive that does not have a problem at present, first manually mark it as failed with the –fail option:

 

mdadm /dev/md0 –fail /dev/sdc

 

Once the device has the status “failed”, it can then be removed from the raid using mdadm –remove:

 

mdadm /dev/md0 –remove /dev/sdc

 

 

You can then replace it with a new drive, using the same mdadm –add command that is used to add a spare:

 

mdadm /dev/md0 –add /dev/sdd

 

 

To delete an entire RAID

 

Quick overview:

 

 

To Delete a RAID:

 

Edit /etc/fstab and delete the line for the raid mount point.

 

Edit /etc/mdadm/mdadm.conf and delete the lines you added earlier via mdadm | tee.

 

Unmount the volume: umount <mountpoint>

 

Wipe the ext4 filesystem: sudo wipefs –all –force /dev/<md device>

 

Stop the RAID volume: sudo mdadm –stop /dev/<md device>

 

 

Zero the superblock on all the drives:

 

mdadm –zero-superblock /dev/<disk1> <disk2> ….etc

 

 

 

 

To destroy a raid, including all data contained within, first stop the array.

 

First, unmount the filesystem:

 

umount /mnt/md0

 

Next, stop the array:

 

mdadm –stop /dev/md0

 

Then delete the raid itself with the –remove command, specifying the RAID device:

 

mdadm –remove /dev/md0

 

Make sure you specify the correct raid device!

 

Once the array itself is removed, you should use mdadm –zero-superblock on each of the component devices.

 

This erases the md superblock, which is a header used by mdadm to assemble and manage the disks in a raid.

 

If this is still present, it can cause problems when trying to reuse the disk for other purposes.

To check if a superblock for a raid is still present on the device, use:

 

 

lsblk –fs

 

and see the column FS-TYPE

 

if this shows

 

linux_raid_member

 

then you need to erase it:

 

eg for each disk:

 

mdadm –zero-superblock /dev/sda /dev/sdb /dev/sdc

 

 

Other important cleaning up measures when deleting a raid:

 

Don’t forget also to remove any definition for the deleted raid in the fstab file, else this can cause a reboot of the machine to hang!

 

Also remove any definition of the deleted raid from the mdadm.conf file

 

Finally, update the initramfs by typing:

 

update-initramfs -u

 

This will remove the deleted raid device from the boot environment.

 

 

Continue Reading

RAID50 Lab: Creating a RAID50 Using MDADM

Creating a RAID50

 

on virtual machine centos1vm

 

this is 2 x RAID5 configs in a RAID1 configuration.

 

so we have 6 disks for the 2 raids, plus one spare for each

 

sdb9 10,11,12

 

sdb13,14,15,16

 

each disk is 500MB

 

we will have 3 x 500MB = 1.5GB total net disk storage available

 

so we need the following commands:

 

IMPORTANT NOTE OUR RAID DEVICE DESIGNATION :

 

we will use md1, md2 and md3  as we are already using md0 for our existing raid10 on this machine.

 

 

DON’T MIX UP YOUR RAID DEVICES!

 

Number Major Minor RaidDevice State
4 8 22 0 active sync set-A /dev/sdb6
6 8 18 1 active sync set-B /dev/sdb2
5 8 19 2 active sync set-A /dev/sdb3
7 8 21 3 active sync set-B /dev/sdb5

8 8 23 – spare /dev/sdb7
9 8 24 – spare /dev/sdb8

 

 

since I have 2 spares defined for md0 we have to use disks starting from sdb9 – see above.

 

we create 2 raid5 arrays, then we combine them into a raid 1:  md1 and md2

 

the combined raid will be md3 –name RAID50

 

 

the new raid device names are:

 

md1:

 

centos1vm:RAID5a

 

md2:

 

centos1vm:RAID5b

 

currently we have:

 

 [root@centos1vm ~]# cat /proc/mdstat

md0 : active raid10 sdb8[9](S) sdb7[8](S) sdb6[4] sdb5[7] sdb3[5] sdb2[6]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

unused devices: <none>
[root@centos1vm ~]#

 

so our designations are:

 

md1: centos1vm:RAID5a

md2: centos1vm:RAID5b

md3: centos1vm:RAID50

 

create the directories /RAID5a, /RAID5b and /RAID50

actually in practice the RAID5a and RAID5b directories are not needed, since we will mount on RAID50 only

 

Disklabel type: dos
Disk identifier: 0xf513fbff

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1026047 1024000 500M fd Linux raid autodetect
/dev/sdb2 1026048 2050047 1024000 500M fd Linux raid autodetect
/dev/sdb3 2050048 3074047 1024000 500M fd Linux raid autodetect
/dev/sdb4 3074048 20971519 17897472 8.5G 5 Extended
/dev/sdb5 3076096 4100095 1024000 500M fd Linux raid autodetect
/dev/sdb6 4102144 5126143 1024000 500M fd Linux raid autodetect
/dev/sdb7 5128192 6152191 1024000 500M fd Linux raid autodetect
/dev/sdb8 6154240 7178239 1024000 500M fd Linux raid autodetect
/dev/sdb9 7180288 8204287 1024000 500M fd Linux raid autodetect
/dev/sdb10 8206336 9230335 1024000 500M fd Linux raid autodetect
/dev/sdb11 9232384 10256383 1024000 500M fd Linux raid autodetect
/dev/sdb12 10258432 11282431 1024000 500M fd Linux raid autodetect
/dev/sdb13 11284480 12308479 1024000 500M fd Linux raid autodetect
/dev/sdb14 12310528 13334527 1024000 500M fd Linux raid autodetect
/dev/sdb15 13336576 14360575 1024000 500M fd Linux raid autodetect
/dev/sdb16 14362624 15386623 1024000 500M fd Linux raid autodetect
/dev/sdb17 15388672 16412671 1024000 500M fd Linux raid autodetect
/dev/sdb18 16414720 17438719 1024000 500M fd Linux raid autodetect
/dev/sdb19 17440768 18464767 1024000 500M fd Linux raid autodetect

 

[root@centos1vm ~]# cat /proc/mdstat
Personalities : [raid10]
md0 : active raid10 sdb8[9](S) sdb7[8](S) sdb3[5] sdb2[6] sdb5[7] sdb6[4]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

unused devices: <none>
[root@centos1vm ~]#

 

 

so we can use from sda9 onwards: 4 each raid – ie 3 active disks plus 1 spare:

 

mdadm –create /dev/md1 –level raid5 –name RAID5a –raid-disks 4 /dev/sdb9 /dev/sdb10 /dev/sdb11 /dev/sdb12

 

mdadm –create /dev/md2 –level raid5 –name RAID5b –raid-disks 4 /dev/sdb13 /dev/sdb14 /dev/sdb15 /dev/sdb16

 

 

[root@centos1vm ~]# cat /proc/mdstat
Personalities : [raid10]
md0 : active raid10 sdb8[9](S) sdb7[8](S) sdb3[5] sdb2[6] sdb5[7] sdb6[4]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

unused devices: <none>
[root@centos1vm ~]# mdadm –create /dev/md1 –level raid5 –name RAID5a –raid-disks 4 /dev/sdb9 /dev/sdb10 /dev/sdb11 /dev/sdb12
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
[root@centos1vm ~]# mdadm –create /dev/md2 –level raid5 –name RAID5b –raid-disks 4 /dev/sdb13 /dev/sdb14 /dev/sdb15 /dev/sdb16
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.
[root@centos1vm ~]# cd ..

 

[root@centos1vm /]# ls
bin boot dev disk etc home lib lib64 media mnt opt proc RAID10 RAID50 RAID5a RAID5b root run sbin srv sys tmp usr var
[root@centos1vm /]#

 

next:

 

[root@centos1vm /]# cat /proc/mdstat
Personalities : [raid10] [raid6] [raid5] [raid4]
md2 : active raid5 sdb16[4] sdb15[2] sdb14[1] sdb13[0]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

md127 : inactive md1[0](S)
1527808 blocks super 1.2

md1 : active raid5 sdb12[4] sdb11[2] sdb10[1] sdb9[0]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

md0 : active raid10 sdb8[9](S) sdb7[8](S) sdb3[5] sdb2[6] sdb5[7] sdb6[4]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

unused devices: <none>
[root@centos1vm /]#

 

 

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

 

[root@centos1vm /]# cat /etc/mdadm.conf
MAILADDR root@localhost
ARRAY /dev/md0 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md0 metadata=1.2 spares=2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
INACTIVE-ARRAY /dev/md127 metadata=1.2 name=centos1vm:RAID50 UUID=0673461d:7c532d23:00f07114:99cdf7f3
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=cb67bc06:d32061ea:eda8873f:c15b9fbf
[root@centos1vm /]#

 

 

mkfs.ext4 /dev/disk/by-id/md-name-centos1vm:RAID5a

 

 

[root@centos1vm /]# mdadm –stop /dev/md127
mdadm: Unknown keyword INACTIVE-ARRAY
mdadm: stopped /dev/md127
[root@centos1vm /]#

[root@centos1vm /]# mkfs.ext4 /dev/disk/by-id/md-name-centos1vm:RAID5a
mke2fs 1.45.6 (20-Mar-2020)
/dev/disk/by-id/md-name-centos1vm:RAID5a contains a linux_raid_member file system labelled ‘centos1vm:RAID50’
Proceed anyway? (y,N) Y
Creating filesystem with 382464 4k blocks and 95616 inodes
Filesystem UUID: ea9122bc-acec-465e-ad76-687b977bd7ff
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

[root@centos1vm /]# mkfs.ext4 /dev/disk/by-id/md-name-centos1vm:RAID5b
mke2fs 1.45.6 (20-Mar-2020)
/dev/disk/by-id/md-name-centos1vm:RAID5b contains a ext4 file system
last mounted on Sat Apr 9 00:20:10 2022
Proceed anyway? (y,N) Y
Creating filesystem with 382464 4k blocks and 95616 inodes
Filesystem UUID: a54bfabb-22f2-466e-82d6-52c06c72d065
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

 

 

then create the raid50 using md1 and md2:

 

[root@centos1vm /]# mdadm –create /dev/md3 –level raid1 –name RAID50 –raid-disks 2 /dev/md1 /dev/md2
mdadm: Unknown keyword INACTIVE-ARRAY
mdadm: /dev/md1 appears to contain an ext2fs file system
size=1529856K mtime=Thu Jan 1 01:00:00 1970
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store ‘/boot’ on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
–metadata=0.90
mdadm: /dev/md2 appears to contain an ext2fs file system
size=1529856K mtime=Thu Jan 1 01:00:00 1970
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md3 started.
[root@centos1vm /]#

 

 

 

 

check with:

 

 

[root@centos1vm /]# cat /proc/mdstat
Personalities : [raid10] [raid6] [raid5] [raid4] [raid1]
md3 : active raid1 md2[1] md1[0]
1527808 blocks super 1.2 [2/2] [UU]

md2 : active raid5 sdb16[4] sdb15[2] sdb14[1] sdb13[0]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

md1 : active raid5 sdb12[4] sdb11[2] sdb10[1] sdb9[0]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

md0 : active raid10 sdb8[9](S) sdb7[8](S) sdb3[5] sdb2[6] sdb5[7] sdb6[4]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

unused devices: <none>
[root@centos1vm /]#

 

 

[root@centos1vm /]# mkfs.ext4 /dev/md3
mke2fs 1.45.6 (20-Mar-2020)
/dev/md3 contains a ext4 file system
last mounted on Fri Apr 8 19:23:05 2022
Proceed anyway? (y,N) Y
Creating filesystem with 381952 4k blocks and 95616 inodes
Filesystem UUID: e9bfd7c1-8788-4050-a7ba-5aa8674815ac
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

 

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

 

[root@centos1vm /]#

 

 

[root@centos1vm /]# mount /dev/md3 /RAID50
[root@centos1vm /]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 653280 0 653280 0% /dev
tmpfs 672308 0 672308 0% /dev/shm
tmpfs 672308 8892 663416 2% /run
tmpfs 672308 0 672308 0% /sys/fs/cgroup
/dev/mapper/cs_centos–base-root 8374272 3195516 5178756 39% /
/dev/sda1 1038336 356816 681520 35% /boot
/dev/md0 987480 879072 41032 96% /RAID10
tmpfs 134460 0 134460 0% /run/user/0
/dev/md3 1470992 4488 1373732 1% /RAID50
[root@centos1vm /]#

 

Success!

 

disk total net

 

capacity is also correct ie 50% of raid5a and raid5b 1.5GB each : 3gb/2 = 1.5GB for md3

 

[root@centos1vm ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 638M 0 638M 0% /dev
tmpfs 657M 0 657M 0% /dev/shm
tmpfs 657M 8.7M 648M 2% /run
tmpfs 657M 0 657M 0% /sys/fs/cgroup
/dev/mapper/cs_centos–base-root 8.0G 3.1G 5.0G 39% /
/dev/sda1 1014M 349M 666M 35% /boot
/dev/md0 965M 859M 41M 96% /RAID10
tmpfs 132M 0 132M 0% /run/user/0
/dev/md3 1.5G 471M 876M 35% /RAID50
[root@centos1vm ~]#

 

[root@centos1vm ~]# cat /proc/mdstat
Personalities : [raid10] [raid6] [raid5] [raid4] [raid1]
md3 : active raid1 md2[1] md1[0]
1527808 blocks super 1.2 [2/2] [UU]

md2 : active raid5 sdb16[4] sdb15[2] sdb14[1] sdb13[0]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

md1 : active raid5 sdb12[4] sdb11[2] sdb10[1] sdb9[0]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

md0 : active raid10 sdb8[9](S) sdb7[8](S) sdb3[5] sdb2[6] sdb5[7] sdb6[4]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

unused devices: <none>
[root@centos1vm ~]#

 

root@centos1vm ~]# cat /etc/mdadm.conf
MAILADDR root@localhost
ARRAY /dev/md0 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md0 metadata=1.2 spares=2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
INACTIVE-ARRAY /dev/md127 metadata=1.2 name=centos1vm:RAID50 UUID=0673461d:7c532d23:00f07114:99cdf7f3
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=cb67bc06:d32061ea:eda8873f:c15b9fbf
[root@centos1vm ~]#

 

[root@centos1vm ~]# mdadm –detail –scan
mdadm: Unknown keyword INACTIVE-ARRAY
ARRAY /dev/md0 metadata=1.2 spares=2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=cb67bc06:d32061ea:eda8873f:c15b9fbf
ARRAY /dev/md3 metadata=1.2 name=centos1vm:RAID50 UUID=66470135:4f0bd96a:357fe54e:2baa3a7b
[root@centos1vm ~]#

 

 

This is how it now looks:

 

 

[root@centos1vm ~]# mdadm -D /dev/md127
/dev/md127:
Version : 1.2
Creation Time : Sat Apr 9 00:48:11 2022
Raid Level : raid1
Array Size : 1527808 (1492.00 MiB 1564.48 MB)
Used Dev Size : 1527808 (1492.00 MiB 1564.48 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

 

Update Time : Sat Apr 9 11:53:15 2022
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

 

Consistency Policy : resync

 

Name : centos1vm:RAID50 (local to host centos1vm)
UUID : 66470135:4f0bd96a:357fe54e:2baa3a7b
Events : 17

 

Number Major Minor RaidDevice State
0 9 1 0 active sync /dev/md1
1 9 2 1 active sync /dev/md2
[root@centos1vm ~]#

 

 

the above is actually a RAID50: consisting of two RAID5s (md1 and md2 respectively)

 

see below:

 

 

[root@centos1vm ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Sat Apr 9 00:41:10 2022
Raid Level : raid5
Array Size : 1529856 (1494.00 MiB 1566.57 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

 

 

Update Time : Sat Apr 9 11:53:15 2022
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

 

Layout : left-symmetric
Chunk Size : 512K

 

 

Consistency Policy : resync

 

Name : centos1vm:RAID5a (local to host centos1vm)
UUID : 57784eb2:7d894249:e368bbd6:4fef82a1
Events : 20

 

Number Major Minor RaidDevice State
0 8 25 0 active sync /dev/sdb9
1 8 26 1 active sync /dev/sdb10
2 8 27 2 active sync /dev/sdb11
4 8 28 3 active sync /dev/sdb12

 

[root@centos1vm ~]# mdadm -D /dev/md2
/dev/md2:
Version : 1.2
Creation Time : Sat Apr 9 00:41:25 2022
Raid Level : raid5
Array Size : 1529856 (1494.00 MiB 1566.57 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

 

 

Update Time : Sat Apr 9 11:53:15 2022
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

 

 

Layout : left-symmetric
Chunk Size : 512K

 

Consistency Policy : resync

 

 

Name : centos1vm:RAID5b (local to host centos1vm)
UUID : cb67bc06:d32061ea:eda8873f:c15b9fbf

Events : 20

 

 

Number Major Minor RaidDevice State
0 8 29 0 active sync /dev/sdb13
1 8 30 1 active sync /dev/sdb14
2 8 31 2 active sync /dev/sdb15
4 259 0 3 active sync /dev/sdb16
[root@centos1vm ~]#

 

 

Our /etc/fstab:

 

 

 

# /etc/fstab
# Created by anaconda on Sun Apr 18 15:57:25 2021
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk/’.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run ‘systemctl daemon-reload’ to update systemd
# units generated from this file.
#
/dev/mapper/cs_centos–base-root / xfs defaults 0 0
UUID=8a1e22d6-888d-416f-b186-e24993c450ae /boot xfs defaults 0 0
/dev/mapper/cs_centos–base-swap none swap defaults 0 0

#/dev/disk/by-id/md-name-centos1vm:RAID10 /RAID10 ext4 defaults 1 1

 

#/dev/disk/by-id/md-name-centos1vm:RAID5a /RAID5a ext4 defaults 1 1
#/dev/disk/by-id/md-name-centos1vm:RAID5b /RAID5b ext4 defaults 1 1
#/dev/disk/by-id/md-name-centos1vm:RAID50 /RAID50 ext4 defaults 1 1

UUID=e9bfd7c1-8788-4050-a7ba-5aa8674815ac /RAID50 ext4 defaults 0 0
[root@centos1vm ~]#

 

 

 

 

and our /etc/mdadm.conf: 

 

 

 

[root@centos1vm ~]# cat /etc/mdadm.conf
MAILADDR root@localhost
ARRAY /dev/md0 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md0 metadata=1.2 spares=2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
#ARRAY /dev/md127 metadata=1.2 name=centos1vm:RAID50 UUID=0673461d:7c532d23:00f07114:99cdf7f3
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=cb67bc06:d32061ea:eda8873f:c15b9fbf

[root@centos1vm ~]#

 

 

 

 

We now have the following config after defining filesystem UUIDs for the RAIDs into the /etc/fstab:

 

basically the mdadm system creates its own MD devices each time . not using the definitions displayed with df!

 

 

UUID=8a1e22d6-888d-416f-b186-e24993c450ae /boot xfs defaults 0 0
/dev/mapper/cs_centos–base-swap none swap defaults 0 0

 

 

#/dev/disk/by-id/md-name-centos1vm:RAID10 /RAID10 ext4 defaults 1 1

#/dev/disk/by-id/md-name-centos1vm:RAID5a /RAID5a ext4 defaults 1 1
#/dev/disk/by-id/md-name-centos1vm:RAID5b /RAID5b ext4 defaults 1 1
#/dev/disk/by-id/md-name-centos1vm:RAID50 /RAID50 ext4 defaults 1 1

 

UUID=7e92383a-e2fb-48a1-8602-722d5c394158 /RAID10 ext4 defaults 0 0
UUID=e9bfd7c1-8788-4050-a7ba-5aa8674815ac /RAID50 ext4 defaults 0 0

 

[root@centos1vm ~]# cat /etc/mdadm.conf
ARRAY /dev/md/RAID10 metadata=1.2 name=centos1vm:RAID10 UUID=60ae2e29:c1621782:65c1b59c:67c9d0b4
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
INACTIVE-ARRAY /dev/md126 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=afc89f2b:03016129:218a6a68:2dd2e6e5
ARRAY /dev/md/RAID50 metadata=1.2 name=centos1vm:RAID50 UUID=66470135:4f0bd96a:357fe54e:2baa3a7b

 

[root@centos1vm ~]# mdadm –detail –scan
mdadm: Unknown keyword INACTIVE-ARRAY
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=afc89f2b:03016129:218a6a68:2dd2e6e5
ARRAY /dev/md/RAID10 metadata=1.2 name=centos1vm:RAID10 UUID=60ae2e29:c1621782:65c1b59c:67c9d0b4
INACTIVE-ARRAY /dev/md126 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md/RAID50 metadata=1.2 name=centos1vm:RAID50 UUID=66470135:4f0bd96a:357fe54e:2baa3a7b

 

 

[root@centos1vm ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 653280 0 653280 0% /dev
tmpfs 672308 0 672308 0% /dev/shm
tmpfs 672308 8892 663416 2% /run
tmpfs 672308 0 672308 0% /sys/fs/cgroup
/dev/mapper/cs_centos–base-root 8374272 3196760 5177512 39% /
/dev/sda1 1038336 356816 681520 35% /boot
/dev/md127 987480 440788 479316 48% /RAID10
/dev/md125 1470992 881312 496908 64% /RAID50
tmpfs 134460 0 134460 0% /run/user/0
[root@centos1vm ~]#

 

 

 

 

 

NOTE how we use different UUIDs for fstab and for mdadm.conf!

 

This is important in order for the system to boot up without hanging

 

 

/etc/fstab:

 

UUID=7e92383a-e2fb-48a1-8602-722d5c394158 /RAID10 ext4 defaults 0 0
UUID=e9bfd7c1-8788-4050-a7ba-5aa8674815ac /RAID50 ext4 defaults 0 0

 

[root@centos1vm by-id]# ll md*
lrwxrwxrwx. 1 root root 11 Apr 9 13:18 md-name-centos1vm:RAID10 -> ../../md127
lrwxrwxrwx. 1 root root 11 Apr 9 13:18 md-name-centos1vm:RAID50 -> ../../md125
lrwxrwxrwx. 1 root root 9 Apr 9 13:18 md-name-centos1vm:RAID5a -> ../../md1
lrwxrwxrwx. 1 root root 9 Apr 9 13:18 md-name-centos1vm:RAID5b -> ../../md2
lrwxrwxrwx. 1 root root 9 Apr 9 13:18 md-uuid-57784eb2:7d894249:e368bbd6:4fef82a1 -> ../../md1
lrwxrwxrwx. 1 root root 11 Apr 9 13:18 md-uuid-60ae2e29:c1621782:65c1b59c:67c9d0b4 -> ../../md127
lrwxrwxrwx. 1 root root 11 Apr 9 13:18 md-uuid-66470135:4f0bd96a:357fe54e:2baa3a7b -> ../../md125
lrwxrwxrwx. 1 root root 9 Apr 9 13:18 md-uuid-afc89f2b:03016129:218a6a68:2dd2e6e5 -> ../../md2
[root@centos1vm by-id]# blkid /dev/md127
/dev/md127: UUID=”7e92383a-e2fb-48a1-8602-722d5c394158″ BLOCK_SIZE=”4096″ TYPE=”ext4″
[root@centos1vm by-id]# blkid /dev/md125
/dev/md125: UUID=”e9bfd7c1-8788-4050-a7ba-5aa8674815ac” BLOCK_SIZE=”4096″ TYPE=”ext4″

 

 

[root@centos1vm by-id]# cat /etc/mdadm.conf
ARRAY /dev/md/RAID10 metadata=1.2 name=centos1vm:RAID10 UUID=60ae2e29:c1621782:65c1b59c:67c9d0b4
ARRAY /dev/md1 metadata=1.2 name=centos1vm:RAID5a UUID=57784eb2:7d894249:e368bbd6:4fef82a1
INACTIVE-ARRAY /dev/md126 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
ARRAY /dev/md2 metadata=1.2 name=centos1vm:RAID5b UUID=afc89f2b:03016129:218a6a68:2dd2e6e5
ARRAY /dev/md/RAID50 metadata=1.2 name=centos1vm:RAID50 UUID=66470135:4f0bd96a:357fe54e:2baa3a7b

 

 

[root@centos1vm by-id]# ll /dev/md/RAID10
lrwxrwxrwx. 1 root root 8 Apr 9 13:18 /dev/md/RAID10 -> ../md127
[root@centos1vm by-id]#

 

 

 

 

[root@centos1vm ~]# mdadm –manage /dev/md125 –fail /dev/md1
mdadm: set /dev/md1 faulty in /dev/md125
[root@centos1vm ~]#
[root@centos1vm ~]#

 

mdadm –manage /dev/md125 –remove /dev/md1

 

[root@centos1vm ~]# mdadm –manage /dev/md125 –remove /dev/md1
mdadm: hot removed /dev/md1 from /dev/md125
[root@centos1vm ~]#

 

mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID50

 

 

[root@centos1vm etc]# mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID50
/dev/disk/by-id/md-name-centos1vm:RAID50:
Version : 1.2
Creation Time : Sat Apr 9 00:48:11 2022
Raid Level : raid1
Array Size : 1527808 (1492.00 MiB 1564.48 MB)
Used Dev Size : 1527808 (1492.00 MiB 1564.48 MB)
Raid Devices : 2
Total Devices : 1
Persistence : Superblock is persistent

Update Time : Sat Apr 9 13:38:41 2022
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

 

Consistency Policy : resync

 

Name : centos1vm:RAID50 (local to host centos1vm)
UUID : 66470135:4f0bd96a:357fe54e:2baa3a7b
Events : 22

 

Number Major Minor RaidDevice State
– 0 0 0 removed
1 9 2 1 active sync /dev/md2
[root@centos1vm etc]#

 

 

mdadm –manage /dev/md125 –add /dev/md1

 

[root@centos1vm etc]# mdadm –manage /dev/md125 –add /dev/md1
mdadm: added /dev/md1
[root@centos1vm etc]#

 

then when we do a cat /proc/mdstat we can see the F – fail status is now gone – we are back to normal:

 

 

[root@centos1vm etc]# cat /proc/mdstat
Personalities : [raid10] [raid6] [raid5] [raid4] [raid1]
md125 : active raid1 md1[2] md2[1]
1527808 blocks super 1.2 [2/2] [UU]

md126 : inactive sdb8[9](S) sdb6[4](S) sdb7[8](S)
1529856 blocks super 1.2

md2 : active raid5 sdb16[4] sdb15[2] sdb13[0] sdb14[1]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

md127 : active raid10 sdb5[3] sdb3[2] sdb2[1] sdb1[0]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

md1 : active raid5 sdb9[0] sdb12[4] sdb11[2] sdb10[1]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

unused devices: <none>
[root@centos1vm etc]#

 

 

check the detail once more, and we see all is once again ok:

 

[root@centos1vm etc]# mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID50
/dev/disk/by-id/md-name-centos1vm:RAID50:
Version : 1.2
Creation Time : Sat Apr 9 00:48:11 2022
Raid Level : raid1
Array Size : 1527808 (1492.00 MiB 1564.48 MB)
Used Dev Size : 1527808 (1492.00 MiB 1564.48 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

 

Update Time : Sat Apr 9 13:41:36 2022
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

 

Consistency Policy : resync

 

Name : centos1vm:RAID50 (local to host centos1vm)
UUID : 66470135:4f0bd96a:357fe54e:2baa3a7b
Events : 41

 

Number Major Minor RaidDevice State
2 9 1 0 active sync /dev/md1
1 9 2 1 active sync /dev/md2
[root@centos1vm etc]#

 

 

[root@centos1vm ~]# mdadm –manage /dev/md125 –fail /dev/md1
mdadm: set /dev/md1 faulty in /dev/md125
[root@centos1vm ~]#
[root@centos1vm ~]#

 

mdadm –manage /dev/md125 –remove /dev/md1

 

[root@centos1vm ~]# mdadm –manage /dev/md125 –remove /dev/md1
mdadm: hot removed /dev/md1 from /dev/md125
[root@centos1vm ~]#

 

mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID50

 

 

[root@centos1vm etc]# mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID50
/dev/disk/by-id/md-name-centos1vm:RAID50:
Version : 1.2
Creation Time : Sat Apr 9 00:48:11 2022
Raid Level : raid1
Array Size : 1527808 (1492.00 MiB 1564.48 MB)
Used Dev Size : 1527808 (1492.00 MiB 1564.48 MB)
Raid Devices : 2
Total Devices : 1
Persistence : Superblock is persistent

 

Update Time : Sat Apr 9 13:38:41 2022
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

 

Consistency Policy : resync

 

Name : centos1vm:RAID50 (local to host centos1vm)
UUID : 66470135:4f0bd96a:357fe54e:2baa3a7b
Events : 22

 

Number Major Minor RaidDevice State
– 0 0 0 removed
1 9 2 1 active sync /dev/md2
[root@centos1vm etc]#

 

 

 

mdadm –manage /dev/md125 –add /dev/md1

 

 

[root@centos1vm etc]# mdadm –manage /dev/md125 –add /dev/md1
mdadm: added /dev/md1
[root@centos1vm etc]#

 

then when we do a cat /proc/mdstat we can see the F – fail status is now gone – we are back to normal:

 

 

[root@centos1vm etc]# cat /proc/mdstat
Personalities : [raid10] [raid6] [raid5] [raid4] [raid1]
md125 : active raid1 md1[2] md2[1]
1527808 blocks super 1.2 [2/2] [UU]

md126 : inactive sdb8[9](S) sdb6[4](S) sdb7[8](S)
1529856 blocks super 1.2

md2 : active raid5 sdb16[4] sdb15[2] sdb13[0] sdb14[1]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

md127 : active raid10 sdb5[3] sdb3[2] sdb2[1] sdb1[0]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

md1 : active raid5 sdb9[0] sdb12[4] sdb11[2] sdb10[1]
1529856 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

 

unused devices: <none>
[root@centos1vm etc]#

 

 

 

check the detail once more, and we see all is once again ok:

 

 

[root@centos1vm etc]# mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID50
/dev/disk/by-id/md-name-centos1vm:RAID50:
Version : 1.2
Creation Time : Sat Apr 9 00:48:11 2022
Raid Level : raid1
Array Size : 1527808 (1492.00 MiB 1564.48 MB)
Used Dev Size : 1527808 (1492.00 MiB 1564.48 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

 

Update Time : Sat Apr 9 13:41:36 2022
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

 

Consistency Policy : resync

 

Name : centos1vm:RAID50 (local to host centos1vm)
UUID : 66470135:4f0bd96a:357fe54e:2baa3a7b
Events : 41

 

Number Major Minor RaidDevice State
2 9 1 0 active sync /dev/md1
1 9 2 1 active sync /dev/md2
[root@centos1vm etc]#

 

 

Continue Reading

RAID10 Lab: RAID Setup and Disk Failure Simulation

These notes document a RAID10 Setup Configuration and 2 Disk Failure Test

 

using Virtual Machine CentOS centoslvm in virt-manager:

 

centos1vm 

 

Create the Disk Storage Space

 

For this example, we use a Virtual Disk and will create partitions on it of 500MB each.

 

 

First I created a new 10GB disk on the centos1vm machine: /dev/sdb 

 

[root@centos1vm ~]# fdisk -l
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x02d6e72f

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 20971519 18872320 9G 8e Linux LVM

Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/cs_centos–base-root: 8 GiB, 8585740288 bytes, 16769024 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/cs_centos–base-swap: 1 GiB, 1073741824 bytes, 2097152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@centos1vm ~]#

 

 

Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): +500M

Created a new partition 1 of type ‘Linux’ and of size 500 MiB.

Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf513fbff

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1026047 1024000 500M 83 Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition ‘Linux’ to ‘Linux raid autodetect’.

Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf513fbff

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1026047 1024000 500M fd Linux raid autodetect

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[root@centos1vm ~]#

 

 

Next, create the RAID Disks. We are using virtual partitions for this. However in a real-life configuration, you will be more likely to be wanting to use physical individual hard drives for this to provide for greater disk failure robustness.

 

I created 10 partitions. 3 physical and 1 extended, disk 4.

 

The remaining partitions are logical partitions within disk 4.

NOTE: we don’t have to have 10 disks for RAID10, only a minimum of 4.

 

I have created additional ones for later use with other raid level configs, and also so we have spares. 

 

Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf513fbff

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1026047 1024000 500M fd Linux raid autodetect
/dev/sdb2 1026048 2050047 1024000 500M fd Linux raid autodetect
/dev/sdb3 2050048 3074047 1024000 500M fd Linux raid autodetect
/dev/sdb4 3074048 20971519 17897472 8.5G 5 Extended
/dev/sdb5 3076096 4100095 1024000 500M fd Linux raid autodetect
/dev/sdb6 4102144 5126143 1024000 500M fd Linux raid autodetect
/dev/sdb7 5128192 6152191 1024000 500M fd Linux raid autodetect
/dev/sdb8 6154240 7178239 1024000 500M fd Linux raid autodetect
/dev/sdb9 7180288 8204287 1024000 500M fd Linux raid autodetect
/dev/sdb10 8206336 9230335 1024000 500M fd Linux raid autodetect
/dev/sdb11 9232384 10256383 1024000 500M fd Linux raid autodetect

Command (m for help): q

[root@centos1vm ~]#
[root@centos1vm ~]#
[root@centos1vm ~]#

 

 

Create the RAID10

 

Create new raid 10 using the partitions we created:

 

First ensure mdadm is installed:

 

yum install mdadm -y

 

[root@centos1vm ~]#
[root@centos1vm ~]#
[root@centos1vm ~]#
[root@centos1vm ~]# yum install mdadm -y
CentOS Stream 8 – AppStream 3.1 kB/s | 4.4 kB 00:01
CentOS Stream 8 – AppStream 1.4 MB/s | 21 MB 00:15
CentOS Stream 8 – BaseOS 14 kB/s | 3.9 kB 00:00
CentOS Stream 8 – BaseOS 1.5 MB/s | 21 MB 00:13
CentOS Stream 8 – Extras 7.9 kB/s | 2.9 kB 00:00
CentOS Stream 8 – Extras 35 kB/s | 18 kB 00:00
CentOS Stream 8 – HighAvailability 7.7 kB/s | 3.9 kB 00:00
CentOS Stream 8 – HighAvailability 1.0 MB/s | 2.7 MB 00:02
Extra Packages for Enterprise Linux 8 – x86_64 51 kB/s | 26 kB 00:00
Extra Packages for Enterprise Linux 8 – x86_64 1.3 MB/s | 11 MB 00:08
Extra Packages for Enterprise Linux Modular 8 – x86_64 73 kB/s | 32 kB 00:00
Extra Packages for Enterprise Linux Modular 8 – x86_64 751 kB/s | 1.0 MB 00:01
Extra Packages for Enterprise Linux 8 – Next – x86_64 81 kB/s | 35 kB 00:00
Extra Packages for Enterprise Linux 8 – Next – x86_64 168 kB/s | 206 kB 00:01
Last metadata expiration check: 0:00:01 ago on Fri 08 Apr 2022 13:26:31 CEST.
Package mdadm-4.2-rc2.el8.x86_64 is already installed.
Dependencies resolved.
=======================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================
Upgrading:
mdadm x86_64 4.2-2.el8 baseos 460 k

Transaction Summary
=======================================================================================================================================
Upgrade 1 Package

Total download size: 460 k
Downloading Packages:
mdadm-4.2-2.el8.x86_64.rpm 1.1 MB/s | 460 kB 00:00
—————————————————————————————————————————————
Total 835 kB/s | 460 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: mdadm-4.2-2.el8.x86_64 1/1
Upgrading : mdadm-4.2-2.el8.x86_64 1/2
Running scriptlet: mdadm-4.2-2.el8.x86_64 1/2
Running scriptlet: mdadm-4.2-rc2.el8.x86_64 2/2
Cleanup : mdadm-4.2-rc2.el8.x86_64 2/2
Running scriptlet: mdadm-4.2-rc2.el8.x86_64 2/2
Verifying : mdadm-4.2-2.el8.x86_64 1/2
Verifying : mdadm-4.2-rc2.el8.x86_64 2/2

Upgraded:
mdadm-4.2-2.el8.x86_64

Complete!
[root@centos1vm ~]#

 

NOTE our extended is sdb4 – so we don’t use this for the mdadm raid definition, but rather the logical drices contained within the extended partition.

 

/dev/sdb4 3074048 20971519 17897472 8.5G 5 Extended

so, we have:

sdb1,2,3,5,6,7,8,9,10,11

 

we are going to use sdb1,2,3,5 for our first RAID10:

 

for ease of recognition, I am calling this raid RAID10, but you can use any name you wish

 

mdadm –create /dev/md0 –level raid10 –name RAID10 –raid-disks 4 /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb5

 

 

[root@centos1vm ~]# mdadm –create /dev/md0 –level raid10 –name RAID10 –raid-disks 4 /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb5
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@centos1vm ~]#

 

echo “MAILADDR root@localhost” >> /etc/mdadm.conf

 

[root@centos1vm ~]# echo “MAILADDR root@localhost” >> /etc/mdadm.conf

 

[root@centos1vm ~]# mdadm –detail –scan >> /etc/mdadm.conf
[root@centos1vm ~]# cat /etc/mdadm.conf
MAILADDR root@localhost
ARRAY /dev/md0 metadata=1.2 name=centos1vm:RAID10 UUID=3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
[root@centos1vm ~]#

 

 

Create new file system on the new raid device:

 

our drive is called:

 

md-name-centos1vm:RAID10

 

you can find this definition under:

 

/dev/disk/by-id
[root@centos1vm by-id]#

 

mkfs.ext4 /dev/disk/by-id/md-name-centos1vm:RAID10

 

 

[root@centos1vm by-id]# mkfs.ext4 /dev/disk/by-id/md-name-centos1vm:RAID10
mke2fs 1.45.6 (20-Mar-2020)
Discarding device blocks: done
Creating filesystem with 254976 4k blocks and 63744 inodes
Filesystem UUID: 7e92383a-e2fb-48a1-8602-722d5c394158
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

[root@centos1vm by-id]#

 

 

mkdir /RAID10

 

The directory does not have to be called RAID10, you can use any name you wish.

 

mount /dev/disk/by-id/md-name-centos1vm:RAID10 /RAID10

 

our RAID designation is important, note this:

 

  /dev/disk/by-id/md-name-centos1vm:RAID10  –

 

you will need to refer to it again and again when using mdadm!

 

[root@centos1vm /]# mkdir RAID10
[root@centos1vm /]#
[root@centos1vm /]# mount /dev/disk/by-id/md-name-centos1vm:RAID10 /RAID10
[root@centos1vm /]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 638M 0 638M 0% /dev
tmpfs 657M 0 657M 0% /dev/shm
tmpfs 657M 8.7M 648M 2% /run
tmpfs 657M 0 657M 0% /sys/fs/cgroup
/dev/mapper/cs_centos–base-root 8.0G 2.7G 5.4G 33% /
/dev/sda1 1014M 349M 666M 35% /boot
tmpfs 132M 0 132M 0% /run/user/0
/dev/md0 965M 2.5M 897M 1% /RAID10
[root@centos1vm /]#

 

Change /etc/fstab if you want to automatically mount the raid device. Use the device id in fstab and not /dev/md0 because it may not be persistent across reboot:

 

vi /etc/fstab

 

/dev/disk/by-id/md-name-centos1vm:RAID10 /RAID10 ext4 defaults 1 1

 

Reboot the system to check that raid 10 is automatically started and mounted after a reboot!

 

So, we have 4 disks each of 500MB, which is 2GB max, but nett capacity is 1GB ie 50% as it is mirrored and striped.

 

Testing Our New Raid 10

 

Here will test two disks failures in our raid.

 

Because raid 10 use mirror sets it will continue to function when it has faulty disks from different mirror sets.

 

Check the array status

 

mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10

 

[root@centos1vm ~]# mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10
/dev/disk/by-id/md-name-centos1vm:RAID10:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

 

Update Time : Fri Apr 8 13:46:14 2022
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 17

Number Major Minor RaidDevice State
0 8 17 0 active sync set-A /dev/sdb1
1 8 18 1 active sync set-B /dev/sdb2
2 8 19 2 active sync set-A /dev/sdb3
3 8 21 3 active sync set-B /dev/sdb5
[root@centos1vm ~]#

 

 

 

Simulate a RAID disk failure

 

For this simulation, we will fail drive sdb1:

 

mdadm –manage –set-faulty /dev/disk/by-id/md-name-centos1vm:RAID10 /dev/sdb1

 

[root@centos1vm ~]# mdadm –manage –set-faulty /dev/disk/by-id/md-name-centos1vm:RAID10 /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/disk/by-id/md-name-centos1vm:RAID10
[root@centos1vm ~]#

 

Check syslog for new failure messages

tail /var/log/messages

 

[root@centos1vm ~]# tail /var/log/messages
Apr 8 13:46:43 centos1vm systemd[1]: Created slice system-mdadm\x2dlast\x2dresort.slice.
Apr 8 13:46:45 centos1vm systemd[1]: systemd-hostnamed.service: Succeeded.
Apr 8 13:46:45 centos1vm dracut[1519]: *** Squashing the files inside the initramfs done ***
Apr 8 13:46:45 centos1vm dracut[1519]: *** Creating image file ‘/boot/initramfs-4.18.0-338.el8.x86_64kdump.img’ ***
Apr 8 13:46:46 centos1vm dracut[1519]: *** Creating initramfs image file ‘/boot/initramfs-4.18.0-338.el8.x86_64kdump.img’ done ***
Apr 8 13:46:46 centos1vm kdumpctl[998]: kdump: kexec: loaded kdump kernel
Apr 8 13:46:46 centos1vm kdumpctl[998]: kdump: Starting kdump: [OK]
Apr 8 13:46:46 centos1vm systemd[1]: Started Crash recovery kernel arming.
Apr 8 13:46:46 centos1vm systemd[1]: Startup finished in 2.099s (kernel) + 3.279s (initrd) + 36.141s (userspace) = 41.520s.
Apr 8 13:51:43 centos1vm kernel: md/raid10:md0: Disk failure on sdb1, disabling device.#012md/raid10:md0: Operation continuing on 3 devices.
[root@centos1vm ~]#

 

 

next, check array status again and we will see our faulty disk listed:

 

mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10

 

[root@centos1vm ~]#
[root@centos1vm ~]# mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10
/dev/disk/by-id/md-name-centos1vm:RAID10:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Fri Apr 8 13:51:43 2022
State : clean, degraded
Active Devices : 3
Working Devices : 3
Failed Devices : 1
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 19

Number Major Minor RaidDevice State
– 0 0 0 removed
1 8 18 1 active sync set-B /dev/sdb2
2 8 19 2 active sync set-A /dev/sdb3
3 8 21 3 active sync set-B /dev/sdb5

0 8 17 – faulty /dev/sdb1
[root@centos1vm ~]#

 

 

 

cat /proc/mdstat

[root@centos1vm ~]# cat /proc/mdstat
Personalities : [raid10]
md0 : active raid10 sdb1[0](F) sdb3[2] sdb2[1] sdb5[3]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/3] [_UUU]

unused devices: <none>
[root@centos1vm ~]#

 

 

 

 

Simulate a Second Disk Failure

 

next, simulate a second disk failure, eg for sdb3:

[root@centos1vm /]# mdadm –manage –set-faulty /dev/disk/by-id/md-name-centos1vm:RAID10 /dev/sdb3
mdadm: set /dev/sdb3 faulty in /dev/disk/by-id/md-name-centos1vm:RAID10
[root@centos1vm /]#

Check syslog for new failure messages:

 

tail /var/log/messages

 

[root@centos1vm /]#
[root@centos1vm /]# tail /var/log/messages
Apr 8 13:46:45 centos1vm systemd[1]: systemd-hostnamed.service: Succeeded.
Apr 8 13:46:45 centos1vm dracut[1519]: *** Squashing the files inside the initramfs done ***
Apr 8 13:46:45 centos1vm dracut[1519]: *** Creating image file ‘/boot/initramfs-4.18.0-338.el8.x86_64kdump.img’ ***
Apr 8 13:46:46 centos1vm dracut[1519]: *** Creating initramfs image file ‘/boot/initramfs-4.18.0-338.el8.x86_64kdump.img’ done ***
Apr 8 13:46:46 centos1vm kdumpctl[998]: kdump: kexec: loaded kdump kernel
Apr 8 13:46:46 centos1vm kdumpctl[998]: kdump: Starting kdump: [OK]
Apr 8 13:46:46 centos1vm systemd[1]: Started Crash recovery kernel arming.
Apr 8 13:46:46 centos1vm systemd[1]: Startup finished in 2.099s (kernel) + 3.279s (initrd) + 36.141s (userspace) = 41.520s.
Apr 8 13:51:43 centos1vm kernel: md/raid10:md0: Disk failure on sdb1, disabling device.#012md/raid10:md0: Operation continuing on 3 devices.
Apr 8 13:56:41 centos1vm kernel: md/raid10:md0: Disk failure on sdb3, disabling device.#012md/raid10:md0: Operation continuing on 2 devices.
[root@centos1vm /]#

 

Check array status again:

 

mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10

 

[root@centos1vm /]#
[root@centos1vm /]# mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10
/dev/disk/by-id/md-name-centos1vm:RAID10:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Fri Apr 8 13:56:41 2022
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 2
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 21

Number Major Minor RaidDevice State
– 0 0 0 removed
1 8 18 1 active sync set-B /dev/sdb2
– 0 0 2 removed
3 8 21 3 active sync set-B /dev/sdb5

0 8 17 – faulty /dev/sdb1
2 8 19 – faulty /dev/sdb3
[root@centos1vm /]#

 

 

cat /proc/mdstat

 

NOTE: Failed disk will be marked as “(F)”.

 

[root@centos1vm /]# cat /proc/mdstat
Personalities : [raid10]
md0 : active raid10 sdb1[0](F) sdb3[2](F) sdb2[1] sdb5[3]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/2] [_U_U]

unused devices: <none>
[root@centos1vm /]#

 

Remove sdb1 from the array and re-add it

 

if you need to access serial number etc of the drive you can use hdparm:

[root@centos1vm /]# hdparm -I /dev/sdb1

/dev/sdb1:

ATA device, with non-removable media
Model Number: QEMU HARDDISK
Serial Number: QM00005
Firmware Revision: 2.5+
Standards:
Used: ATA/ATAPI-5 published, ANSI INCITS 340-2000
Supported: 7 6 5 4 & some of 6
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63

CHS current addressable sectors: 16514064
LBA user addressable sectors: 20971520
LBA48 user addressable sectors: 20971520
Logical Sector size: 512 bytes
Physical Sector size: 512 bytes
device size with M = 1024*1024: 10240 MBytes
device size with M = 1000*1000: 10737 MBytes (10 GB)
cache/buffer size = 256 KBytes (type=DualPortCache)
Capabilities:
LBA, IORDY(cannot be disabled)
Queue depth: 32
Standby timer values: spec’d by Vendor
R/W multiple sector transfer: Max = 16 Current = 16
DMA: sdma0 sdma1 sdma2 mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
* Write cache
* NOP cmd
* 48-bit Address feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* Native Command Queueing (NCQ)
HW reset results:
CBLID- above Vih
Device num = 0
Integrity word not set (found 0x0000, expected 0x05a5)
[root@centos1vm /]#

 

 

Remove the drive from the array

 

OK, let’s replace the sdb1 drive, the first step is to tell MDADM that the drive has failed, and then remove it from the array:

 

mdadm –manage /dev/md0 –fail /dev/sdb1

 

mdadm –manage /dev/md0 –remove /dev/sdb1

 

[root@centos1vm /]# mdadm –manage /dev/md0 –fail /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
[root@centos1vm /]# mdadm –manage /dev/md0 –remove /dev/sdb1
mdadm: hot removed /dev/sdb1 from /dev/md0
[root@centos1vm /]#

 

mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10

 

 

 

so, now our RAID10 looks like this….

 

 

[root@centos1vm /]#
[root@centos1vm /]# mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10
/dev/disk/by-id/md-name-centos1vm:RAID10:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Fri Apr 8 14:04:04 2022
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 1
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 22

Number Major Minor RaidDevice State
– 0 0 0 removed
1 8 18 1 active sync set-B /dev/sdb2
– 0 0 2 removed
3 8 21 3 active sync set-B /dev/sdb5

2 8 19 – faulty /dev/sdb3
[root@centos1vm /]#

 

 

Remove the drive from the kernel – not sure if this is essential or not in our case….

 

 

Next, tell the OS to delete the reference to the drive, this doesn’t remove any data, it just tells the kernel that the disk is no longer available:

 

 

echo 1 | sudo tee /sys/block/sdc/device/delete

 

going to leave this for the moment in this example.

 

Replace the faulty disk 

 

We will substitute one of our other logical drives in place of sdb1… eg the next free disk in our spares, which is sdb6 (since we were using sdb1,2,3,5 (sdb4 is extended partition type).

 

Copy the partition table to the new disk

 

Copy the partition table to the new disk (Caution: This sfdisk command will replace the entire partition table on the target disk with that of the source disk – use an alternative command if you need to preserve other partition information):

 

sfdisk -d /dev/sdb2 | sfdisk /dev/sdb6

 

In this case did not work. But as they are partitions this is because the partition table is on the sdb itself not on parititions

[root@centos1vm /]# sfdisk -d /dev/sdb2 | sfdisk /dev/sdb6
sfdisk: /dev/sdb2: does not contain a recognized partition table
Checking that no-one is using this disk right now … FAILED

This disk is currently in use – repartitioning is probably a bad idea.
Umount all file systems, and swapoff all swap partitions on this disk.
Use the –no-reread flag to suppress this check.

 

sfdisk: Use the –force flag to overrule all checks.
[root@centos1vm /]#

 

Add the new drive to the array:

 

# mdadm –manage /dev/md0 –add /dev/sdb6

 

mdadm –manage /dev/md0 –add /dev/sdb6

 

 

[root@centos1vm /]# mdadm –manage /dev/md0 –add /dev/sdb6
mdadm: added /dev/sdb6
[root@centos1vm /]#

 

[root@centos1vm /]# cat /proc/mdstat
Personalities : [raid10]
md0 : active raid10 sdb6[4] sdb3[2](F) sdb2[1] sdb5[3]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/3] [UU_U]

unused devices: <none>
[root@centos1vm /]#

 

 

Lastly, if you have smartmontools installed and running, we need to reset the daemon so it doesn’t keep warning about the drive we removed:

 

systemctl restart smartd

 

[root@centos1vm /]# systemctl restart smartd
[root@centos1vm /]# systemctl status smartd
● smartd.service – Self Monitoring and Reporting Technology (SMART) Daemon
Loaded: loaded (/usr/lib/systemd/system/smartd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-04-08 14:16:41 CEST; 9s ago
Docs: man:smartd(8)
man:smartd.conf(5)
Main PID: 6025 (smartd)
Status: “Next check of 2 devices will start at 14:46:41”
Tasks: 1 (limit: 8165)
Memory: 1.6M
CGroup: /system.slice/smartd.service
└─6025 /usr/sbin/smartd -n -q never

Apr 08 14:16:41 centos1vm smartd[6025]: Device: /dev/sda [SAT], is SMART capable. Adding to “monitor” list.
Apr 08 14:16:41 centos1vm smartd[6025]: Device: /dev/sdb, type changed from ‘scsi’ to ‘sat’
Apr 08 14:16:41 centos1vm smartd[6025]: Device: /dev/sdb [SAT], opened
Apr 08 14:16:41 centos1vm smartd[6025]: Device: /dev/sdb [SAT], QEMU HARDDISK, S/N:QM00005, FW:2.5+, 10.7 GB
Apr 08 14:16:41 centos1vm smartd[6025]: Device: /dev/sdb [SAT], not found in smartd database.
Apr 08 14:16:41 centos1vm smartd[6025]: Device: /dev/sdb [SAT], can’t monitor Current_Pending_Sector count – no Attribute 197
Apr 08 14:16:41 centos1vm smartd[6025]: Device: /dev/sdb [SAT], can’t monitor Offline_Uncorrectable count – no Attribute 198
Apr 08 14:16:41 centos1vm smartd[6025]: Device: /dev/sdb [SAT], is SMART capable. Adding to “monitor” list.
Apr 08 14:16:41 centos1vm smartd[6025]: Monitoring 2 ATA/SATA, 0 SCSI/SAS and 0 NVMe devices
Apr 08 14:16:41 centos1vm systemd[1]: Started Self Monitoring and Reporting Technology (SMART) Daemon.
[root@centos1vm /]#

 

 

let’s do another check

 

 

mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10

 

 

 

[root@centos1vm /]#
[root@centos1vm /]# mdadm –detail /dev/disk/by-id/md-name-centos1vm:RAID10
/dev/disk/by-id/md-name-centos1vm:RAID10:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Fri Apr 8 14:15:16 2022
State : clean, degraded
Active Devices : 3
Working Devices : 3
Failed Devices : 1
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 41

Number Major Minor RaidDevice State
4 8 22 0 active sync set-A /dev/sdb6
1 8 18 1 active sync set-B /dev/sdb2
– 0 0 2 removed
3 8 21 3 active sync set-B /dev/sdb5

2 8 19 – faulty /dev/sdb3
[root@centos1vm /]#

 

mdadm -–query -–detail /dev/md0

 

 

now lets do the same with sdb3:

 

mdadm –manage /dev/md0 –fail /dev/sdb3

 

mdadm –manage /dev/md0 –remove /dev/sdb3

 

 

 

[root@centos1vm /]#
[root@centos1vm /]#
[root@centos1vm /]#
[root@centos1vm /]# mdadm –manage /dev/md0 –fail /dev/sdb3
mdadm: set /dev/sdb3 faulty in /dev/md0
[root@centos1vm /]#
[root@centos1vm /]# mdadm –query –detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Fri Apr 8 14:15:16 2022
State : clean, degraded
Active Devices : 3
Working Devices : 3
Failed Devices : 1
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 41

Number Major Minor RaidDevice State
4 8 22 0 active sync set-A /dev/sdb6
1 8 18 1 active sync set-B /dev/sdb2
– 0 0 2 removed
3 8 21 3 active sync set-B /dev/sdb5

2 8 19 – faulty /dev/sdb3
[root@centos1vm /]# mdadm –manage /dev/md0 –remove /dev/sdb3
mdadm: hot removed /dev/sdb3 from /dev/md0
[root@centos1vm /]# mdadm –query –detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Fri Apr 8 14:22:33 2022
State : clean, degraded
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 42

Number Major Minor RaidDevice State
4 8 22 0 active sync set-A /dev/sdb6
1 8 18 1 active sync set-B /dev/sdb2
– 0 0 2 removed
3 8 21 3 active sync set-B /dev/sdb5
[root@centos1vm /]#

 

 

we will then substitute sdb3 which has failed with our spare, sdb7:

 

 

Add the new drive to the array:

 

mdadm –manage /dev/md0 –add /dev/sdb7

 

[root@centos1vm /]#
[root@centos1vm /]#
[root@centos1vm /]# mdadm –manage /dev/md0 –add /dev/sdb7
mdadm: added /dev/sdb7
[root@centos1vm /]#
[root@centos1vm /]# mdadm –query –detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Fri Apr 8 14:24:37 2022
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 61

Number Major Minor RaidDevice State
4 8 22 0 active sync set-A /dev/sdb6
1 8 18 1 active sync set-B /dev/sdb2
5 8 23 2 active sync set-A /dev/sdb7
3 8 21 3 active sync set-B /dev/sdb5
[root@centos1vm /]#

 

[root@centos1vm /]# cat /proc/mdstat
Personalities : [raid10]
md0 : active raid10 sdb7[5] sdb6[4] sdb2[1] sdb5[3]
1019904 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

unused devices: <none>
[root@centos1vm /]#

 

 

next we will fail 2 disks simultaneously: sdb2,5

 

 

mdadm –manage –set-faulty /dev/disk/by-id/md-name-centos1vm:RAID10 /dev/sdb2
mdadm –manage /dev/md0 –fail /dev/sdb2

 

 

[root@centos1vm ~]# mdadm –manage /dev/md0 –remove /dev/sdb2
mdadm: hot removed /dev/sdb2 from /dev/md0
[root@centos1vm ~]# mdadm –manage /dev/md0 –remove /dev/sdb5
mdadm: hot removed /dev/sdb5 from /dev/md0
[root@centos1vm ~]# mdadm –query –detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 2
Persistence : Superblock is persistent

Update Time : Fri Apr 8 15:16:21 2022
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 67

Number Major Minor RaidDevice State
4 8 22 0 active sync set-A /dev/sdb6
– 0 0 1 removed
5 8 23 2 active sync set-A /dev/sdb7
– 0 0 3 removed
[root@centos1vm ~]#

 

once they are removed, provided the disks are actually ok (as they are in this example – we are just simulating a failure – we can add them back again and the RAID will rebuild itself…

 

[root@centos1vm ~]# mdadm –manage /dev/md0 –add /dev/sdb2
mdadm: added /dev/sdb2
[root@centos1vm ~]# mdadm –manage /dev/md0 –add /dev/sdb5
mdadm: added /dev/sdb5
[root@centos1vm ~]# mdadm –query –detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Fri Apr 8 15:17:01 2022
State : clean, degraded, recovering
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Rebuild Status : 93% complete

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 102

Number Major Minor RaidDevice State
4 8 22 0 active sync set-A /dev/sdb6
6 8 18 1 active sync set-B /dev/sdb2
5 8 23 2 active sync set-A /dev/sdb7
7 8 21 3 spare rebuilding /dev/sdb5
[root@centos1vm ~]#

 

 

a few minutes later and the rebuild is 100% done:

 

[root@centos1vm ~]#
[root@centos1vm ~]#
[root@centos1vm ~]# mdadm –query –detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Apr 8 13:32:13 2022
Raid Level : raid10
Array Size : 1019904 (996.00 MiB 1044.38 MB)
Used Dev Size : 509952 (498.00 MiB 522.19 MB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Fri Apr 8 15:17:01 2022
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : resync

Name : centos1vm:RAID10 (local to host centos1vm)
UUID : 3dd59b4a:6f3cdf67:f89659d6:5e0f1c0d
Events : 105

Number Major Minor RaidDevice State
4 8 22 0 active sync set-A /dev/sdb6
6 8 18 1 active sync set-B /dev/sdb2
5 8 23 2 active sync set-A /dev/sdb7
7 8 21 3 active sync set-B /dev/sdb5
[root@centos1vm ~]#

 

all ok again!

Continue Reading