Website-Icon .: blog cscholz.io :.

Debian: rebuild Software RAID

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 später auszutauschen.

Partitionierung

Zunächst schauen wir uns an, wie die überlebende Platte partitioniert ist:

tux:~# fdisk -l /dev/sdaDisk /dev/sda: 1610 MB, 1610612736 bytes
255 heads, 63 sectors/track, 195 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sda1 * 1 73 586341 fd Linux raid autodetect
/dev/sda2 74 195 979965 5 Extended
/dev/sda5 74 85 96358+ fd Linux raid autodetect
/dev/sda6 86 195 883543+ fd Linux raid autodetect

Jetzt entweder eine zweite Shell öffnen oder die Partitionierungsinformationen abschreiben.
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): 73
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
Partition number (1-4): 2
First cylinder (3-8924, default 3): 74
Using default value 3
Last cylinder or +size or +sizeM or +sizeK (3-8924, default 8924): 195
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
Partition number (1-4): 3
First cylinder (246-8924, default 246): 74
Using default value 246
Last cylinder or +size or +sizeM or +sizeK (246-8924, default 8924): 85
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
Partition number (1-4): 4
First cylinder (489-8924, default 489): 86
Using default value 489
Last cylinder or +size or +sizeM or +sizeK (489-8924, default 8924): 195
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.

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/sdb3mdadm: hot added /dev/sdb3
tux:~# mdadm --add /dev/md3 /dev/sdb4
mdadm: hot added /dev/sdb4Die Ü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 persistantUpdate 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:8cfb7f8cDies ä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 persistantUpdate 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

Boot-Loader auf die neue Platte schreiben

Lilo
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.24Grub
grub
device (h0) /dev/sdb
root (hd0,0)
setup (hd0)

Nun sollte wieder alles beim Alten sein und die nächste Platte kann ausfallen.

Funktionales Array

# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md2 : active raid1 hda3[1] hdb3[0]
262016 blocks [2/2] [UU] md1 : active raid1 hda2[1] hdb2[0]
119684160 blocks [2/2] [UU]md0 : active raid1 hda1[1] hdb1[0]
102208 blocks [2/2] [UU]unused devices: <none>

Defektes Array

Personalities : [raid1]
read_ahead 1024 sectors
md0 : active raid1 hda1[1]
102208 blocks [2/1] [_U] md2 : active raid1 hda3[1]
262016 blocks [2/1] [_U]md1 : active raid1 hda2[1]
119684160 blocks [2/1] [_U]
unused devices: <none>

Um lediglich einen Datenträger der sich aufgrund eines Fehlers ausgeklingt hat wieder neu einzubinden kann dieser aus- und direkt wieder eingebunden werden:

mdadm /dev/md0 -r /dev/sdb1
mdadm /dev/md1 -r /dev/sdb3
mdadm /dev/md0 -a /dev/sdb1
mdadm /dev/md1 -a /dev/sdb3

Der Status kann wiefolgt angezeigt werden

watch -n1 cat /proc/mdstat 

download als PDF

Die mobile Version verlassen