raid

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
raid [22/03/2021 - 18:49] thommie4raid [29/03/2024 - 17:59] (aktuell) admin
Zeile 1: Zeile 1:
 ====== Basis Tools ====== ====== Basis Tools ======
 +
 +[[https://www.dlford.io/linux-mdraid-disk-replacement-procedure/|https://www.dlford.io/linux-mdraid-disk-replacement-procedure/]]
  
 blkid zeigt Info über Block Devices, ua. UUID und PTUIID blkid zeigt Info über Block Devices, ua. UUID und PTUIID
 +<code>
  
-<synopsis> ''blkid'' ''-po'' ''udev'' //device_name// </synopsis.. zeigt noch mehr Infos+''blkid''  ''-po''  ''udev''  //device_name// 
 + 
 +</code>
  
 smartctl -a devcice_name liest die Smart Daten der Platte aus. smartctl -a devcice_name liest die Smart Daten der Platte aus.
 +
 +<code>
 +hdparm -I /dev/xxx
 +
 +</code>
 +
 +zeigt die Seriennummer der Hardware (wichtig zur Indentifikation bei Fehlern in smartctl)
  
 ====== Raid Pflege bei Hetzner ====== ====== Raid Pflege bei Hetzner ======
Zeile 17: Zeile 29:
 ''cat /proc/mdstat Personalities : [raid1] md3 : active raid1 sda4[0] sdb4[1](F) 1822442815 blocks super 1.2 [2/1] [U_] md2 : active raid1 sda3[0] sdb3[1](F) 1073740664 blocks super 1.2 [2/1] [U_] md1 : active raid1 sda2[0] sdb2[1](F) 524276 blocks super 1.2 [2/1] [U_]'' ''cat /proc/mdstat Personalities : [raid1] md3 : active raid1 sda4[0] sdb4[1](F) 1822442815 blocks super 1.2 [2/1] [U_] md2 : active raid1 sda3[0] sdb3[1](F) 1073740664 blocks super 1.2 [2/1] [U_] md1 : active raid1 sda2[0] sdb2[1](F) 524276 blocks super 1.2 [2/1] [U_]''
  
-Mit mdadm /dev/md0 -r /dev/sdb1 lässt sich einen Platte gezielt aus dem Array entfernen.+Mit mdadm /dev/md0 -r /dev/sdb1 lässt sich einen Platte gezielt aus dem Array entfernen. Das geht aber nur, wenn das Ding icht gerade aktiv synct. Dann kann man den Array auch so auflösen: 
 + 
 +''sudo mdadm –manage /dev/md2 –fail /dev/sdc1 sudo mdadm –manage /dev/md2 –remove /dev/sdc1 '' 
 + 
 +Ab jetzt läuft das RAID Array nu noch mit einer Platte 
 + 
 +<code> 
 + <font inherit/monospace;;inherit;;#000000background-color:#ffffff;>root@nas:~# mdadm --detail /dev/md0</font>      /dev/md0: 
 +          Version : 1.2 
 +    Creation Time : Thu Dec  1 18:32:25 2016 
 +       Raid Level : raid1 
 +       Array Size : 5860021112 (5588.55 GiB 6000.66 GB) 
 +    Used Dev Size : 5860021112 (5588.55 GiB 6000.66 GB) 
 +     Raid Devices : 2 
 +    Total Devices : 1 
 +      Persistence : Superblock is persistent 
 + 
 +      Update Time : Thu Mar 14 14:56:01 2024 
 +            State : clean, degraded 
 +   Active Devices : 1 
 +  Working Devices : 1 
 +   Failed Devices : 0 
 +    Spare Devices : 0 
 + 
 +Consistency Policy : resync 
 + 
 +             Name : thommienas:
 +             UUID : 6a3e6f11:c60382cd:d674583d:4a397bce 
 +           Events : 11997 
 + 
 +   Number   Major   Minor   RaidDevice State 
 +      -              0        0      removed 
 +      2             33        1      active sync   /dev/sdc1 
 + 
 +</code>
  
 Hetzner braucht die Information, welche Platte defekt ist. Dazu benutzt man Hetzner braucht die Information, welche Platte defekt ist. Dazu benutzt man
Zeile 23: Zeile 69:
 ''mdadm –detail /dev/md0'' ''mdadm –detail /dev/md0''
  
-Sobald die neue Platte ins System eingebaut ist, muss die Partitionstabelle von der **alten** auf die **neue** Platte kopiert werden.+Sobald die neue Platte ins System eingebaut ist, muss die Partitionstabelle von der **alten** auf die **neue** Platte kopiert werden: hier NEU (sdb) << ALT (sda).
  
 ''sgdisk -R /dev/sdb /dev/sda'' ''sgdisk -R /dev/sdb /dev/sda''
Zeile 33: Zeile 79:
 Danach werden die Arrays wieder neu aufgebaut Danach werden die Arrays wieder neu aufgebaut
  
-''mdadm /dev/md0 -a /dev/sdb1 mdadm /dev/md1 -a /dev/sdb2 mdadm /dev/md2 -a /dev/sdb3 mdadm /dev/md3 -a /dev/sdb4''+''mdadm /dev/md0 -a /dev/sdb1 '' 
 + 
 +''mdadm /dev/md1 -a /dev/sdb2 '' 
 + 
 +''mdadm /dev/md2 -a /dev/sdb3 '' 
 + 
 +''mdadm /dev/md3 -a /dev/sdb4''
  
 Die Partitionen werden jetzt automatisch wieder synchronisiert. Den Fortschritt/Status sieht man mit Die Partitionen werden jetzt automatisch wieder synchronisiert. Den Fortschritt/Status sieht man mit
Zeile 39: Zeile 91:
 ''cat /proc/mdstat'' ''cat /proc/mdstat''
  
-Der Bootloader sollte neu installiertden, da sich ja die Device Map geändert hat: Im gebooteten System reicht ein+Der Bootloader sollte neu installiert werden, da sich ja die Device Map geändert hat: Im gebooteten System reicht ein
  
 ''grub-mkdevicemap'' ''grub-mkdevicemap''
Zeile 48: Zeile 100:
  
 Referenzen: [[http://wiki.hetzner.de/index.php/Festplattenaustausch_im_Software-RAID|http://wiki.hetzner.de/index.php/Festplattenaustausch_im_Software-RAID]] Referenzen: [[http://wiki.hetzner.de/index.php/Festplattenaustausch_im_Software-RAID|http://wiki.hetzner.de/index.php/Festplattenaustausch_im_Software-RAID]]
- 
-====== Datenrettung von einem RAID Array ====== 
- 
-Manueller Array Build mit einem Laufwerk 
- 
-''mdadm --build --verbose /dev/md0 --level=1 --raid-device=2 /dev/sdb missing '' 
- 
  
 ====== Plattentausch in einem RAID1 Array in Open Media Vault (NAS) ====== ====== Plattentausch in einem RAID1 Array in Open Media Vault (NAS) ======
  
 smartctl liefert Hinweise, dass die Platte einen Hieb hat: smartctl liefert Hinweise, dass die Platte einen Hieb hat:
 +<code>
  
-<code> 
 This message was generated by the smartd daemon running on: This message was generated by the smartd daemon running on:
  
Zeile 68: Zeile 113:
 The following warning/error was logged by the smartd daemon: The following warning/error was logged by the smartd daemon:
  
-Device: /dev/disk/by-id/ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3 [SAT], 1275 Currently unreadable (pending) sectors+Device: /dev/disk/by-id/ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3 [SAT], **1275 Currently unreadable (pending) sectors**
  
 Device info: Device info:
 WDC WD60EFRX-68L0BN1, S/N:WD-WXB1HB4YS7K3, WWN:5-0014ee-2b83025c8, FW:82.00A82, 6.00 TB WDC WD60EFRX-68L0BN1, S/N:WD-WXB1HB4YS7K3, WWN:5-0014ee-2b83025c8, FW:82.00A82, 6.00 TB
 +
 </code> </code>
  
-Die Anzahl der "pending sectors" nimmt nach und nach zu. Der Fehler wird in S.M.A.R.T. sichtbar, bevor die Platte hart ausfällt.+Die Anzahl der "pending sectors" nimmt nach und nach zu. Der Fehler wird zuerst in S.M.A.R.T. sichtbar, bevor die Platte irgendwann hart ausfällt. Challenge: die **richtige** Hardware austauschen.
  
-ssh shell auf OMV öffnen, sudo. lsblk liefert Partitionen und die Zuordnung zur Hardware+ssh shell auf OMV öffnen, sudo. lsblk liefert die Partitionen und die Zuordnung zur Hardware
  
 <code> <code>
Zeile 95: Zeile 141:
 ├─nvme0n1p2 259:2    0 200,5G  0 part  / ├─nvme0n1p2 259:2    0 200,5G  0 part  /
 └─nvme0n1p3 259:3    0  31,9G  0 part  [SWAP] └─nvme0n1p3 259:3    0  31,9G  0 part  [SWAP]
 +
 </code> </code>
  
-UUIDs der Partitionen zeigen:+Die UUIDs der Partitionen zeigen, darin ist die aufgedruckte Seriennummer der Platte integriert:
  
 <code> <code>
Zeile 107: Zeile 154:
 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WX11D3678FVK-part1 -> ../../sdc1 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WX11D3678FVK-part1 -> ../../sdc1
 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WX11D3678FVK-part2 -> ../../sdc2 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WX11D3678FVK-part2 -> ../../sdc2
-lrwxrwxrwx 1 0 0  9 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3 -> ../../sda+lrwxrwxrwx 1 0 0  9 Mär 11 12:16 **ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3** 
 + -> ../../sda
 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3-part1 -> ../../sda1 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3-part1 -> ../../sda1
 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3-part2 -> ../../sda2 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3-part2 -> ../../sda2
Zeile 128: Zeile 176:
 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 wwn-0x50014ee2b83025c8-part1 -> ../../sda1 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 wwn-0x50014ee2b83025c8-part1 -> ../../sda1
 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 wwn-0x50014ee2b83025c8-part2 -> ../../sda2 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 wwn-0x50014ee2b83025c8-part2 -> ../../sda2
 +
 </code> </code>
  
- +Aus der Liste die betroffene Platte anhand der UUID/Seriennummer aus smartctl rausfiltern:
-Aus der Liste die betroffene Platte anhand der UUID bzw. Seriennummer aus smartctl rausfiltern:+
  
 <code> <code>
Zeile 138: Zeile 186:
 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3-part1 -> ../../sda1 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3-part1 -> ../../sda1
 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3-part2 -> ../../sda2 lrwxrwxrwx 1 0 0 10 Mär 11 12:16 ata-WDC_WD60EFRX-68L0BN1_WD-WXB1HB4YS7K3-part2 -> ../../sda2
 +
 </code> </code>
  
-Mit mdadm --detail die Details zum RAID Array zeigen +Mit mdadm detail die Details zum aktuellen RAID Array zeigen
 <code> <code>
 +
 root@nas:/dev/disk/by-id# mdadm --detail /dev/md0 root@nas:/dev/disk/by-id# mdadm --detail /dev/md0
 /dev/md0: /dev/md0:
Zeile 170: Zeile 219:
                    34        0      active sync   /dev/sdc2                    34        0      active sync   /dev/sdc2
                     2        1      active sync   /dev/sda2                     2        1      active sync   /dev/sda2
 +
 </code> </code>
  
-Mit mdadm --manage die defekte Platte aus dem Array entfernen:+Mit mdadm manage wird die defekte Platte als fehlerhaft markiert und danach aus dem Array entfernt:
  
 <code> <code>
Zeile 179: Zeile 229:
  
 mdadm --manage /dev/md0 --remove /dev/sda2 mdadm --manage /dev/md0 --remove /dev/sda2
 +
 </code> </code>
  
Zeile 187: Zeile 238:
 Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
 md0 : active raid1 sdc2[0] sda2[1](F) md0 : active raid1 sdc2[0] sda2[1](F)
-      5860021112 blocks super 1.2 [2/1] [U_]+      5860021112 blocks super 1.2 [2/1] **[U_]** 
 </code> </code>
  
Zeile 205: Zeile 257:
 /dev/md0       5767937448 1673488612 4094432452   30% /srv/dev-disk-by-id-md-name-thommienas-0 /dev/md0       5767937448 1673488612 4094432452   30% /srv/dev-disk-by-id-md-name-thommienas-0
 /dev/sdb1       960380628   54 /dev/sdb1       960380628   54
 +
 </code> </code>
  
Zeile 228: Zeile 281:
 /dev/sda1    2048      999423      997376  487M Linux filesystem /dev/sda1    2048      999423      997376  487M Linux filesystem
 /dev/sda2  999424 11721043967 11720044544  5,5T Linux filesystem /dev/sda2  999424 11721043967 11720044544  5,5T Linux filesystem
 +
 </code> </code>
  
-Jetzt kann die alte Platte ausgebaut werden. Auf der neuen Platte mit gparted oder mkfs die Partitionierung analog anlegen (erst die Paritionstabelle gpt, dann die Partition selbst, in der Regel ext4).  +Jetzt kann die alte Platte ausgebaut werden. Auf der neuen Platte mit gparted oder mkfs die Partitionierung analog anlegen (erst die Paritionstabelle gpt, dann die Partition selbst, in der Regel ext4). Nach dem Umbau quittiert smartctl das Array als degraded:
- +
-Nach dem Umbau quittiert smartctl das Array als degraded:+
  
 <code> <code>
Zeile 244: Zeile 296:
 P.S. The /proc/mdstat file currently contains the following: P.S. The /proc/mdstat file currently contains the following:
  
-Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] +Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
 md0 : active (auto-read-only) raid1 sdb2[0] md0 : active (auto-read-only) raid1 sdb2[0]
       5860021112 blocks super 1.2 [2/1] [U_]       5860021112 blocks super 1.2 [2/1] [U_]
-      +
 unused devices: <none> unused devices: <none>
 +
 </code> </code>
  
-Nach Installation der neuen Platte wird dierse wieders ins Array integriert:+Die neue Platte wird wieder ins Array integriert:
  
 <code> <code>
 root@nas:~# mdadm --manage /dev/md0 --add /dev/sdc1 root@nas:~# mdadm --manage /dev/md0 --add /dev/sdc1
 mdadm: added /dev/sdc1 mdadm: added /dev/sdc1
 +
 </code> </code>
  
-Das sw raid beginnt, die Datein wieder zwischen beiden Platten zu synchronisieren:+Danach beginnt das sw raid, die Dateien zwischen beiden Platten zu synchronisieren:
  
 <code> <code>
-root@nas:~# mdadm --detail /dev/md0 +root@nas:~# mdadm --detail /dev/md0
 /dev/md0: /dev/md0:
            Version : 1.2            Version : 1.2
Zeile 273: Zeile 327:
  
        Update Time : Mon Mar 22 19:47:34 2021        Update Time : Mon Mar 22 19:47:34 2021
-             State : clean, degraded, recovering +             State : clean, degraded, recovering
     Active Devices : 1     Active Devices : 1
    Working Devices : 2    Working Devices : 2
Zeile 289: Zeile 343:
     Number   Major   Minor   RaidDevice State     Number   Major   Minor   RaidDevice State
                    18        0      active sync   /dev/sdb2                    18        0      active sync   /dev/sdb2
-       2             33        1      spare rebuilding   /dev/sdc1+**       2             33        1      spare rebuilding   /dev/sdc1** 
 </code> </code>
 +
 +====== Variante: wenn das Array crasht ======
 +
 +**SDB new**
 +<code>
 +Disk model: WDC WD6003FFBX-6
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 4096 bytes
 +I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 +Disklabel type: gpt
 +Disk identifier: DF00632A-03F7-46B4-A2D4-15C5DCE3930F
 +
 +</code>
 +
 +**SDC OLD**
 +<code>
 +Disk model: WDC WD60EFPX-68C
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 4096 bytes
 +I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 +Disklabel type: gpt
 +Disk identifier: 7BC40B3C-3226-40CE-84DB-844942ED7944
 +
 +Device     Start         End     Sectors  Size Type
 +/dev/sdc1   2048 11721045134 11721043087  5,5T Linux filesystem
 +
 +</code>
 +
 +RAID member einzeln analysieren
 +
 +<code>
 +root@nas:~# mdadm --examine /dev/sdc1
 +/dev/sdc1:
 +          Magic : a92b4efc
 +        Version : 1.2
 +    Feature Map : 0x2
 +     Array UUID : 6a3e6f11:c60382cd:d674583d:4a397bce
 +           Name : thommienas:0
 +  Creation Time : Thu Dec  1 18:32:25 2016
 +     Raid Level : raid1
 +   Raid Devices : 2
 +
 + Avail Dev Size : 11721041039 (5589.03 GiB 6001.17 GB)
 +     Array Size : 5860021112 (5588.55 GiB 6000.66 GB)
 +  Used Dev Size : 11720042224 (5588.55 GiB 6000.66 GB)
 +    Data Offset : 2048 sectors
 +   Super Offset : 8 sectors
 +Recovery Offset : 9190785664 sectors
 +   Unused Space : before=1768 sectors, after=998815 sectors
 +          State : clean
 +    Device UUID : 71a7b2c3:567d5d68:c4a6ec9d:0d95819b
 +
 +    Update Time : Mon Mar 25 00:31:32 2024
 +  Bad Block Log : 512 entries available at offset 264 sectors
 +       Checksum : 5cca03dd - correct
 +         Events : 12179
 +
 +   Device Role : Active device 0
 +   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
 +
 +</code>
 +
 +Dann ein loop device mit "Data Offset : 2048 sectors" erzeugen, am Besten read only:
 +
 +<code>
 +losetup --find --show --offset=$((2048*512)) /dev/sdc1
 +
 +root@nas:~# losetup
 +NAME       SIZELIMIT  OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
 +/dev/loop0         0 1048576          0 /dev/sdc1       512
 +
 +</code>
 +
 +Danach read only mounten
 +
 +<code>
 +mount -o ro /dev/loop0 /mnt/sdc1
 +
 +root@nas:/mnt/sdc1# ls
 +aquota.group  aquota.user  backup  buch  downloads  lost+found  music  photo  public2  thommie  video
 +
 +</code>
 +
 +Jetzt brauchen wir ein neues RAID array mit nur einem member auf der neuen Platte\\
 +Die Paritition wird mit fdisk /dev/sdb angelegt. Als partition type nimmt man 29 "Linux RAID".
 +
 +Danach findet mdadm die Partition. Bei gpt ist der Parititon type "ee", nicht "fd":
 +
 +<code>
 +root@nas:/mnt/sdc1# mdadm --examine /dev/sdb
 +/dev/sdb:
 +   MBR Magic : aa55
 +Partition[0] :   4294967295 sectors at            1 (type ee)
 +
 +</code>
 +
 +Danach wird manuell ein RAID Array mit einem member erzeugt:
 +
 +<code>
 +sudo mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 missing
 +
 +root@nas:/mnt# sudo mdadm --create /dev/md1 --level=mirror --raid-devices=2 /dev/sdb1 missing
 +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?
 +
 +mdadm: Defaulting to version 1.2 metadata
 +mdadm: array /dev/md1 started.
 +
 +</code>
 +
 +Danach sieht man das neue md1 array und das alte (kaputte) md0:
 +
 +<code>
 +root@nas:/mnt# cat /proc/mdstat
 +Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
 +md1 : active raid1 sdb1[0]
 +      5860389440 blocks super 1.2 [2/1] [U_]
 +      bitmap: 0/44 pages [0KB], 65536KB chunk
 +
 +md0 : inactive sdc1[3](S)
 +      5860520519 blocks super 1.2
 +
 +</code>
 +
 +Jetzt brauchts noch ein filesystem:
 +
 +<code>
 +mkfs.ext4 /dev/md1
 +
 +mount /dev/md1 /mnt/md1/
 +
 +</code>
 +
 +Danach kann man die Daten vom alten array, das read-only läuft, ins neue umkopieren:
 +
 +cp -R * /mnt/md1 & progress -mp $!
 +
 +mit progress sieht man einen Fortschrittsbalken
 +
 +
  • raid.1616438977.txt.gz
  • Zuletzt geändert: 05/03/2024 - 10:52
  • (Externe Bearbeitung)