Skip to contentSkip to conversation

RAID1 assembled broken array

DISCUSSION Matthias Urlichs 8 participants 20 messages Sep 15, 2009 – Sep 28, 2009 MD RAID

lore
Share & tools
lore
#0 lore raw

I had a somewhat strange error today.

One of my servers has a RAID1 array. Two partitions at the end of the disk; the RAID superblocks are at the end of the partition.

After a hard reboot today, one of the disks managed to not have its partition table scanned correctly, most probably because the disk was hung and the ("intelligent") controller got confused about it. After the initial scan, however, it came up correctly.

This error caused mdadm to "successfully" build a RAID1 from /dev/sda3 and /dev/sdb (instead of /dev/sdb3). Needless to say, the resulting volume was somewhat unuseable. To say the least.

My server's mdadm.conf has a 'DEVICE=partitions' line. I suppose that replacing these with a pattern that explicitly only matches partitions, not disks, would make the problem go away, and that the lesson from today's disaster recovery effort is to always explicitly list the allowed partition names, instead of being lazy and using 'DEVICE=partitions'.

#1 lore raw

Specifying partition names may cause problems if the disk names changed. Specify the UUID instead.

Quoted 27 lines · Matthias Urlichs

I had a somewhat strange error today.

One of my servers has a RAID1 array. Two partitions at the end of the disk; the RAID superblocks are at the end of the partition.

After a hard reboot today, one of the disks managed to not have its partition table scanned correctly, most probably because the disk was hung and the ("intelligent") controller got confused about it. After the initial scan, however, it came up correctly.

This error caused mdadm to "successfully" build a RAID1 from /dev/sda3 and /dev/sdb (instead of /dev/sdb3). Needless to say, the resulting volume was somewhat unuseable. To say the least.

My server's mdadm.conf has a 'DEVICE=partitions' line. I suppose that replacing these with a pattern that explicitly only matches partitions, not disks, would make the problem go away, and that the lesson from today's disaster recovery effort is to always explicitly list the allowed partition names, instead of being lazy and using 'DEVICE=partitions'.

--

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 5 lines
       Majed B.
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 3 lines · Majed B.

Specifying partition names may cause problems if the disk names changed. Specify the UUID instead.

What I was trying to say is "use a pattern that matches all of your partitions and none of your actual disks". That should be safe from changing disk file names.

Besides, specifying UUIDs does not work because it runs into the exact problem we're trying to solve in the first place. Behold the "blkid" output from the server in question:

/dev/sdb2: UUID="1583e643-7004-a86e-4eff-81c58ea53278" TYPE="mdraid" /dev/sdb: UUID="1583e643-7004-a86e-4eff-81c58ea53278" TYPE="mdraid"

Interestingly, for some reason it doesn't do that with /dev/sda -- most probably because the disks in question use different head/sector values and thus have slightly different partition layout.

#3 lore raw

Weird. I haven't seen that before on my disks/partitions.

user@Adam:~$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 2009-09-14 18:05
cf70cb2b-8e1e-44f3-b361-4a27e169eef2 -> ../../sdi1
lrwxrwxrwx 1 root root 10 2009-09-14 18:05
f54698f9-72a0-4226-9ada-34af2699a25c -> ../../sdi5

My array is offline at the moment, so I can't print the disks' info, but as you can see, each partition has its own UUID, and if each partition belonged to a different array then it would have a different UUID.

Sorry for your loss :/

Quoted 20 lines · Matthias Urlichs
Quoted 3 lines · Majed B.

Specifying partition names may cause problems if the disk names changed. Specify the UUID instead.

What I was trying to say is "use a pattern that matches all of your partitions and none of your actual disks". That should be safe from changing disk file names.

Besides, specifying UUIDs does not work because it runs into the exact problem we're trying to solve in the first place. Behold the "blkid" output from the server in question:

/dev/sdb2: UUID="1583e643-7004-a86e-4eff-81c58ea53278" TYPE="mdraid" /dev/sdb: UUID="1583e643-7004-a86e-4eff-81c58ea53278" TYPE="mdraid"

Interestingly, for some reason it doesn't do that with /dev/sda -- most probably because the disks in question use different head/sector values and thus have slightly different partition layout.

Signature · 1 line
       Majed B.
#4 lore raw
Quoted 9 lines · Majed B.

Weird. I haven't seen that before on my disks/partitions.

user@Adam:~$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 2009-09-14 18:05
cf70cb2b-8e1e-44f3-b361-4a27e169eef2 -> ../../sdi1
lrwxrwxrwx 1 root root 10 2009-09-14 18:05
f54698f9-72a0-4226-9ada-34af2699a25c -> ../../sdi5
Quoted 4 lines

My array is offline at the moment, so I can't print the disks' info, but as you can see, each partition has its own UUID, and if each partition belonged to a different array then it would have a different UUID.

As did Matthias' setup. However, if you fail to read the partition table on a device, *and* the superblock on any given partition is in the exact same location as it would be if you put a superblock on the entire device, then mdadm can get confused and think the superblock belongs to the entire device and not just the partition that the superblock is at the end of. When that happens, it will think the data starts at block 0 of the drive, instead of block 0 of the partition and the data read will be inconsistent. That's what happened to Matthias.

Quoted 16 lines

Sorry for your loss :/

On Tue, Sep 15, 2009 at 10:33 PM, Matthias Urlichs <[email protected]

Quoted 13 lines

wrote:

Quoted 3 lines · Majed B.

Specifying partition names may cause problems if the disk names changed. Specify the UUID instead.

What I was trying to say is "use a pattern that matches all of your partitions and none of your actual disks". That should be safe from changing disk file names.

Besides, specifying UUIDs does not work because it runs into the exact problem we're trying to solve in the first place. Behold the "blkid" output from the server in question:

Quoted 17 lines
Quoted 8 lines

/dev/sdb2: UUID="1583e643-7004-a86e-4eff-81c58ea53278" TYPE="mdraid" /dev/sdb: UUID="1583e643-7004-a86e-4eff-81c58ea53278" TYPE="mdraid"

Interestingly, for some reason it doesn't do that with /dev/sda -- most probably because the disks in question use different head/sector values and thus have slightly different partition layout.

Signature · 5 lines
      Majed B.
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--

Doug Ledford <[email protected]>

GPG KeyID: CFBFF194
http://people.redhat.com/dledford

InfiniBand Specific RPMS
http://people.redhat.com/dledford/Infiniband

#5 lore raw
In reply to Matthias Urlichs
Quoted 14 lines · Matthias Urlichs

I had a somewhat strange error today.

One of my servers has a RAID1 array. Two partitions at the end of the disk; the RAID superblocks are at the end of the partition.

After a hard reboot today, one of the disks managed to not have its partition table scanned correctly, most probably because the disk was hung and the ("intelligent") controller got confused about it. After the initial scan, however, it came up correctly.

This error caused mdadm to "successfully" build a RAID1 from /dev/sda3 and /dev/sdb (instead of /dev/sdb3). Needless to say, the resulting volume was somewhat unuseable. To say the least.

Quoted 5 lines

My server's mdadm.conf has a 'DEVICE=partitions' line. I suppose that replacing these with a pattern that explicitly only matches partitions, not disks, would make the problem go away, and that the lesson from today's disaster recovery effort is to always explicitly list the allowed partition names, instead of being lazy and using 'DEVICE=partitions'.

Wrong lesson. The correct lesson to gather from this is to prefer version 1.1 or 1.2 superblocks wherever possible. Superblocks at the beginning of the device disappear when there is no partition table, superblocks at the end can be confused for superblocks belonging to the whole device when there is no partition table.

--

Doug Ledford <[email protected]>

GPG KeyID: CFBFF194
http://people.redhat.com/dledford

InfiniBand Specific RPMS
http://people.redhat.com/dledford/Infiniband

#6 lore raw
Quoted 2 lines · Doug Ledford

Wrong lesson. The correct lesson to gather from this is to prefer version 1.1 or 1.2 superblocks wherever possible.

Thanks for reminding me. I _knew_ there was something I should have added to that conclusion. :-/

#7 lore raw
In reply to Doug Ledford
Quoted 25 lines · Doug Ledford
Quoted 15 lines · Matthias Urlichs

I had a somewhat strange error today.

One of my servers has a RAID1 array. Two partitions at the end of the disk; the RAID superblocks are at the end of the partition.

After a hard reboot today, one of the disks managed to not have its partition table scanned correctly, most probably because the disk was hung and the ("intelligent") controller got confused about it. After the
initial scan, however, it came up correctly.

This error caused mdadm to "successfully" build a RAID1 from /dev/sda3 and /dev/sdb (instead of /dev/sdb3). Needless to say, the resulting volume was somewhat unuseable. To say the least.

Quoted 7 lines

My server's mdadm.conf has a 'DEVICE=partitions' line. I suppose that replacing these with a pattern that explicitly only matches partitions,
not disks, would make the problem go away, and that the lesson from today's disaster recovery effort is to always explicitly list the allowed
partition names, instead of being lazy and using 'DEVICE=partitions'.

Quoted 5 lines

Wrong lesson. The correct lesson to gather from this is to prefer version 1.1 or 1.2 superblocks wherever possible. Superblocks at the beginning of the device disappear when there is no partition table, superblocks at the end can be confused for superblocks belonging to the whole device when there is no partition table.

1.0 also protects from this problem. The 1.x metadata stores the offset of the superblock from the start of the device. That will appear to be wrong if you find a partition-superblock when reading from a whole-device, so mdadm will reject the device as not having a valid superblock.

NeilBrown

#8 lore raw
Quoted 1 line · NeilBrown

1.0 also protects from this problem.

So what's the best way to update a 0.9 superblock to 1.0 format?

mdadm --assemble --metadata=1.0 --update=summaries ... ?

#9 lore raw
Quoted 6 lines · Matthias Urlichs
Quoted 1 line · NeilBrown

1.0 also protects from this problem.

So what's the best way to update a 0.9 superblock to 1.0 format?

mdadm --assemble --metadata=1.0 --update=summaries ... ?

I don't think you can. You just have to create a new array with the new superblock.

--

Doug Ledford <[email protected]>

GPG KeyID: CFBFF194
http://people.redhat.com/dledford

InfiniBand Specific RPMS
http://people.redhat.com/dledford/Infiniband

#10 lore raw
Quoted 9 lines · Doug Ledford
Quoted 5 lines
Quoted 1 line

1.0 also protects from this problem.

So what's the best way to update a 0.9 superblock to 1.0 format?

mdadm --assemble --metadata=1.0 --update=summaries ... ?

I don't think you can. You just have to create a new array with the new superblock.

Hmm. Looks like you're right.

Consider this to be a feature request, then. If 1.0 is more reasonable than 0.9, there should be a "safe" upgrade path.

#11 lore raw

0.9 shouldn't be the default if 1.0 or 1.x is better anyway :/

Quoted 20 lines · Matthias Urlichs
Quoted 9 lines · Doug Ledford
Quoted 5 lines
Quoted 1 line

1.0 also protects from this problem.

So what's the best way to update a 0.9 superblock to 1.0 format?

mdadm --assemble --metadata=1.0 --update=summaries ... ?

I don't think you can.  You just have to create a new array with the new superblock.

Hmm. Looks like you're right.

Consider this to be a feature request, then. If 1.0 is more reasonable than 0.9, there should be a "safe" upgrade path.

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 5 lines
       Majed B.
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw
In reply to Matthias Urlichs
Quoted 7 lines · On Thursday September 17, [email protected] wrote:
Quoted 6 lines · Doug Ledford
Quoted 5 lines
Quoted 1 line

1.0 also protects from this problem.

So what's the best way to update a 0.9 superblock to 1.0 format?

mdadm --assemble --metadata=1.0 --update=summaries ... ?

Quoted 7 lines
Quoted 3 lines

I don't think you can. You just have to create a new array with the new superblock.

Hmm. Looks like you're right.

Consider this to be a feature request, then. If 1.0 is more reasonable than 0.9, there should be a "safe" upgrade path.

Yes, definitely. There should be.

Now if only there were more hours in the day.... :-)

NeilBrown

#13 lore raw
In reply to NeilBrown
Quoted 11 lines · NeilBrown
Quoted 5 lines

Wrong lesson. The correct lesson to gather from this is to prefer version 1.1 or 1.2 superblocks wherever possible. Superblocks at the beginning of the device disappear when there is no partition table, superblocks at the end can be confused for superblocks belonging to the whole device when there is no partition table.

1.0 also protects from this problem. The 1.x metadata stores the offset of the superblock from the start of the device. That will appear to be wrong if you find a partition-superblock when reading from a whole-device, so mdadm will reject the device as not having a valid superblock.

BTW: Why are new arrays still created with 0.90 metadata format by default?

Andre

Signature · 1 line
The only person who always got his work done by Friday was Robinson Crusoe
#14 lore raw
Quoted 7 lines · On Thursday September 17, [email protected] wrote:
Quoted 6 lines · NeilBrown
Quoted 5 lines

Wrong lesson. The correct lesson to gather from this is to prefer version 1.1 or 1.2 superblocks wherever possible. Superblocks at the beginning of the device disappear when there is no partition table, superblocks at the end can be confused for superblocks belonging to the whole device when there is no partition table.

Quoted 8 lines
Quoted 5 lines

1.0 also protects from this problem. The 1.x metadata stores the offset of the superblock from the start of the device. That will appear to be wrong if you find a partition-superblock when reading from a whole-device, so mdadm will reject the device as not having a valid superblock.

BTW: Why are new arrays still created with 0.90 metadata format by default?

Because I'm a chicken....

I guess it probably is time ... but to we make the default 1.0, which is compatible with people's expectations, to 1.1 which is generally a safer approach (you cannot mount a bare device by mistake).

Of course a distro can import their own default using the CREATE line in mdadm.conf.

NeilBrown

#15 lore raw
Quoted 10 lines · Neil Brown
Quoted 2 lines · On Thursday September 17, [email protected] wrote:

BTW: Why are new arrays still created with 0.90 metadata format by default?

Because I'm a chicken....

I guess it probably is time ... but to we make the default 1.0, which is compatible with people's expectations, to 1.1 which is generally a safer approach (you cannot mount a bare device by mistake).

One problem with 1.x metadata formats is that you can't assemble them at boot time without building an initrd/initramfs containing userspace to put them together. An md=0,xxx kernel argument only appears to work for 0.90 superblocks. (Would you accept a patch to fix this; it doesn't feel like it should be particularly hard?)

Another issue with 1.1 and 1.2 metadata is that you can't make a mirror out of sd*, install a bootloader (e.g. extlinux) on the md, and then boot the corresponding system. That said, I guess it wouldn't be hard to make a little 'mbr' that understands the data offset in the md 1.2 container, so if I'm honest, it's just laziness that keeps me using 0.90 where it works out of the box without the need to hack any bootloader code or create untidy partitions just for booting.

Best wishes,

Chris.

#16 lore raw
In reply to Neil Brown
Quoted 8 lines · Neil Brown
Quoted 2 lines

BTW: Why are new arrays still created with 0.90 metadata format by default?

Because I'm a chicken....

I guess it probably is time ... but to we make the default 1.0, which is compatible with people's expectations, to 1.1 which is generally a safer approach (you cannot mount a bare device by mistake).

People will soon have to use 1.x anyway as drives are getting bigger than 2T. I'd vote for making 1.1 or 1.2 metadata the default for the reasons Doug pointed out. Failing to mount the bare device if there is a partition table is IMHO more important than meeting (broken) expectations.

Maybe we should depricate kernel-level autodetection at the same time so that using an initramfs becomes mandatory for setups with / on md.

Best
Andre

Signature · 1 line
The only person who always got his work done by Friday was Robinson Crusoe
#17 lore raw
Quoted 9 lines · Andre Noll
Quoted 7 lines · Neil Brown
Quoted 2 lines

BTW: Why are new arrays still created with 0.90 metadata format by default?

Because I'm a chicken....

I guess it probably is time ... but to we make the default 1.0, which is compatible with people's expectations, to 1.1 which is generally a safer approach (you cannot mount a bare device by mistake).

Quoted 8 lines

People will soon have to use 1.x anyway as drives are getting bigger than 2T. I'd vote for making 1.1 or 1.2 metadata the default for the reasons Doug pointed out. Failing to mount the bare device if there is a partition table is IMHO more important than meeting (broken) expectations.

Maybe we should depricate kernel-level autodetection at the same time so that using an initramfs becomes mandatory for setups with / on md.

It already is deprecated; afaik all the recent distros already use an initramfs, even if they still use 0.90 metadata.

I second making this a priority to get into the next round of distro updates, for all the reasons given. As soon as metadata version upgrade facilities go in to mdadm, 0.90 metadata can also be deprecated and perhaps mdadm can issue warnings, or at least the kernel autoassembly code can start issuing warnings (if it doesn't already).

Cheers,

John.

#18 lore raw
Quoted 18 lines
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

BTW: Why are new arrays still created with 0.90 metadata format by default?

Because I'm a chicken....

I guess it probably is time ... but to we make the default 1.0, which is compatible with people's expectations, to 1.1 which is generally a safer approach (you cannot mount a bare device by mistake).

Quoted 8 lines

People will soon have to use 1.x anyway as drives are getting bigger than 2T. I'd vote for making 1.1 or 1.2 metadata the default for the reasons Doug pointed out. Failing to mount the bare device if there is a partition table is IMHO more important than meeting (broken) expectations.

Maybe we should depricate kernel-level autodetection at the same time so that using an initramfs becomes mandatory for setups with / on md.

Quoted 8 lines

It already is deprecated; afaik all the recent distros already use an initramfs, even if they still use 0.90 metadata.

I second making this a priority to get into the next round of distro updates, for all the reasons given. As soon as metadata version upgrade facilities go in to mdadm, 0.90 metadata can also be deprecated and perhaps mdadm can issue warnings, or at least the kernel autoassembly code can start issuing warnings (if it doesn't already).

All this talk of metadata 1.x, what about all the metadata 0.90 RAID
array's out there? What is needed for an upgrade or conversion? Would a conversion program need to understand the under lying filesystem?

Thanks
Mailed
LeeT

#19 lore raw
Quoted 6 lines · Clinton Lee Taylor
Quoted 6 lines
Quoted 2 lines

Maybe we should depricate kernel-level autodetection at the same time so that using an initramfs becomes mandatory for setups with / on md.

It already is deprecated; afaik all the recent distros already use an initramfs, even if they still use 0.90 metadata.

Quoted 8 lines
Quoted 5 lines

I second making this a priority to get into the next round of distro updates, for all the reasons given. As soon as metadata version upgrade facilities go in to mdadm, 0.90 metadata can also be deprecated and perhaps mdadm can issue warnings, or at least the kernel autoassembly code can start issuing warnings (if it doesn't already).

All this talk of metadata 1.x, what about all the metadata 0.90 RAID
array's out there? What is needed for an upgrade or conversion?

We're just talking about making 1.x the default for creating _new_ arrays. The old v0.90 metadata format will still be supported for years. However, if one could easily upgrade from v0.90 to v1.x metadata, we could stop supporting the old format a bit earlier.

It would be good enough to teach mdadm to convert the superblocks of inactive arrays only.

Quoted 2 lines

Would a conversion program need to understand the under lying filesystem?

No.

Regards
Andre

Signature · 1 line
The only person who always got his work done by Friday was Robinson Crusoe