replaced disk in software mirror RAID

Using OpenSUSE 11.1 with a pair of software raid mirrored 750GB Seagate drives and sdb died. The mirror is md0-100GB, md1-200GB, md2-200gb, md3-200GB and the leftover on md4 (not currently used)

When sdb failed I was delighted that the system kept running on the mirror.

I replaced sdb with a similar but bigger Seagate drive under warranty. The geometry seems the same but parted (YAST Partition tool anyway) isn’t happy with it.

I still have md0, md1, md2 and md3 which are all on sda and running OK.

Not being very experienced I need some guidance please - how do I convert the new drive so it becomes the mirror of sda?

It is important I do not wreck the existing setup.

Thanks for any help

Suzan

This is for Gentoo but is a very good howto for various RAID setup and maintenance operations. First make sure the failed partitions are marked failed. Should happen automatically but manually fail them with madam if you have to.

Scroll down to Misc for how to copy the partition setup from sda to sdb using sfdisk twice in a pipe. You will have leftover space on the replacement disk but it will otherwise be a copy of sda’s partitions. But check the command line several times before hitting return to make sure you haven’t mixed up the disks. After the partitioning, readd the missing partitions and they will automatically resync.

RAID/Software - Gentoo Linux Wiki

Thanks ken_yap - unfortunately I’m not succeeding with the piped sfdisk …

~ # sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now …
OK

Disk /dev/sdb: 0 cylinders, 255 heads, 63 sectors/track
read: Invalid argument

sfdisk: read error on /dev/sdb - cannot read sector 0
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
Warning: given size (25157790) exceeds max allowable size (0)

sfdisk: bad input
~ #

… here is sfdisk -V …

~ # sfdisk -V /dev/sda
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
/dev/sda: OK
~ #
~ # sfdisk -V /dev/sdb
read: Invalid argument

sfdisk: read error on /dev/sdb - cannot read sector 0
/dev/sdb: unrecognized partition table type

sfdisk: no partition table present.
~ #

… and the list of partitions on sda …

~ # sfdisk -l /dev/sda

Disk /dev/sda: 91201 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sda1 1 1566 1566 12578895 82 Linux swap / Solaris
/dev/sda2 1567 14620 13054 104856255 fd Linux raid autodetect
/dev/sda3 14621 40728 26108 209712510 fd Linux raid autodetect
/dev/sda4 40729 91200 50472 405416340 f W95 Ext’d (LBA)
/dev/sda5 40729+ 66836 26108- 209712478+ fd Linux raid autodetect
/dev/sda6 66837+ 91200 24364- 195703798+ 83 Linux

I did think I might use dd to overwrite sector 0 on sdb with something appropriate but I’m outta my depth.

What should I do next?

Suzan

Doesn’t look like sdb is healthy. Are there any signs that it’s detected in the output of dmesg?

You could try to create the partition layout manually using fdisk on sdb and see if that gives any errors.

OK - some progress but no cigar :slight_smile:

I used a live CD from a magazine and managed to create a set of partitions on sdb which match those on sda. I also changed the partition type of /dev/sda6 from 0x83 to 0xFD ready to test or practice making /dev/md3 (which used to exist but I changed it after sdb disk failure and exported it as a samba drive) sda6 is safely backed up so I can afford to blow it away if I blunder.

After restart, the Yast partitioner (Suse 11.1) can see all the partitions on both sda and sdb. Those on sda are still listed as part of md0, md1 and md3.

I have studied mdadm for an hour now and am just getting more confused. I’m going to see if I can find a tutorial.

Suzan

You need to use mdadm to readd each missing sdb partition to its corresponding RAID array. Look for a tute on mdadm commands. However if you changed any sda partitions, I don’t think you can switch it back to RAID easily.