Plattentausch mit Software-Raid1
Inhalt
- Identifizierung und Austausch der defekten Platte
 - Partitionierung
 - Reintegration der neuen Platte ins Raid
 - Boot-Loader auf die neue Platte schreiben
 
Dieses Dokument beschreibt den Austausch einer defekten Platte aus einem über Software-Raid realisierten Plattenspiegel.
Alle Raid-Aktion werden über das Kommandozeilentool «mdadm» realisiert. Dies steht im Gegensatz zur Vorgehensweise, wie sie in einem älteren Artikel vorgestellt wurde: Dort wurden die «raidtools» benutzt (10.10.2003 Plattenspiegel unter Linux anlegen).
1. Identifizierung und Austausch der defekten Platte
Zunächst muss mit «mdadm -D /dev/md?» ermittelt werden, welche der beiden Platten eigentlich defekt ist. Auch die Ausgabe von «dmesg» kann dabei hilfreich sein. Anhand dieser Angaben sollte es möglich sein, die defekte Platte physikalisch zu lokalisieren (SCSI-ID, IDE-Kanal, ...) und auszutauschen.2. Partitionierung
Zunächst schauen wir uns an, wie die überlebende Platte partitioniert ist:
 tux:~# fdisk -l /dev/sda
 Disk /dev/sda: 255 heads, 63 sectors, 8924 cylinders
 Units = cylinders of 16065 * 512 bytes
    Device Boot    Start       End    Blocks   Id  System
 /dev/sda1   *         1         2     16033+  fd  Linux raid autodetect
 /dev/sda2             3       245   1951897+  fd  Linux raid autodetect
 /dev/sda3           246       488   1951897+  fd  Linux raid autodetect
 /dev/sda4           489      8924  67762170   fd  Linux raid autodetect
 | 
Analog wird nun die neu eingebaute Platte partitioniert (Eingaben fett dargestellt):
 tux:~# fdisk /dev/sdb
 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 Building a new DOS disklabel. Changes will remain in memory only,
 until you decide to write them. After that, of course, the previous
 content won't be recoverable.
 The number of cylinders for this disk is set to 8924.
 There is nothing wrong with that, but this is larger than 1024,
 and could in certain setups cause problems with:
 1) software that runs at boot time (e.g., old versions of LILO)
 2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)
 Command (m for help): n
 Command action
    e   extended
    p   primary partition (1-4)
 p
 Partition number (1-4): 1
 First cylinder (1-8924, default 1): 
 Using default value 1
 Last cylinder or +size or +sizeM or +sizeK (1-8924, default 8924): 2
 Command (m for help): p
 Partition number (1-4): 2
 First cylinder (3-8924, default 3): 
 Using default value 3
 Last cylinder or +size or +sizeM or +sizeK (3-8924, default 8924): 245
 Command (m for help): n
 Command action
    e   extended
    p   primary partition (1-4)
 p
 Partition number (1-4): 3
 First cylinder (246-8924, default 246): 
 Using default value 246
 Last cylinder or +size or +sizeM or +sizeK (246-8924, default 8924): 488
 Command (m for help): n
 Command action
    e   extended
    p   primary partition (1-4)
 p
 Partition number (1-4): 4
 First cylinder (489-8924, default 489): 
 Using default value 489
 Last cylinder or +size or +sizeM or +sizeK (489-8924, default 8924): 
 Using default value 8924
 Command (m for help): t
 Partition number (1-4): 1
 Hex code (type L to list codes): fd>
 Changed system type of partition 1 to fd (Linux raid autodetect)
 Command (m for help): t
 Partition number (1-4): 2
 Hex code (type L to list codes): fd
 Changed system type of partition 2 to fd (Linux raid autodetect)
 Command (m for help): t>
 Partition number (1-4): 3
 Hex code (type L to list codes): fd
 Changed system type of partition 3 to fd (Linux raid autodetect)
 Command (m for help): t
 Partition number (1-4): 4
 Hex code (type L to list codes): fd
 Changed system type of partition 4 to fd (Linux raid autodetect)
 Command (m for help): w
 The partition table has been altered!
 Calling ioctl() to re-read partition table. 
 WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
 The kernel still uses the old table.
 The new table will be used at the next reboot.
 Syncing disks.
 | 
Wichtig ist, dass als Partitionstyp «fd» gewählt wird. Dieser Partitionstyp ist reserviert für Linux-Raid-Arrays. Nur so ist gewährleistet, dass das System automatisch von den gespiegelten Platten bootet.
Die letzte Meldung (WARNING: ...) besagt, dass an dieser Stelle ein System-Neustart angesagt ist,
damit wir mit der Reintegration der neuen Platte ins Raid weitermachen können:
3. Reintegration der neuen Platte ins Raid
Die Reintegration erfolgt partitionsweise:
tux:~# mdadm --add /dev/md0 /dev/sdb1 mdadm: hot added /dev/sdb1 tux:~# mdadm --add /dev/md1 /dev/sdb2 mdadm: hot added /dev/sdb2 tux:~# mdadm --add /dev/md2 /dev/sdb3 mdadm: hot added /dev/sdb3 tux:~# mdadm --add /dev/md3 /dev/sdb4 mdadm: hot added /dev/sdb4  | 
Die Überprüfung des Raid-Status erfolgt mit «mdadm -D». Dabei wird zunächst zusätzlich zur neuen auch die alte, ausgebaute Festplatte aufgeführt:
 tux:~# mdadm -D /dev/md2
 /dev/md2:
         Version : 00.90.00
   Creation Time : Fri Aug  9 17:33:15 2002
      Raid Level : raid1
      Array Size : 1951808 (1906.06 MiB 1998.65 MB)
     Device Size : 1951808 (1906.06 MiB 1998.65 MB)
      Raid Disks : 2
     Total Disks : 2
 Preferred Minor : 2
     Persistance : Superblock is persistant
 
     Update Time : Wed Nov 24 14:11:30 2004
           State : dirty, no-errors
   Active Drives : 1
  Working Drives : 2
   Failed Drives : 0
    Spare Drives : 1
     Number   Major   Minor   RaidDisk   State
        0       8        3        0      active sync   /dev/sda3
        1       0        0        1      faulty removed
        2       8       19        2        /dev/sdb3
            UUID : 123f9a8c:16fbf824:c2ecba52:8cfb7f8c
 | 
Dies ändert sich, sobald die Synchronisation abgeschlossen ist. Es ergibt sich etwa folgendes Bild:
 tux:~# mdadm -D /dev/md2
 /dev/md2:
         Version : 00.90.00
   Creation Time : Fri Aug  9 17:33:15 2002
      Raid Level : raid1
      Array Size : 1951808 (1906.06 MiB 1998.65 MB)
     Device Size : 1951808 (1906.06 MiB 1998.65 MB)
      Raid Disks : 2
     Total Disks : 2
 Preferred Minor : 2
     Persistance : Superblock is persistant
     Update Time : Wed Nov 24 14:12:08 2004
           State : dirty, no-errors
   Active Drives : 2
  Working Drives : 2
   Failed Drives : 0
    Spare Drives : 0
     Number   Major   Minor   RaidDisk   State
        0       8        3        0      active sync   /dev/sda3
        1       8       19        1      active sync   /dev/sdb3
            UUID : 123f9a8c:16fbf824:c2ecba52:8cfb7f8c
 | 
4. Boot-Loader auf die neue Platte schreiben
Zu guter Letzt wird der LILO neu geschrieben:
tux:~# lilo -b /dev/sdb Ignoring entry 'boot' Warning: /dev/sdb is not on the first disk Added Linux-2.4.28 * Added Linux-2.4.19 Added Linux-2.4.24  | 
Nun sollte wieder alles beim Alten sein und die nächste Platte kann ausfallen.
 unixwerk