In dieser Anleitung wird 'GPT-fdisk' für die
Einteilung der Festplatten benutzt. Mit dem eisfair-Installer 2.2.5
wurde 'GPT-fdisk' als Standard-Partitionierer eingeführt.
Um ein RAID einzurichten, benutzen wir in dieser Beschreibung das Programm
'mdadm'.
Diese Anleitung wurde speziell auf eisfair-Systeme abgestimmt,
auf deren Besonderheiten zu gegebener Zeit hingewiesen wird.
Es werden alle Arten von Festplatten (IDE, SATA, SCSI, NVME) unterstützt. Die
Festplattenbezeichnung (sd[a-f]) muss jeweils den eigenen
Gegebenheiten angepasst werden, unabängig davon, welche Werte in dieser
Anleitung verwendet wurden.
| eisfair-1 | |
| eisfair-64 | |
| Das Program 'mdadm' ist im Basis-System enthalten und muss deshalb nicht explizit installiert werden. | |
| Die notwendigen Kernelmodule sind im Kernel integriert und müssen nicht zusätzlich geladen werden. | |
Ein eisfair-System wurde bereits auf einer Festplatte installiert und soll um zwei zusätzliche Festplatten in einem RAID-1-Verbund ergänzt werden. Damit ergibt sich beispielsweise folgendes Bild:
|
eis # sgdisk -p /dev/sda
Disk /dev/sda: 625140335 sectors, 298.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): C0F8AF45-9DF5-4EFA-8166-7C0156E00E14
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 625140301
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 198655 96.0 MiB 8300 boot
2 198656 460799 128.0 MiB 8200 swap
3 460800 625119821 297.9 GiB 8300 root
eis #
eis # sgdisk -p /dev/sdb
Disk /dev/sda: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): A7B5ED75-DABA-429C-93DF-95896840CE26
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 198655 96.0 MiB 8300 boot
2 198656 460799 128.0 MiB 8200 swap
3 460800 2557951 1024.0 MiB 8300 root
4 2557952 5860512654 2.7 TiB 8300 data
eis #
eis # sgdisk -p /dev/sdc
Creating new GPT entries.
Disk /dev/sdb: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 41B3BC0A-F0EF-4D32-AE86-FA54C1921F27
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 5860533101 sectors (2.7 TiB)
Number Start (sector) End (sector) Size Code Name
eis #
|
Das Basis-System liegt in diesem Beispiel auf der Festplatte /dev/sda.
Die zu einem Software-RAID zusammenzufassenden Festplatten sind
| /dev/sdb: | wurde schon einmal benutzt und muss nun für | |
| den Einsatz fit gemacht werden. Erreicht wird dies | ||
| durch das Löschen der vorhandenen Datenstruktur: | ||
| /dev/sdc: | hat bisher keine Formatierung - ist also neu |
|
eis # sgdisk -Z /dev/sdb
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
eis #
|
Beim Ausführen des Befehls 'sgdisk -p DEVICE' ergibt sich somit folgendes Bild:
|
eis # sgdisk -p /dev/sda
Disk /dev/sda: 625140335 sectors, 298.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): C0F8AF45-9DF5-4EFA-8166-7C0156E00E14
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 625140301
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 198655 96.0 MiB 8300 boot
2 198656 460799 128.0 MiB 8200 swap
3 460800 625119821 297.9 GiB 8300 root
eis #
eis # sgdisk -p /dev/sdb
Creating new GPT entries.
Disk /dev/sda: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): A7B5ED75-DABA-429C-93DF-95896840CE26
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
eis #
eis # sgdisk -p /dev/sdc
Creating new GPT entries.
Disk /dev/sdb: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 41B3BC0A-F0EF-4D32-AE86-FA54C1921F27
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 5860533101 sectors (2.7 TiB)
Number Start (sector) End (sector) Size Code Name
eis #
|
Auf der ersten Festplatte wird eine Partition angelegt und deren Typ festgelegt. Mittels des gdisk-Befehls werden folgende Schritte ausgeführt:
| - | Partition anlegen (hier wird eine primäre Partition angelegt | |
| welche die ganze Grösse der Festplatte einnimmt) | ||
| - | Typ der Partition auf 'Linux raid auto' ändern | |
| - | Partitionstabelle schreiben | |
| - | Es muss beachtet werden, dass hinter der letzten | |
| Partition auf der Festplatte ein Bereich von (-)10M frei | ||
| bleibt. |
|
eis # gdisk /dev/sdb
q(gdisk) version 1.0.9.1
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): p
Disk /dev/sdb: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 43F0A3C8-CF7C-4A44-A753-224B04DBA35A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 5860533101 sectors (2.7 TiB)
Number Start (sector) End (sector) Size Code Name
Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-5860533134, default = 2048) or {+-}size{KMGTP}: ENTER
Last sector (2048-5860533134, default = 5860533134) or {+-}size{KMGTP}: -10M ENTER
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): L
0700 Microsoft basic data 0c01 Microsoft reserved 2700 Windows RE
3000 ONIE boot 3001 ONIE config 4100 PowerPC PReP boot
4200 Windows LDM data 4201 Windows LDM metadata 7501 IBM GPFS
7f00 ChromeOS kernel 7f01 ChromeOS root 7f02 ChromeOS reserved
8200 Linux swap 8300 Linux filesystem 8301 Linux reserved
8302 Linux /home 8400 Intel Rapid Start 8e00 Linux LVM
a500 FreeBSD disklabel a501 FreeBSD boot a502 FreeBSD swap
a503 FreeBSD UFS a504 FreeBSD ZFS a505 FreeBSD Vinum/RAID
a580 Midnight BSD data a581 Midnight BSD boot a582 Midnight BSD swap
a583 Midnight BSD UFS a584 Midnight BSD ZFS a585 Midnight BSD Vinum
a800 Apple UFS a901 NetBSD swap a902 NetBSD FFS
a903 NetBSD LFS a904 NetBSD concatenated a905 NetBSD encrypted
a906 NetBSD RAID ab00 Apple boot af00 Apple HFS/HFS+
af01 Apple RAID af02 Apple RAID offline af03 Apple label
af04 AppleTV recovery af05 Apple Core Storage be00 Solaris boot
bf00 Solaris root bf01 Solaris /usr & Mac Z bf02 Solaris swap
bf03 Solaris backup bf04 Solaris /var bf05 Solaris /home
bf06 Solaris alternate se bf07 Solaris Reserved 1 bf08 Solaris Reserved 2
bf09 Solaris Reserved 3 bf0a Solaris Reserved 4 bf0b Solaris Reserved 5
c001 HP-UX data c002 HP-UX service ea00 Freedesktop
eb00 Haiku BFS ed00 Sony system partitio ed01 Lenovo system partit
ef00 EFI System ef01 MBR partition scheme ef02 BIOS boot partition
fb00 VMWare VMFS fb01 VMWare reserved fc00 VMWare kcore crash p
fd00 Linux RAID
Hex code or GUID (L to show codes, Enter = 8300): fd00
Changed type of partition to 'Linux RAID'
Command (? for help): c
Using 1
Enter name: data
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.
eis #
|
Für die, die es kurz mögen, die vorherigen Schritte als Einzeiler mit sgdisk:
|
eis # sgdisk --new=0:0:-10M -t 1:fd00 -c 1:data /dev/sdb
Creating new GPT entries.
Setting name!
partNum is 0
REALLY setting name!
The operation has completed successfully.
eis #
|
Nachdem die erste Festplatte komplett eingerichtet wurde, überträgt man deren Partitions-Layout auf die zweite Festplatte und begutachtet das Ergebnis:
|
eis # sgdisk -R /dev/sdc /dev/sdb
The operation has completed successfully.
eis #
eis # sgdisk -G /dev/sdc
The operation has completed successfully.
eis #
|
|
eis # sgdisk -p /dev/sda
Disk /dev/sda: 625140335 sectors, 298.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): C0F8AF45-9DF5-4EFA-8166-7C0156E00E14
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 625140301
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 198655 96.0 MiB 8300 boot
2 198656 460799 128.0 MiB 8200 swap
3 460800 625119821 297.9 GiB 8300 root
eis #
eis # sgdisk -p /dev/sdb
Disk /dev/sda: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 43F0A3C8-CF7C-4A44-A753-224B04DBA35A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 5860533134 2.7 TiB FD00 data
eis #
eis # sgdisk -p /dev/sdc
Disk /dev/sdb: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): DC52B1DD-7D2F-4DFD-A783-C1490E4A8D0A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 5860533134 2.7 TiB FD00 data
eis #
|
Falls die Festplatten bereits einmal in einem RAID-Verbund verwendet wurden, muss sichergestellt werden, dass keine Reste der alten RAID-Konfiguration mehr vorhanden sind. Hierzu wird einfach der alte Superblock gelöscht:
|
eis # mdadm --zero-superblock /dev/sdb1
mdadm: Unrecognised md component device - /dev/sdb1
eis #
eis # mdadm --zero-superblock /dev/sdc1
mdadm: Unrecognised md component device - /dev/sdc1
eis #
|
Falls keine Reste eines früheren RAID-Verbundes gefunden werden, wird von mdadm die oben zu sehende Meldung ausgegeben. Das ist an dieser Stelle kein Problem und bei neuen Festplatten absolut normal.
Die Festplatten sind nun soweit vorbereitet, um sie zu einem RAID-Verbund zusammenzuführen. Der RAID-Verbund wird im nächsten Schritt mit Hilfe von mdadm angelegt:
|
eis # mdadm --create /dev/md0 --bitmap=internal --level=1 --raid-disks=2 /dev/sdb1 /dev/sdc1
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
eis #
|
Jetzt beginnt die Synchronisation der RAID-Festplatten, welche man unbedingt bis zum Ende abwarten sollte. Dieser Vorgang kann, abhängig von der Größe der Festplatten, mehrere Stunden dauern. Den aktuellen Status der Synchronisation kann man sich wie folgt anzeigen lassen:
|
eis # cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc[1] sdb[0]
2930134272 blocks super 1.2 [2/2] [UU]
[>....................] resync = 0.3% (10941248/2930134272) finish=443.2min speed=109772K/sec
bitmap: 22/22 pages [88KB], 65536KB chunk
unused devices: <none>
eis #
|
Beim Aufruf des Befehls 'watch cat /proc/mdstat' erhält man eine alle zwei Sekunden aktualisierte Statusausgabe und kann den Synchronisationsprozess so nebenher im Auge behalten. Zurück auf die Konsole gelangt man mit 'Strg+C':
|
eis # watch cat /proc/mdstat
Every 2.0s: cat /proc/mdstat Sat Jul 20 18:14:42 2024
Personalities : [raid1]
md0 : active raid1 sdc[1] sdb[0]
2930134272 blocks super 1.2 [2/2] [UU]
[>....................] resync = 0.3% (10941248/2930134272) finish=443.2min speed=109772K/sec
bitmap: 22/22 pages [88KB], 65536KB chunk
unused devices: <none>
eis #
|
Nach Abschluss der Synchronisation legt man das Dateisystem an, was
üblicherweise einige Minuten dauert. Das Standard-Dateisystem
ist 'ext4 - mkfs.ext4', auch wenn es diverse Alternativen gibt.
'Wer die Wahl hat, hat die Qual' ;-)
Zum Einrichten eines 'xfs'-Dateisystems, 'xfs - mkfs.xfs', müssen
zusätzlich die 'xfs-tools' von
Pack-Eis
installiert werden.
|
eis # mkfs.ext4 /dev/md0
mke2fs 1.47.0 (5-Feb-2023)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
183140352 inodes, 732533568 blocks
36626678 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
22356 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
eis #
|
Dieses Szenario setzt voraus, dass auf einem anderen System ein RAID-Verbund auf einer oder mehreren Platten angelegt wurde und die beinhaltenden Platten in den eisfair-1-Server eingebaut und elektrisch angeschlossen wurden.
Um den existierenden RAID-Verbund mounten zu können, muss dieser zuerst gestartet werden. Dies geht mit folgendem Befehl; ggf. /dev/mdX-Device und die einzelnen Partitionen /dev/sdX bzw. /dev/sdX anpassen.
Beispiel für ein RAID-1 auf zwei Festplatten:
|
eis # mdadm --assemble /dev/md0 /dev/sdb1 /dev/sdc1
mdadm: /dev/md0 has been started with 2 drives (out of 2)
eis #
|
Beispiel für ein RAID-1 auf zwei Festplatten, wobei gerade nur eine Festplatte angeschlossen ist:
|
eis # mdadm --assemble /dev/md0 /dev/sdb1
mdadm: /dev/md0 has been started with 1 drive (out of 2)
eis #
|
Die fehlende Festplatte/Partition kann später mit folgendem Befehl hinzugefügt werden:
|
eis # mdadm /dev/md0 -a /dev/sdc1
eis #
|
Der RAID-Verbund ist nun eingerichtet und kann gemountet werden. Im Beispiel wird als Mountpoint das Verzeichnis /data/backup verwendet:
|
eis # mkdir -p /data/backup
eis #
eis # ls -l /data/
total 4
drwxr-xr-x 2 root root 4096 Jul 20 18:21 backup
eis #
eis # mount -t ext4 /dev/md0 /data/backup
eis #
|
Die neue Partition im RAID-Verbund ist dem System nun bis zum nächsten Reboot bekannt:
|
eis # mount
/dev/sda3 on / type ext4 (rw,errors=remount-ro)
/dev/sda1 on /boot type ext4 (rw,errors=remount-ro)
devpts on /dev/pts type devpts (rw)
sysfs on /sys type sysfs (rw)
/dev/md0 on /data/backup type ext4 (rw)
eis #
|
Um den RAID-Verbund dauerhaft zu aktivieren, damit er auch einen
Neustart übersteht, sind folgende Schritte durchzuführen:
Mit Hilfe des Editors 'joe' öffnet man die Datei /etc/fstab und fügt eine zusätzliche Zeile, ebenfalls beginnend mit UUID=, hinzu.
Ermitteln lässt sich der Wert der hinter UUID= erforderlich ist mit foldgendem Kommando.
|
eis # blkid -o value -s UUID /dev/md0
eis #
|
| joe /etc/fstab |
|---|
Vor dem erzeugen einer neuen initrd ist es von Vorteil die mdadm.conf zu erzeugen oder zu erweitern, damit die geänderte mdadm.conf mit in die initrd integriert wird, dann ist das neue md Device nach dem reboot vorhanden. Dies kann über das Menu erfolgen.
| 4. | System administration |
| x. | Filesystems |
| x. | mdadm - RAID management |
| x. | Create mdadm conf |
Im Anschluss lässt sich die Zuordnung der md Device Namen ändern, wenn z.B ein md127 Device vorhanden ist. Dazu wird mit einem Editor die /etc/mdadm/mdadm.conf bearbeitet und die Device bezeichnung angepasst. z.B.
ist: ARRAY /dev/md/127 ...
soll: ARRAY /dev/md/4 ...
Hinweis
Ab der Kernel Version 6.0.5 linux-4.9.261-eisfair wird dracut als
tool zum erzeugen der initrd benutzt
Für die Systeme, denen ein RAID hinzugefügt wurde, ist unter '/usr/share/dracut/config' eine Vorlage abgelegt, 01-dracut-mdraid.conf, die dann nach '/etc/dracut.conf.d' kopiert werden sollte.
Anschliessend wird eine neue initrd mit, mkinitrd erzeugt.
Nach dem Neustart des Servers prüfen wir noch einmal, ob die neue Partition im RAID-Verbund korrekt eingebunden wurde.
|
Welcome to eisfair!
eisfair-base: 3.6.5
eiskernel : 6.6.119-eisfair-1-SMP
eis #
eis # mount
/dev/sda3 on / type ext4 (rw,errors=remount-ro)
/dev/sda1 on /boot type ext4 (rw,errors=remount-ro)
devpts on /dev/pts type devpts (rw)
sysfs on /sys type sysfs (rw)
/dev/md0 on /data/backup type ext4 (rw)
eis #
|
An dieser Stelle ist die Konfiguration des RAID-Verbundes und dessen
dauerhafte Einbindung in das eisfair-System abgeschlossen.
Ein eisfair-System wurde bereits mit 4 Partitionen auf einer Festplatte
installiert, d.h. es wurde dabei auch eine zusätzliche /data-Partition
angelegt. Dieses eisfair-System soll nun komplett auf einen RAID-1-Verbund umziehen.
Damit ergibt sich folgendes Bild:
| /dev/sda | ⇒ | Erste Festplatte mit dem vorhandenen eisfair-System | |
| /dev/sda1 | ⇒ | /boot | |
| /dev/sda2 | ⇒ | swap-Partition | |
| /dev/sda3 | ⇒ | / | |
| /dev/sda4 | ⇒ | /data | |
| /dev/sdb | ⇒ | Zweite 'leere' Festplatte |
|
eis # sgdisk -p /dev/sda
Disk /dev/sda: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 225A5478-5E44-4F29-A07B-C5237D2C8D0A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 100351 96.0 MiB 8300 boot
2 198656 460799 128.0 MiB 8200 swap
3 460800 2557951 1024.0 MiB 8300 root
4 2557952 8368094 2.8 GiB 8300 data
eis #
eis # sgdisk -p /dev/sdb
Creating new GPT entries.
Disk /dev/sdb: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 64A8CE74-7CE2-400A-BCA3-09392C7C8114
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 8388541 sectors (4.0 GiB)
Number Start (sector) End (sector) Size Code Name
eis #
|
Auf der ersten Festplatte ändert man nun die Partitions-Ids aller vorhandenen Partitionen nach 'fd00' - 'Linux raid autodetect':
|
eis # sgdisk -t 1:fd00 /dev/sda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
eis #
eis # sgdisk -t 2:fd00 /dev/sda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
eis #
eis # sgdisk -t 3:fd00 /dev/sda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
eis #
eis # sgdisk -t 4:fd00 /dev/sda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
eis #
|
Für die, die es kurz mögen, gibt es diese Befehle noch einmal als Einzeiler mit sgdisk:
|
eis # for i in 1 2 3 4 ; do sgdisk -t ${i}:fd00 /dev/sda ; done
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
eis #
|
Jetzt ist ein Reboot erforderlich, da uns die Meldungen darauf hinweisen, dass der Kernel die neue Tabelle erst nach einem Reboot benutzt.
Die Partitionen stellen sich nach dem Reboot wie folgt dar:
|
eis # sgdisk -p /dev/sda
Disk /dev/sda: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 225A5478-5E44-4F29-A07B-C5237D2C8D0A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 198655 96.0 MiB FD00 boot
2 198656 460799 128.0 MiB FD00 swap
3 460800 2557951 1024.0 MiB FD00 root
4 2557952 860512654 2.7 GiB FD00 data
eis #
|
Nachdem die erste Festplatte komplett eingerichtet wurde, überträgt man deren Partitions-Layout auf die zweite Festplatte und begutachtet das Ergebnis:
|
eis # sgdisk -R /dev/sdb /dev/sda
The operation has completed successfully.
eis #
eis # sgdisk -G /dev/sdb
The operation has completed successfully.
eis #
|
|
eis # sgdisk -p /dev/sda
Disk /dev/sda: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 225A5478-5E44-4F29-A07B-C5237D2C8D0A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 198655 96.0 MiB FD00 boot
2 198656 460799 128.0 MiB FD00 swap
3 460800 2557951 1024.0 MiB FD00 root
4 2557952 5860512654 2.7 GiB FD00 data
eis #
eis # sgdisk -p /dev/sdb
Disk /dev/sdb: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D2ADEFB9-7DD6-4942-BB4B-3EAAF84DA137
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 198655 96.0 MiB FD00 boot
2 198656 460799 128.0 MiB FD00 swap
3 460800 2557951 1024.0 MiB FD00 root
4 2557952 5860512654 2.7 GiB FD00 data
eis #
|
Falls die Festplatten bereits einmal in einem RAID-Verbund verwendet wurden, muss sichergestellt werden, dass keine Reste der alten RAID-Konfiguration mehr vorhanden sind. Hierzu wird einfach der alte Superblock gelöscht:
|
eis # mdadm --zero-superblock /dev/sdb1
mdadm: Unrecognised md component device - /dev/sdb1
eis #
eis # mdadm --zero-superblock /dev/sdb2
mdadm: Unrecognised md component device - /dev/sdb2
eis #
eis # mdadm --zero-superblock /dev/sdb3
mdadm: Unrecognised md component device - /dev/sdb3
eis #
eis # mdadm --zero-superblock /dev/sdb4
mdadm: Unrecognised md component device - /dev/sdb4
eis #
|
Falls keine Reste eines früheren RAID-Verbundes gefunden werden, wird die oben zu sehende Meldung ausgegeben. Das ist an dieser Stelle kein Problem und bei neuen Festplatten absolut normal.
Die Festplatten sind nun soweit vorbereitet, dass ein RAID-Verbund
angelegt werden kann. Hierzu verwendet man mdadm. Zur besseren
Orientierung wird empfohlen, die Bezeichnungen der 'md'-Devices
an die der vorherigen Partitionen anzulehnen:
| /dev/sda1 | ⇒ | /dev/md1 | |
| /dev/sda2 | ⇒ | /dev/md2 | |
| /dev/sda3 | ⇒ | /dev/md3 | |
| /dev/sda4 | ⇒ | /dev/md4 | |
Da die erste Festplatte die zu kopierenden Daten enthält, wird sie beim
Anlegen des RAID-Verbundes als 'missing' deklariert. Das Schlüsselwort
'missing' sagt lediglich aus, dass noch Devices fehlen und bezieht sich
nicht auf das danach angegebene Device.
Es ist unbedingt darauf zu achten, dass die '/boot'-Partition, also /dev/md1, mit '--metadata=0.90' angelegt wird, da der Kernel nur davon booten kann.
|
eis # mdadm --create /dev/md1 --bitmap=internal --level=1 --metadata=0.90 --raid-disks=2 missing /dev/sdb1
mdadm: array /dev/md1 started.
eis #
eis # mdadm --create /dev/md2 --bitmap=internal --level=1 --raid-disks=2 missing /dev/sdb2
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
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.
eis #
eis # mdadm --create /dev/md3 --bitmap=internal --level=1 --raid-disks=2 missing /dev/sdb3
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
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md3 started.
eis #
eis # mdadm --create /dev/md4 --bitmap=internal --level=1 --raid-disks=2 missing /dev/sdb4
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
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md4 started.
eis #
|
Das Ergebnis lässt man sich zur Kontrolle anzeigen:
|
eis # cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md4 : active raid1 sdb4[1]
2952128 blocks super 1.2 [2/1] [_U]
bitmap: 0/1 pages [0KB], 65536KB chunk
md3 : active raid1 sdb3[1]
1048000 blocks super 1.2 [2/1] [_U]
bitmap: 0/1 pages [0KB], 65536KB chunk
md2 : active raid1 sdb2[1]
130944 blocks super 1.2 [2/1] [_U]
bitmap: 0/1 pages [0KB], 65536KB chunk
md1 : active raid1 sdb1[1]
49088 blocks [2/1] [_U]
bitmap: 0/1 pages [0KB], 65536KB chunk
unused devices: <none>
eis #
|
Nun legt man das Dateisystem an, was üblicherweise einige Minuten
dauert. Das Standard-Dateisystem vieler Linux-Systeme ist auch heute
noch 'ext4 - mkfs.ext4', auch wenn es diverse Alternativen gibt.
'Wer die Wahl hat, hat die Qual' ;-)
Neu für eisfair hinzugekommenes Dateisystem ist 'xfs - mkfs.xfs'.
Zum Einrichten eines 'xfs'-Dateisystems müssen
zusätzlich die 'xfs-tools' von
Pack-Eis
installiert werden.
| mkfs.ext4 | /dev/md1 | |
| mkfs.ext4 | /dev/md3 | |
| mkfs.ext4 | /dev/md4 | |
| mkswap | /dev/md2 |
|
eis # mkfs.ext4 /dev/md1
mke2fs 1.47.0 (5-Feb-2023)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
12288 inodes, 49088 blocks
2454 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=50331648
6 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
eis #
eis # mkfs.ext4 /dev/md3
mke2fs 1.47.0 (5-Feb-2023)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262000 blocks
13100 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
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
eis #
eis # mkfs.ext4 /dev/md4
mke2fs 1.47.0 (5-Feb-2023)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
184736 inodes, 738032 blocks
36901 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=759169024
23 block groups
32768 blocks per group, 32768 fragments per group
8032 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
eis #
eis # mkswap /dev/md2
Setting up swapspace version 1, size = 130940 KiB
no label, UUID=30231248-4bf2-40c9-a09c-d69cc4ffc53a
eis #
|
Das Root-Device (/dev/md3) mountet man nach /mnt und legt dort ein neues boot-Verzeichnis an. Dieses boot-Verzeichnis verwendet man nun als Mountpoint für das Boot-Device (/dev/md1):
|
eis # mount -t ext4 /dev/md3 /mnt
eis #
eis # mkdir -p /mnt/boot
eis #
eis # mount -t ext4 /dev/md1 /mnt/boot
eis #
|
Die Partitionen mit dem Root-Verzeichnis sowie dem Boot-Verzeichnis werden auf die neu erstellten Multiple-Devices kopiert.
Da der Kopiervorgang selbst einige Minuten dauern kann, wartet man so lange, bis der Eingabe-Prompt wieder erscheint:
|
eis # cd /
eis #
eis # find . -xdev | cpio -pmv /mnt
eis #
eis # cd /boot
eis #
eis # find . -xdev | cpio -pmv /mnt/boot
eis #
|
Im Anschluss müssen nun noch im /dev Verzeichnis die Devices console und null angelegt werden. Diese Devices müssen beim boot vorhanden sein.
Dazu wechselt man in das Verzeichnis:
cd /mnt/dev
mknod -m 0660 console c 5 1
mknod -m 0660 null c 1 3
Mit Hilfe des Editors 'joe' öffnet man die Datei /mnt/etc/fstab und
passt sie an die neuen Multiple-Device-Namen an. Bitte eine Leerzeile
am Dateiende nicht vergessen:
Ermitteln lässt sich der Wert der jeweils hinter UUID= erforderlich ist mit foldgendem Kommando. Bitte den Wert /dev/mdX bitte jeweils anpassen.
|
eis # blkid -o value -s UUID /dev/md1
eis #
|
| joe /mnt/etc/fstab |
|---|
Vor dem erzeugen einer neuen initrd ist es von Vorteil die mdadm.conf zu erzeugen oder zu erweitern, damit die geänderte mdadm.conf mit in die initrd integriert wird, dann ist das neue md Device nach dem reboot vorhanden. Dies kann über das Menu erfolgen.
| 4. | System administration |
| x. | Filesystems |
| x. | mdadm - RAID management |
| x. | Create mdadm conf |
Im Anschluss lässt sich die Zuordnung der md Device Namen ändern, wenn z.B ein md127 Device vorhanden ist. Dazu wird mit einem Editor die /etc/mdadm/mdadm.conf bearbeitet und die Device bezeichnung angepasst. z.B.
ist: ARRAY /dev/md/127 ...
soll: ARRAY /dev/md/4 ...
Hinweis
Ab der Kernel Version 6.0.5 linux-4.9.261-eisfair wird dracut als
tool zum erzeugen der initrd benutzt
Für die Systeme, denen ein RAID hinzugefügt wurde, ist unter '/usr/share/dracut/config' eine Vorlage abgelegt, 01-dracut-mdraid.conf, die dann nach '/etc/dracut.conf.d' kopiert werden sollte.
Anschliessend wird eine neue initrd mit, mkinitrd erzeugt.
Wenn alle bisherigen Schritte ohne Probleme durchgeführt wurden, läuft der RAID-Verbund zwar bereits, jedoch ohne aktive Redundanz, da die Festplatte /dev/sda noch nicht Teil des RAID-Verbundes ist:
|
eis # mount
/dev/md3 on / type ext4 (rw,errors=remount-ro)
/dev/md1 on /boot type ext4 (rw,errors=remount-ro)
/dev/md4 on /data type ext4 (rw)
devpts on /dev/pts type devpts (rw)
sysfs on /sys type sysfs (rw)
eis #
|
Die Festplatte /dev/sda wird nun in den RAID-Verbund integriert:
|
eis # mdadm /dev/md1 --add /dev/sda1
mdadm: added /dev/sda1
eis #
eis # mdadm /dev/md2 --add /dev/sda2
mdadm: added /dev/sda2
eis #
eis # mdadm /dev/md3 --add /dev/sda3
mdadm: added /dev/sda3
eis #
eis # mdadm /dev/md4 --add /dev/sda4
mdadm: added /dev/sda4
eis #
|
Jetzt beginnt die Synchronisation der RAID-Festplatten, welche man
unbedingt bis zum Ende abwarten sollte. Dieser Vorgang kann, abhängig
von der Größe der Festplatten, mehrere Stunden dauern. Den aktuellen
Status der Synchronisation kann man sich wie folgt anzeigen lassen:
|
eis # cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md2 : active raid1 sda2[0] sdb2[1]
130944 blocks super 1.2 [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk
md3 : active raid1 sda3[2] sdb3[1]
1048000 blocks super 1.2 [2/1] [_U]
[========>............] recovery = 40.9% (429504/1048000)
finish=0.3min speed=28633K/sec
bitmap: 1/1 pages [4KB], 65536KB chunk
md4 : active raid1 sda4[2] sdb4[1]
2952128 blocks super 1.2 [2/1] [_U]
resync=DELAYED
bitmap: 1/1 pages [4KB], 65536KB chunk
md1 : active raid1 sda1[0] sdb1[1]
49088 blocks [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk
unused devices: <none>
eis #
|
Beim Aufruf des Befehls 'watch cat /proc/mdstat' erhält man eine alle zwei
Sekunden aktualisierte Statusausgabe und kann den Synchronisationsprozess
so nebenher im Auge behalten. Zurück auf die Konsole gelangt man mit 'Strg+C':
|
eis # watch cat /proc/mdstat
Every 2.0s: cat /proc/mdstat Sat Jul 20 18:14:42 2024
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md2 : active raid1 sda2[0] sdb2[1]
130944 blocks super 1.2 [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk
md3 : active raid1 sda3[2] sdb3[1]
1048000 blocks super 1.2 [2/1] [_U]
[========>............] recovery = 40.9% (429504/1048000)
finish=0.3min speed=28633K/sec
bitmap: 1/1 pages [4KB], 65536KB chunk
md4 : active raid1 sda4[2] sdb4[1]
2952128 blocks super 1.2 [2/1] [_U]
resync=DELAYED
bitmap: 1/1 pages [4KB], 65536KB chunk
md1 : active raid1 sda1[0] sdb1[1]
49088 blocks [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk
unused devices: <none>
eis #
|
An dieser Stelle ist die Konfiguration des RAID-Verbundes und dessen
dauerhafte Einbindung in das eisfair-System abgeschlossen. Dies
sollte noch durch einen Neustart des Servers überprüft werden:
|
eis # Welcome to eisfair!
eisfair-base: 3.6.5
eiskernel : 6.6.119-eisfair-1-SMP
eis #
eis # mount
/dev/md3 on / type ext4 (rw,errors=remount-ro)
/dev/md1 on /boot type ext4 (rw,errors=remount-ro)
/dev/md4 on /data type ext4 (rw)
devpts on /dev/pts type devpts (rw)
sysfs on /sys type sysfs (rw)
eis #
|
Die Installation eines RAID-5 erfolgt analog eines RAID-1 mit einer dritten Festplatte.
Der wesentlichste und wichtigste Unterschied ist, dass ein Linux-System nicht von einem Software-RAID-5 booten kann. Das heisst nun aber nicht, dass sich ein System mit Software-RAID-5 nicht einrichten und betreiben lässt. Es benötigt dafür nur eine Boot-Partition, die kein RAID-5 enthält. Dafür ist ein RAID-1 genau richtig.
Ein Software-RAID wird vom Kernel bereit gestellt. Das bedeutet, der Kernel muss selbst erst einmal geladen sein, um dieses Software-RAID zu initalisieren. Wenn nun /boot mit dem zu ladenen Kernel aber auf einem RAID-5 liegen würde, bei dem die Daten über 3 Festplatten verteilt sind, müßte der Kernel von einem Array geladen werden, welches nur der Kernel selber initialisieren kann ...
Weitere Tests lassen sich realisieren, indem man einzelne Festplatten nacheinander hardwareseitig abklemmt. Es ist darauf zu achten, dass die Synchronisation immer vollständig erfolgt ist, bevor ein Reboot ausgeführt wird. Ist alles korrekt konfiguriert, muss das System von jedem Laufwerk ohne Fehlermeldungen hochfahren.
Bei Ausfall einer Festplatte in einem Software-RAID-Verbund sind im Wesentlichen die gleichen Schritte wie bei dem Hinzufügen der 2. Festplatte, weiter vorne beschrieben, auszuführen.
|
eis # hdparm -i /dev/sdb
/dev/sdb:
Model=WDC WD10EARS-00Y5B1, FwRev=80.00A80, SerialNo=WD-WCAV5F175350
Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=50
BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=16
CurCHS=65535/1/63, CurSects=4128705, LBA=yes, LBAsects=625142448
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
AdvancedPM=no WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-1,2,3,4,5,6,7
* signifies the current active mode
eis #
|
|
eis # mdadm /dev/md1 --fail /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md1
eis #
eis # mdadm /dev/md2 --fail /dev/sdb2
mdadm: set /dev/sdb2 faulty in /dev/md2
eis #
eis # mdadm /dev/md3 --fail /dev/sdb3
mdadm: set /dev/sdb3 faulty in /dev/md3
eis #
eis # mdadm /dev/md4 --fail /dev/sdb4
mdadm: set /dev/sdb4 faulty in /dev/md4
eis #
|
|
eis # mdadm /dev/md1 --remove /dev/sdb1
mdadm: hot removed /dev/hsdb1
eis #
eis # mdadm /dev/md2 --remove /dev/sdb2
mdadm: hot removed /dev/sdb2
eis #
eis # mdadm /dev/md3 --remove /dev/sdb3
mdadm: hot removed /dev/sdb3
eis #
eis # mdadm /dev/md4 --remove /dev/sdb4
mdadm: hot removed /dev/sdb4
eis #
|
|
eis # sgdisk -R /dev/sdb /dev/sda
The operation has completed successfully.
eis #
eis # sgdisk -G /dev/sdb
The operation has completed successfully.
eis #
|
|
eis # sgdisk -p /dev/sda
Disk /dev/sda: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 225A5478-5E44-4F29-A07B-C5237D2C8D0A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 198655 96.0 MiB FD00 boot
2 198656 460799 128.0 MiB FD00 swap
3 460800 2557951 1024.0 MiB FD00 root
4 2557952 5860512654 2.7 GiB FD00 data
eis #
eis # sgdisk -p /dev/sdb
Disk /dev/sdb: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D2ADEFB9-7DD6-4942-BB4B-3EAAF84DA137
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 198655 96.0 MiB FD00 boot
2 198656 460799 128.0 MiB FD00 swap
3 460800 2557951 1024.0 MiB FD00 root
4 2557952 5860512654 2.7 GiB FD00 data
eis #
|
|
eis # mdadm /dev/md1 --add /dev/sdb1
mdadm: added /dev/sdb1
eis #
eis # mdadm /dev/md2 --add /dev/sdb2
mdadm: added /dev/sdb2
eis #
eis # mdadm /dev/md3 --add /dev/sdb3
mdadm: added /dev/sdb3
eis #
eis # mdadm /dev/md4 --add /dev/sdb4
mdadm: added /dev/sdb4
eis #
|
Nach der Synchronisation ist der RAID-Verbund wieder vollständig.
Es ist unbedingt zu beachten, dass ein RAID-Verbund kein Backup ersetzt.
Aus diesem Grund wird empfohlen, eine verlässliche Sicherungsstrategie
zu erstellen.
Darüberhinaus sollte vor der Überführung eines bestehenden
eisfair-Systems in einen RAID-Verbund, wie vor allen großen Änderungen
an der Hard- oder Software, eine Datensicherung auf einen externen
Datenträger durchgeführt werden.
Für die Erstellung dieser Anleitung wurde u.a. auf die auf
eisfair.org
abgelegten
Anleitungen von Jürgen Witt und Manfred Reiland
zurückgegriffen.