Information from http://ubuntuforums.org/showthread.php?t=990045 that uses information from http://scottwallace.posterous.com/tag/mdadm that uses information from http://www.n8gray.org/blog/2006/09/0...vms-and-mdadm/ is used for this tutorial.
But...I did not like the steps saying 'to destroy all configurationfiles and building new' so I find out a solution.
This worked twice for me with Ubuntu 10.04 setups.
- Don't be stupid, backup important data first.
- Don't kill commands used in this tutorial.
- Do not proceed with this tutorial if you can't prevent /boot from becoming RAID5 also. This may kill GRUB.
- Try to understand what you are doing. Preventing and fixing mistakes is much easier than.
- Run all commands as superuser/root.
- Everything shown in code boxes are commands, no output information will be there.
- Use the "cat /proc/mdstat" command any moment to see the RAID status.
RAID1 with LVM --> RAID5 with LVM
In this tutorial:
RAID1 array: "/dev/mdx," containing: "/dev/sda" and "/dev/sdb."
We will add "/dev/sdc" to create a RAID5 setup.
Part 1 - Converting the RAID1 array to a RAID5 array
Copy partition structures from the current disks to the new disk:
Reload the disk.
dd if=/dev/sda of=/dev/sdc count=1 bs=512
sfdisk -d /dev/sda > sda.sf
sfdisk --force /dev/sdc < sda.sf
Check if the partition structure is the same as on the disk in the RAID1 setup. For example, compare these two outputs:
fdisk -l /dev/sda
fdisk -l /dev/sdc
Switch to Live CD. Preferable the same version of the same distro you have installed. (Unless, you know how to stop an array being used or your array isn't in use*. Tn that case skip this step).
apt-get install mdadm
Stop the RAID1 array.
Overwrite meta data and combine one old disk with the new disk, starting with the old one.
mdadm --stop /dev/mdx
Recovery will start, wait until it is finished.
mdadm --create /dev/mdx --level=5 -n 2 /dev/sda /dev/sdc
Check the process.
Afterwards you should have a degraded RAID5 setup.
'(UU_)' is indicating this.
Add the third disk. (This is the second one of the old RAID1 setup.)
Tell the array to not use it as spare.
mdadm --add /dev/mdx /dev/sdb
Reshaping will start. This takes more time than recovery. (The backup argument apparently is a option in case grow fails.)
mdadm --grow /dev/mdx --raid-disks=3 --backup-file=/mnt/tmp/raid1-5.backup.file
Wait until it is done.
Part 2 - Editing the configuration data
The LVM part. Now we've got a RAID5 setup but the OS inside the LVM does not know this. We will get inside LVM. (If you do not use the Live CD method, skip this step.)
Find LVM stuff.
apt-get install lvm2
Activate the Volume Group(s).
Now you also know where they are. Mount the one containing the operating system.
mount /dev/mapper/OS-LV /mnt/OS
Get the new array information.
Only catch the lines that talk about the array we are working with.
mdadm --detail --scan
It looks something like this:
Put this into the /etc/mdadm/mdadm.conf of the operating system. This would be /mnt/OS/etc/mdadm/mdadm.conf in this tutorial when using the Live CD method.
ARRAY /dev/mdx level=raid5 num-devices=3 metadata=00.90 UUID=a5241471:51b928ef:92045851:c654ebbf
Be sure to replace the correct old information talking about a raid1 array and save.
This actually means nothing yet. The info needs to go into the boot image.
(Non Live CD method users want to skip this step also.)
Chroot to the LV.
Specific commands that have kind of relative paths in it will now work like as if you are booted into the OS-LV we mounted earlier.
Update the boot image.
Reboot to OS.
You should get into the OS like it was the case with the raid1 array.
Check if everything is fine.
You should have a double amount of blocks now.
Part 3 - Assigning the new bits
Give the new space to the physical volume.
This won't take much time.
Check if it is there.
Look at the line saying 'Free PE / Size.'
Give it to members of the group, for this tutorial let's say /home is in a group called 'home-dirs' and needs to get extended with 500GB.
See manuals for other kinds of extend commands.
lvextend -L+500G /dev/mapper/home-dirs
This could take some time.
Check if they got it.
Look at the line saying 'LV Size.'
Finally, resize the filesystem so the space becomes useable
This takes some time also but less than the previous operation.
Check out your new space.
*My array broke right at this moment (this must have been coincidence) so I continued in the OS itself. However, the first successful attempt took place using a Live CD.
**I don't know for sure whether this 'partprobe' command is needed now. It won't harm anyways...