Skip to contentSkip to conversation

mdadm and automatic re-add / incremental mode with usb-disk

DISCUSSION Wilhelm Meier 4 participants 8 messages Nov 30, 2008 – Dec 1, 2008 MD RAID

lore
Share & tools
lore
#0 lore raw

Hi,

I'm using debian etch with mdadm 2.5.6-9.

I have a md-device /dev/md1000 with two usb-disks as raid1. The array is assembled well if the system boots, if I unplug one of the disks, the array goes to degraded. Thats all ok.

If I re-plug the usb-disk, udev discovers the device fine, but mdadm doesn't start the re-add to the md-array. I have to do this but hand.

Is there something missing to make this work automatically?

I tried the mdm-2.6.2 from etch-backports too. Same effect.

Here, if I try to use the --incremental mode, it constructs a new (!) array /dev/md/d_1000 instead of adding it to /dev/md1000. Thats strange to me.

I thought I got it working some weeks ago (maybe with earlier / other versions of mdadm or somme missing other tool), but I can't get the puzzle right now.

Any hints?

Signature · 1 line
Wilhelm
#1 lore raw
Quoted 19 lines · Wilhelm Meier

Hi,

I'm using debian etch with mdadm 2.5.6-9.

I have a md-device /dev/md1000 with two usb-disks as raid1. The array is assembled well if the system boots, if I unplug one of the disks, the array goes to degraded. Thats all ok.

If I re-plug the usb-disk, udev discovers the device fine, but mdadm doesn't start the re-add to the md-array. I have to do this but hand.

Is there something missing to make this work automatically?

I tried the mdm-2.6.2 from etch-backports too. Same effect.

Here, if I try to use the --incremental mode, it constructs a new (!) array /dev/md/d_1000 instead of adding it to /dev/md1000. Thats strange to me.

Quoted 12 lines

I thought I got it working some weeks ago (maybe with earlier / other versions of mdadm or somme missing other tool), but I can't get the puzzle right now.

Any hints?

Signature · 5 lines
Wilhelm
--
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

Wilhelm,

As far as I know mdadm never will re-add a broken/failed/disconnected disk back into the array. Perhaps what you saw before is on an un-clean shutdown or something similar, upon reboot the array is checking/re-initializing.

When you have a failed drive and you re-attach it, it will stay as a removed unit and you need to remove it and add it manually as you stated.

Were you seeing something other than this before?

Justin.

#2 lore raw

Am Sonntag 30 November 2008 schrieb Justin Piszcz:

Quoted 34 lines · Wilhelm Meier
Quoted 24 lines

Hi,

I'm using debian etch with mdadm 2.5.6-9.

I have a md-device /dev/md1000 with two usb-disks as raid1. The array is assembled well if the system boots, if I unplug one of the disks, the array goes to degraded. Thats all ok.

If I re-plug the usb-disk, udev discovers the device fine, but mdadm doesn't start the re-add to the md-array. I have to do this but hand.

Is there something missing to make this work automatically?

I tried the mdm-2.6.2 from etch-backports too. Same effect.

Here, if I try to use the --incremental mode, it constructs a new (!) array /dev/md/d_1000 instead of adding it to /dev/md1000. Thats strange to me.

I thought I got it working some weeks ago (maybe with earlier / other versions of mdadm or somme missing other tool), but I can't get the puzzle right now.

Quoted 8 lines

Any hints?
--
Wilhelm
--
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

Quoted 6 lines

Wilhelm,

As far as I know mdadm never will re-add a broken/failed/disconnected disk back into the array. Perhaps what you saw before is on an un-clean shutdown or something similar, upon reboot the array is checking/re-initializing.

That might be, but what is the difference between doing the re-add and re-sync on boot (that's what happens!) or if the drive comes back on a running system.

mdadm can surely determine the state/uuid and do this - the same as on reboot.

Quoted 3 lines

When you have a failed drive and you re-attach it, it will stay as a removed unit and you need to remove it and add it manually as you stated.

the only thing I have to do is e.g.

mdadm --re-add /dev/md1000 /dev/sdg1

then it starts reconstructing the right way.

So, my thought was to do this as part of a udev-rule. But I think this is a common case and therefore there should be a well-known solution

Quoted 1 line

Were you seeing something other than this before?

I might be wrong, but I thought it was on debian ...

Quoted 5 lines

Justin.
--
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 · 1 line
Wilhelm
#3 lore raw
Quoted 6 lines · Wilhelm Meier

Am Sonntag 30 November 2008 schrieb Justin Piszcz:

Quoted 1 line · Wilhelm Meier

That might be, but what is the difference between doing the re-add and re-sync on boot (that's what happens!) or if the drive comes back on a running system.

From the docs, when you remove and re-add it would appear to be a 'reocover' whereas an unclean shutdown would be resyncing (or repair if you do not have a bitmap).

linux-2.6.27.7/Documentation/md.txt (actually a good doc to read btw)

resync - redundancy is being recalculated after unclean
shutdown or creation
recover - a hot spare is being built to replace a
failed/missing device
repair - A full check and repair is happening. This is
similar to 'resync', but was requested by the user, and the write-intent bitmap is NOT used to
optimise the process.

Quoted 10 lines

mdadm can surely determine the state/uuid and do this - the same as on reboot.

Quoted 3 lines

When you have a failed drive and you re-attach it, it will stay as a removed unit and you need to remove it and add it manually as you stated.

the only thing I have to do is e.g.

Quoted 7 lines

mdadm --re-add /dev/md1000 /dev/sdg1

then it starts reconstructing the right way.

So, my thought was to do this as part of a udev-rule. But I think this is a common case and therefore there should be a well-known solution

Yeah I suppose you could do something like this. Is the purpose more or less to have a portable raid1 array?

Justin.

#4 lore raw

Am Sonntag 30 November 2008 schrieb Justin Piszcz:

Quoted 15 lines · Wilhelm Meier
Quoted 6 lines

Am Sonntag 30 November 2008 schrieb Justin Piszcz:

Quoted 1 line · Wilhelm Meier

That might be, but what is the difference between doing the re-add and re-sync on boot (that's what happens!) or if the drive comes back on a running system.

From the docs, when you remove and re-add it would appear to be a 'reocover' whereas an unclean shutdown would be resyncing (or repair if you do not have a bitmap).

linux-2.6.27.7/Documentation/md.txt (actually a good doc to read btw)

Quoted 7 lines

resync - redundancy is being recalculated after
unclean shutdown or creation
recover - a hot spare is being built to replace a
failed/missing device
repair - A full check and repair is happening. This
is similar to 'resync', but was requested by the user, and the write-intent bitmap is NOT used to optimise the process.

Oh yes, I mean "recover", thats what is happening after the manual re-add if I unplug und then replug the usb-disk.

Quoted 12 lines
Quoted 12 lines

mdadm can surely determine the state/uuid and do this - the same as on reboot.

Quoted 3 lines

When you have a failed drive and you re-attach it, it will stay as a removed unit and you need to remove it and add it manually as you stated.

the only thing I have to do is e.g.

mdadm --re-add /dev/md1000 /dev/sdg1

Quoted 8 lines
Quoted 5 lines

then it starts reconstructing the right way.

So, my thought was to do this as part of a udev-rule. But I think this is a common case and therefore there should be a well-known solution

Yeah I suppose you could do something like this. Is the purpose more or less to have a portable raid1 array?

Yes, exactly.
I want to have a portable usb-raid of 2 disks (or 2x2 with lvm on top) and I want to plug and unplug the disks freely.

Signature · 1 line
Wilhelm
#6 lore raw
In reply to Wilhelm Meier
Quoted 4 lines · Wilhelm Meier

Hi,

I'm using debian etch with mdadm 2.5.6-9.

Quoted 8 lines

I have a md-device /dev/md1000 with two usb-disks as raid1. The array is assembled well if the system boots, if I unplug one of the disks, the array goes to degraded. Thats all ok.

If I re-plug the usb-disk, udev discovers the device fine, but mdadm doesn't start the re-add to the md-array. I have to do this but hand.

Is there something missing to make this work automatically?

You would need to put some magic in udev.
Something in /etc/udev/rules.d would need to do something like
RUN+="/sbin/mdadm -I ..the..device.name"

if the detected device was one that you want to be added to an array. I have tried this yet so I don't know the details of how to make it work.

Quoted 6 lines

I tried the mdm-2.6.2 from etch-backports too. Same effect.

Here, if I try to use the --incremental mode, it constructs a new (!) array /dev/md/d_1000 instead of adding it to /dev/md1000. Thats strange to me.

--incremental only works properly if the array was created by --incremental. You might be able to make it work better by running
mdadm -Ir

first. This recreates /var/run/mdadm/map.

Good luck!

NeilBrown

#7 lore raw

Am Montag 01 Dezember 2008 schrieb NeilBrown:

Quoted 13 lines · Wilhelm Meier
Quoted 12 lines

Hi,

I'm using debian etch with mdadm 2.5.6-9.

I have a md-device /dev/md1000 with two usb-disks as raid1. The array is assembled well if the system boots, if I unplug one of the disks, the array goes to degraded. Thats all ok.

If I re-plug the usb-disk, udev discovers the device fine, but mdadm doesn't start the re-add to the md-array. I have to do this but hand.

Quoted 5 lines
Quoted 1 line

Is there something missing to make this work automatically?

You would need to put some magic in udev.
Something in /etc/udev/rules.d would need to do something like
RUN+="/sbin/mdadm -I ..the..device.name"

Yes, I tried that and it works half-the-way: as I wrote in another posting, mdadm -I does not allow the -c configfile option. Because I use a different config for a special set of devices, mdadm -I does not know the uuid's of the arrays of this special config file and therefore creates a new array with a different naming scheme (and different major/minor dev-numbers) (see below).

Quoted 5 lines

if the detected device was one that you want to be added to an array. I have tried this yet so I don't know the details of how to make it work.

Quoted 8 lines
Quoted 5 lines

I tried the mdm-2.6.2 from etch-backports too. Same effect.

Here, if I try to use the --incremental mode, it constructs a new (!) array /dev/md/d_1000 instead of adding it to /dev/md1000. Thats strange to me.

--incremental only works properly if the array was created by --incremental.

Thats a point I don't understand.
Should I use --increment instead of normal creation and later --assemble?
Why is this different?
Can this work together, I mean: can I --assemble arrays (as most distros do that on boot) and later --incremental create/reconstruct other arrays?

Quoted 5 lines

You might be able to make it work better by
running
mdadm -Ir

first. This recreates /var/run/mdadm/map.

Signature · 1 line
Wilhelm
#5 lore raw
In reply to Wilhelm Meier
Quoted 2 lines · Wilhelm Meier

That might be, but what is the difference between doing the re-add and re-sync on boot (that's what happens!)

Nope, that's not what happens. What happens is a re-sync, not a re-add. Drives are never automagically re-added to an array. Once arrays are so far out of sync that a re-add is needed, you always have to do it manually, reboot or not.

Quoted 1 line

or if the drive comes back on a running system.

The drive could be buggy, could have a buggy connection, whatever. The reason for a drive disappearing and re-appearing is not always a user plugging it out and in.

Quoted 1 line

So, my thought was to do this as part of a udev-rule.

Of course, you can do this yourself via some scripting. And if you think it is safe for you, move on. But then you have no reason to cry once those automatisms broke your system :)

regards
Mario

Signature · 2 lines
The problem in the world today is communication. Too much communication.
                                                     -- Homer J. Simpson