mdadm: which device set as source to mirror?
Thanks for your quick response.
It won't matter if I want to use 2 blank partitions to build RAID1;
But now I wish to use mdadm to backup my /home partition, which already has tons of files on it;
If mdadm happens to choose the other blank partition as source to do mirroring, all my data on /home will be lost;
Hardware RAID always allows me to choose which partition/drive to be used as source.
Regards,
Quoted 25 lines · Neil Brown
Quoted 11 lines · On Sunday September 11, [email protected] wrote:
Dear Neil Brown,
I'm trying to learn how to use your great mdadm, one thing I'm not quite sure, and couldn't find any clue in your man page, is,
During create or assemble mode, for RAID1, which device mdadm uses as source to make the mirroring? Is there any differences to determine it
for situations of same-size devices and different-size devices (>1% differences) ?I think it copies from the smallest numbered working drive (i.e. drive 0 if that is working, else drive 1, etc). However it really shouldn't matter to you. If you are doing something that depends on having the right answer to this, you are probably doing it the wrong way.
If you would like to discuss it further, I suggest explaining what you want to do, and why you think you need to know this, to [email protected].
NeilBrown
Signature · 1 line
Changsen Xu
http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Software-RAID-HOWTO.html#ss7.6
Look, RAIDTOOLS clearly stated source is "raid-disk 0", but your current mdadm has no specifications on this matter. Maybe one more command line switch, such as "--source /dev/hdb3", can be added to your next release?
Regards,
Quoted 25 lines · Neil Brown
Quoted 11 lines · On Sunday September 11, [email protected] wrote:
Dear Neil Brown,
I'm trying to learn how to use your great mdadm, one thing I'm not quite sure, and couldn't find any clue in your man page, is,
During create or assemble mode, for RAID1, which device mdadm uses as source to make the mirroring? Is there any differences to determine it
for situations of same-size devices and different-size devices (>1% differences) ?I think it copies from the smallest numbered working drive (i.e. drive 0 if that is working, else drive 1, etc). However it really shouldn't matter to you. If you are doing something that depends on having the right answer to this, you are probably doing it the wrong way.
If you would like to discuss it further, I suggest explaining what you want to do, and why you think you need to know this, to [email protected].
NeilBrown
Signature · 1 line
Changsen Xu
Quoted 6 lines · On Sunday September 11, [email protected] wrote:
Thanks for your quick response.
It won't matter if I want to use 2 blank partitions to build RAID1;
But now I wish to use mdadm to backup my /home partition, which already has tons of files on it;
You probably don't want to do that. Normally a raid1 array created by mdadm is slightly smaller than the original device, to allow room for some metadata. If you create a raid1 using a device with an existing filesystem, you will probably corrupt that filesystem - though it may be possible to 'resize' it a few hundred Kilobytes smaller first.
Quoted 3 lines
If mdadm happens to choose the other blank partition as source to do mirroring, all my data on /home will be lost;
If this really is something you want to do (e.g. you do shrink the filesystem first, or you use --build to make an array without metadata (not recommended unless you really know what you are doing)), then the thing to do is create the array with only one active device, and one 'missing' device. Thus the data on the active device will have to be the data using in the array. Then you hot-add the drive that you want data to be copied on to.
When you hot-add a spare to an array, you can be certain that data will be copied ONTO it, not OFF OF it.
However the recommended approach is to create a degraded array using the new drive, make a filesystem there-on, copy the data, and once you are sure the data is safe, add the original drive as a spare to the new array.
e.g. assuming sda1 has your /home and sdb1 is the same size:
mdadm --create /dev/md1 --level=1 -n2 missing /dev/sdb1 mkfs /dev/md1 mount /dev/md1 /mnt cp -a /home /mnt # convince yourself that the copy was successful umount /mnt umount /home mount /dev/md1 /home # convince yourself again that /home is good mdadm /dev/md1 --add /dev/sda1
# update /etc/fstab and /etc/mdadm.conf as required
Quoted 3 lines
Hardware RAID always allows me to choose which partition/drive to be used as source.
Probably because customers ask for it and hardware manufacturers think it is good to give customers what they want.
I prefer to tell customers what they need :-)
NeilBrown