LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1592|回复: 8

uestion Two: RAID mdadm hot add device "Invalid argument"

[复制链接]
发表于 2005-10-3 09:34:52 | 显示全部楼层 |阅读模式
In RHEL 4.0, trying to manage my raid 1 device using mdadm.

1. create raid 1, OK.
mdadm -C /dev/md0 -l1 --raid-devices=2 /dev/hda11 /dev/hda12 --spare-devices=1 /dev/hda13

2. set faulty, OK.
mdadm /dev/md0 -f /dev/hda12

3. hot remove device, OK.
mdadm /dev/md0 -r /dev/hda12

4. hot add device (add the previous spare device as active)
mdadm /dev/md0 -a /dev/hda13

Here I got error:

mdadm: hot add failed for /dev/hda13: Invalid argument

However, "mdadm --detail /dev/md0" shows /dev/hda13 has been added as active. Is this just a warning message or have I done anything wrong?


BTW, in order to add an active device /dev/hda14, here is what I have done. Just want to confirm with you guys if it is correct.

1. fdisk to create partition /dev/hda14 as fd and mkfs
2. /dev/hda14 should first be added as spare device to /dev/md0, right?
mdadm /dev/md0 -a /dev/hda14
3. Finally /dev/hda14 can be added as an active device to /dev/md0 with the same command as in step 2
mdadm /dev/md0 -a /dev/hda14

BTW2, when trying to hot remove a device (I have set it as faulty first), I occasionally got "Device busy" error, but sometimes it works fine. What could be the cause?

希望不要被Kevin老师骂阿: 这么简单都不会...5555, 我是菜鸟....
发表于 2005-10-3 10:56:07 | 显示全部楼层
1. /dev/hda13 is already a active spare device, so when you add it, it will complaint. You simply don't need to do that.
2. new device doesn't need to be a spare first, it can be added directly to the raid matrix. Or you can add additional spare device too.
3. you can watch mdadm --detail device to see sometimes if you changed a raid, it needs time to restructure the raid matrix. If you issue another job to this raid, it will complaint too.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-3 11:49:01 | 显示全部楼层
1. Yes, /dev/hda13 is already an active SPARE device, but I would like to add it as a real active device. By real, I mean it should show "ACTIVE" instead of "SPARE" in "mdadm --detail".

If I don't do anything, will the spare device automatically become a real active device after the faulty device is removed? Maybe a reboot will force it?

It seems I need to enhance my understanding of "active" and "spare" concept.  Feel puzzled....

2.  How to add additional spare device?  Suppose /dev/hda14 is only a fd partition and is not a spare device created by the "mdadm -C", now I want to add it as a spare device to /dev/md0, what's the command?

If I run:
mdadm /dev/md0 -a /dev/hda14

How could it tell if i want to add it directly to the raid matrix or add it as spare?

Hope I make myself understood....sounds confusing.... I will do more tests tomorrow and let u know.

I appreciate your help very much.
回复 支持 反对

使用道具 举报

发表于 2005-10-3 13:04:02 | 显示全部楼层
Post by zaiwen
1. Yes, /dev/hda13 is already an active SPARE device, but I would like to add it as a real active device. By real, I mean it should show "ACTIVE" instead of "SPARE" in "mdadm --detail".

If I don't do anything, will the spare device automatically become a real active device after the faulty device is removed? Maybe a reboot will force it?

It seems I need to enhance my understanding of "active" and "spare" concept.  Feel puzzled....

2.  How to add additional spare device?  Suppose /dev/hda14 is only a fd partition and is not a spare device created by the "mdadm -C", now I want to add it as a spare device to /dev/md0, what's the command?

If I run:
mdadm /dev/md0 -a /dev/hda14

How could it tell if i want to add it directly to the raid matrix or add it as spare?

Hope I make myself understood....sounds confusing.... I will do more tests tomorrow and let u know.

I appreciate your help very much.


1. yes, it will be automatically if you take an active device out. That's why it is called spare device.
2. when you created your md, you specified 1 spare device, after that, if you hot added another disk in and at that moment, if there is no active disk failed, that extra disk will become a new spare device. And if you didn't specify any spare when you were creating the md, then any disk you add in later will become spare device.

The rule of thumb is, mdadm will try to maintain the same structure when you create a md at the first time. If the structure is clean and no disks are failed, then any extra disk will be a spare. if an active disk fails, an existing spare will become an active auto, if a spare fails, you manually exchange it.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-4 10:07:49 | 显示全部楼层
I tested again today as what you have suggested. YES,  u r absolutely right! Now I feel like the master of RAID   Thank u, sir!

One more question about the difference I noticed between the old raidtools and the new mdadm:

In old raidtools, we need to run mkfs twice:

1. fdisk created fd partition and then format these partitions and convert them to the default ext3 filesystem.
# mkfs -j /dev/hda14

2. mkraid to create the /dev/md0 and then mkfs of /dev/md0.
# mkfs -j /dev/md0

But it seems I don't need to run those two mkfs in the new mdadm. Am I right?

To recap how to creata raid using mdadm:

1. fdisk to create fd partion.
2. mdadm -C /dev/md0 -l1 --raid-devices=2 /dev/hda11 /dev/hda12 --spare-devices=1 /dev/hda13
3. mount /dev/md0 /home
4. e2label /dev/md0 /home
5. edit /etc/fstab to set it up to be automatically mounted next boot
6. To manage,
mdadm /dev/md0 -f /dev/xx -r /dev/xx -a /dev/nn
7. To view the detail and create a configuration file,
mdadm ━--detail ━--scan >/etc/mdadm.conf


Do I miss anything?
回复 支持 反对

使用道具 举报

发表于 2005-10-4 13:36:01 | 显示全部楼层
After you create the raid, you mkfs it.
回复 支持 反对

使用道具 举报

发表于 2005-10-10 09:26:45 | 显示全部楼层
U only need mkfs once
回复 支持 反对

使用道具 举报

发表于 2005-10-10 09:28:29 | 显示全部楼层
If u want to know the RAID theory deeply,I suggest u read some relational HARDWARE raid DOC
回复 支持 反对

使用道具 举报

发表于 2006-4-15 16:42:59 | 显示全部楼层
楼主的帖子指点了我,谢
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表