Menu

Transferring current RAID1 to newer and bigger disks Log in to Edit

João Cardoso

__Not Finished, WORK IN PROGRESS___

Your RAID1 has no more free space, or one of the disks have already failed, or the disks are old and might fail at any moment, and you want to create a new RAID1 with new and bigger disks without loosing your data. How to do that the most efficient way?
There are several approaches, A-the safer and long lasting, and B-the faster and risker.

The fasted way, the one that involves the small number of copies, implies deliberately degrade the current array, remove one of its disks, inserting one of the new disks in the now empty slot, create a new degraded array with it, copy all data from the old array to the new one, verifying the copy, stopping the old array and removing it disk, plugging the second new disk and add it to the to the new array and let the rsync happens.

Lets say you have a old md0 RAID1 array with disks A and B that you want to replace with newer and bigger disks C and D.
Fail disk A (Disk->RAID, Fail) turning md0 into a degraded array, remove disk A from the md0 array (Disk->RAID, Remove) and finally from the box.
Insert disk C in the now vacant box bay/slot and create a new degraded md1 array with it using Disk->Wizard, selecting only the C disk.
Copy, using the cp -a /mnt/md0 /mnt/md1 command (or rsync -av *) in the command line, all data from the md0 RAID1 with only the B disk to the new md1 RAID1 array with only the C disk .
verify the copy.
unmount (Disk->Filesystem) and stop the md0 array (Disk->RAID),
remove the B disk from the box and replace it with the new D disk, copy the C disk partition table to the D disk (Disk->Partitioner)
and add the D disk to the md1 array (Disk->RAID, Add)

(*) - cp -a is faster than rsync -av, but if the copy fails for whatever reason it has to be started from the beginning, while rsync restarts where it stopped.


Discussion

  • Andre Kiss Uber

    Andre Kiss Uber - 2022-01-21

    many KUDOS to João for this fabulous work that is ALT-F
    currenty experimenting alt-f in dlink dns-320, after many years with default firmware+funplug

    the aproach above to migrate hdds and grow raid size seems very useful, and i decided to try it

    after failing sdb from md0, poweroff the box and remove disk = OK
    insert new, bigger SDB. = OK
    create partition for swap, like in sda, and raid with remaining space = OK
    create new raid1 using NONE as component 1, sdb2 as component 2, and NONE as spare = FAIL

    error says : All componentes must be different.

    i supose a new option could be added in the options for each component : missing

    none, sda2, sdb2, missing

    i now will try to create raid1 / md1 with missing disk, from console

    mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb2

    and raid md1 seems to be just fine, in web interface, after reload of webpage

    will try now to copy all data from /md0 to md1, as recomended

    thanks again

    Andre

    (greetings from Portugal)

     

    Last edit: Andre Kiss Uber 2022-01-21
    • João Cardoso

      João Cardoso - 2022-01-23

      Using the command:

      mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb2

      as you did, creates the RAID with metadata 1.2 by default, which means that you can't convert the RAID to two identical "normal" filesystem, each one on its disk, as covered by another wiki entry.
      You could explicitly add --metadata=1.0 to the above command, or use the Disk Wizard to create the new RAID (selecting only the appropriate disk and choosing RAID1). Another advantage of using the Disk Wizard is to avoids the need to manipulate the new disk partition table, as a new partition table will be created with proper RAID type and filling all disk; a swap partition entry will also be added and swap created and added.

       
  • Andre Kiss Uber

    Andre Kiss Uber - 2022-01-21

    stage 2:
    comand to copy from original raid (md0) to new raid (md1), in ssh session
    rsync -av --exclude lost+found /mnt/md0/ /mnt/md1/ =OK

    stage 3:
    poweroff, remove old remaining small disk (sda), from box
    insert new large disk, in empty slot, turn power on
    in web interface:
    - copy partition scheme from sdb to sda =OK
    - in raid menu, Raid Maintenance - choose COMPONENT "sda2", and OPERATION "add"
    md1 goes to recovery status and starts to rebuild /dev/md1 = OK

    job done,

    the problem that i havent figured out is to rename md1 back to md0

    because all shares where made using /dev/md0/.... path and applications like minidnla also use /dev/md0/.... paths

    nevertheless the raid has migrated and increased with sucess and speed
    (and safe, because old data is still in old disks, very very safe)

    very good solution

    João, any sugestion about how to safely rename md1 to md0, or any other solution ??

    thanks to all

     
    • João Cardoso

      João Cardoso - 2022-01-23

      In my experience rsync -av is two to three times slower than a plain cp -a, as resync needs to create a file list which is very big and a lengthy process.
      I don't have a clue on how to convert the new RAID name back to md0 in a safe way. The name is stored in the device, but surely can be renamed.
      The obvious "solution" is to assign a label to the filesystem (Disk->Filesystems) and call it md0; as filesystems are mounted preferentially by label /dev/md1 will be mounted as /mnt/md0 (but it might cause confusion within a couple of months or years, having a device named md1 and mounted as md0 -- this is not recommended, as it might lead to errors in the future)

       
  • Andre Kiss Uber

    Andre Kiss Uber - 2022-01-29

    thank you, João, that metadata "detail" completely slipped my mind.
    As to using the web wizard, that was my first option, but it did not work, as i reported before, in first post, with error like
    " All componentes must be different. "

    please check my first post , i have proposed a possible solution ??

    i did create the same (identical) partition scheme, as in first disk, in such way to have swap partition on all disks

    as for rsync beeing slower, i agree, i will try CP next time

    thanks again

     

Log in to post a comment.

MongoDB Logo MongoDB