mdadm misdetects disks instead of partitions

Bug #599515 reported by Casandro
36
This bug affects 7 people
Affects Status Importance Assigned to Milestone
debian-installer (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: mdadm

When building a RAID5 with mdadm mdadm confuses partitions and disks if the partition ends with the disk.

Steps to reproduce: (in my case
1. Take 4 500G harddisks.
2. Add a 2 gigabyte partition to each of them
3. Use the rest as a logical partition for the raid
4. create a raid5 raid with /dev/sd?5

mdadm --misc --examine /dev/sd? will show precisely the same as
mdadm --misc --examine /dev/sd?5
On reboot the raid will use /dev/sd? instead of /dev/sd?5 either sd? will be inaccessable because another partition has been mounted before, resulting in a degrades raid, or after starting the raid other partitions will not be accessable.

Possible solution:
Fix mdadm so it first looks for superblocks on the partitions. If it found a superblock there, skip checking for the superblock of the device.

Revision history for this message
Casandro (casandro) wrote :

Quick fix:

in mdadm.conf
replace DEVICE partitions
by DEVICE /dev/sd??
Its not clean, but gets rid of a lot of trouble.

Revision history for this message
John Edwards (john-cornerstonelinux) wrote :

I can confirm this after installing Ubuntu 10.04.1 server with two 500GB disks with two RAID1 partitions (1st 20GB for rootfs, the rest for LVM). The 2nd RAID is incorrectly setup as /dev/sda and /dev/sdb.

Zero'ing the superblock on /dev/sda results in the superblock on /dev/sda2 going as well.

Item 11 in this obscure Debian mdadm FAQ maybe related, though I did not see the same error message:
http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=blob_plain;f=debian/FAQ;hb=HEAD

I think the problem lies with the partitioner in the installer using every available KB of space at the end of the disk, resulting in the superblock area for /dev/sda and /dev/sda2 overlapping. For details on where the superblock is stored see:
    https://raid.wiki.kernel.org/index.php/RAID_superblock_formats

The workaround I used was to end the partitions a few MB from the end of the disk.

affects: mdadm (Ubuntu) → debian-installer (Ubuntu)
Revision history for this message
MrGuga (mrguga) wrote :

Thanks for the quick fix, Casandro, and for the explanation, John Edwards. I was almost hitting my head on my keyboard after 22h looking for a solution.
Casandro's quick fix did the trick for me. But next time i do this i'll definately leave some free kb at the end of the disk.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in debian-installer (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.