RAID5 aufbauen (inkl. LUKS Verschlüsselung)

Partitionstabellen der Festplatten löschen:

dd if=/dev/zero of=/dev/ count=1
dd if=/dev/zero of=/dev/ count=1
dd if=/dev/zero of=/dev/ count=1

Partitionierung mit einer Partition vom Typ Linux RAID autodetect (FD)

cfdisk /dev/ 
cfdisk /dev/ 
cfdisk /dev/

RAID-Stuff installieren:

apt-get install mdadm

RAID-5 Verbund erstellen (level => RAID5-TYP -n 3 => 3 Festplatten):

mdadm --create /dev/md0 --level=5 -n 3 &&
/dev/ /dev/ &&
/dev/

Status des Raids überprüfen (in einer weiteren SSH-Instanz ausführen):

watch cat /proc/mdstat

oder:

mdadm -D /dev/md0

Config-File anlegen

echo "DEVICE partitions" > /etc/mdadm/mdadm.conf
mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Datei-System anlegen:

mkfs.ext4 /dev/md0

HDD mounten und Überwachung per Email aktivieren:

vi /etc/mdadm/mdadm.conf

Und dies in die Datei einfügen:

MAILADDR max.mustermann@musterhausen.de
mdadm --monitor --scan --test --oneshot

Bei Ausfall der HDD wird folgendermaßen vorgegangen:

Partitionsinformationen von einer intakten HDD auf die neue kopieren:

dd if=/dev/sda of=/dev/sdb bs=512 count=1

Neu einlesen und einen Neustart ersparen:

sfdisk -R /dev/md0

Partition dem Raid hinzufügen:

mdadm /dev/md0 -a /dev/

Rebuild wird automatisch gestartet!!! WARTEN!!! -> Status abfragen (in einer weiteren SSH-Instanz)

cat /proc/mdstat

Methode 1 – Neue Festplatte zum Verbund hinzufügen.

Partitionsinformationen von einer intakten HDD auf die neue kopieren:

dd if=/dev/sda of=/dev/ bs=512 count=1

Methode 2 – Partition mit cfdisk (autodetect FD) anlegen

cfdisk /dev/

Neu einlesen und Neustart ersparen:

sfdisk -R /dev/md0

Partition dem Raid hinzufügen (aber nur bei gleicher Größe und Art):

mdadm /dev/md0 -a /dev/

Andere Möglichkeit: fdisk -> Primär -> Raid-Flag setzen

Raid erweitern, vorher prüfen, wie der Raid-Verbund aussieht:

mdadm --detail /dev/md0
mdadm /dev/md0 --grow --raid-devices=

(Nicht getestet) – Bei der FEHLERMELDUNG: mdadm: Need to backup critical section.. -> ...

“Unmount the array, i don’t know if this is necessary, but doing so means less stuff to go wrong”.

RAID aushängen

umount /dev/md0

Then you need to go and prepare the disk(s) to be added. (The prepare section of the guide) Then tell mdadm that it can play with it:

mdadm --add /dev/md0 /dev/sda2

Then tell mdadm to stop playing and use it to expand/grow your raid5 array(make sure that the number of raid devices is correct, it should be the number of disks/partitions the grown/expanded array will have):

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

View and wait for the new array to reshape:

cat /proc/mdstat

Check the files/dataystem (required to resize it):

e2fsck -f /dev/md0

Resize the files/dataystem on the new array so that you can use it for something useful.

resize2fs /dev/md0

Mount the expanded/grown array with it’s resized files/dataystem(remember to change the mount point):

mount -t ext3 /dev/md0 /home/tore/raid

Go check your files/data:

cd /home/tore/raid
cksfv -r -q

Überprüfen ob das Array größer geworden ist. Konfigurationsdatei erzeugen:

mv /etc/mdadm/mdadm.conf /root/mdadm.conf.backup
dpkg-reconfigure mdadm

Verschlüsseltes Volume erweitern:

cryptsetup luksOpen /dev/md0 md0_crypt

Filesystem vergrößern anhand von Ext2/3

e2fsck -f /dev/mapper/raid_crypt
resize2fs /dev/mapper/

und nun kann man weiter kräftig Daten drauf schieben