In my current Ubuntu server, I have 2x 2TB Western Digital RED hard drives in a RAID 1, using mdadm. I would like to add 2 more 2TB RED drives, and convert it to a RAID 10. I realize I would have to wipe the data most likely, but is there any way that I wouldn't need to? I have the 2TB volume almost completely filled up
Answer
This took some strategy, and unfortunately, was a little while ago, so bear with me; I'm going by memory.
Essentially, I shut down the server, and installed the two new drives. I did a backup beforehand to an External 4TB HDD (much faster since it had USB3!), just in case. I didn't need to use it thankfully, but I'm happy I at least had it. I took note of what the partition sizes were on the disk (by block size), and what each disk was. At the time, sda
and sdb
were the drives with the current array loaded. sdc
and sdd
were the new drives. I copied the partition layout to the two new disks, using fdisk
as root. I then created a new array, with two missing members:
mdadm -v --create /dev/md1 --level=raid10 --raid-devices=4 /dev/sdc1 missing /dev/sdd2 missing
This command creates the array, called /dev/md1
, sets the RAID type to 10, and says that there should be 4 devices, in a perfect world. The devices I added were /dev/sdc1
and /dev/sdd1
for the first partition. Once it was up, I mounted the array (as /mnt/raid
), and did an rsync -avP /mnt/data/ /mnt/raid/
, and waited a day for everything to copy.
Once it was copied over, you need to fail the hard drives in the array, and remove them: mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1
. You can then add that hard drive to the new array, and wait for it to rebuild. Then, remove the last drive from the array (using /deb/sdb
instead), and add it back (mdadm /dev/md1 --add /dev/sda1
).
Finally, to remove the old array from starting up or giving warnings, run mdadm --stop /dev/md0
. At this point, the old array is gone! I would suggest double-checking that the boot loader is installed correctly on the array (or, depending on your scheme, the boot sector of the hard drives). Give it a test reboot; if everything comes up, great! If not, that's why we have a backup!
As a bonus, I learned a new useful command: watch cat /proc/mdstat
to automatically update the screen every 2 seconds with the rebuilding status of your drives. I also wrote a blog entry about my experience, including pictures.
No comments:
Post a Comment