0

Unfortunately all tutorials I have found online until now on how to setup software-raid-1 are outdated on ubuntu 12.40

My target is to setup it on a system with a secondary disk drive that is already running. Format is not an option!

I am trying to follow and adapt from 11.10 to 12.04 the following tutorial: http://www.howtoforge.com/how-to-set-up-software-raid1-on-a-running-lvm-system-incl-grub2-configuration-ubuntu-11.10-p2

On the above tutorial there is a successful command which creates a raid-1 array by setting the first disk drive with the installed system as missing: mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1

But when the time comes to add the first main drive with the installed system on the raid-array with this command: mdadm --add /dev/md0 /dev/sda1 I receive an error message.

The error message says that the device /dev/sda is (which makes sense) busy!

Note: hardware raid solution is not available since the system is a laptop with two disk drives!

Thank you

  • Did you reboot and boot from the newly created RAID array? If not and you booted from your old setup on sda then it is indeed busy. – Hennes Dec 10 '12 at 00:53
  • No I didn't. I tried to copy all data to the new device with this command: `sudo cp -dpRx / /mnt/md0` but failed to complete. So the reboot after that failed as well. How could I copy the entire sda succesfully? :) – George Pligoropoulos Dec 10 '12 at 01:00
  • To clarify, you got stuck at step 4 off: 1) Insert a second drive (sdb). 2) Create a new array with sda missing (`mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb`). 3) Formatted the new drive. (it should now be accesable). 4) Copied the data to the new drive . 5) Changed grub to boot from the new device. 6) Rebooted and booted from the new device. 7) Added sda (which is not in use since the reboot) to the mirror and let is sync. – Hennes Dec 10 '12 at 06:03
  • @Hennes yes this is correct. Thanks for clarifying that I need first to do a reboot with the raid-array running and THEN to add the sda device on the raid array! But even so I would still be stuck on step 4 as you mentioned. Also I am not very proficient with grub so step 5 is also unknown to me – George Pligoropoulos Dec 10 '12 at 13:18

2 Answers2

0

I've just been through massive dramas getting bootable RAID on a new Slackware installation so mdadm is relatively fresh in my mind =) My system wouldn't even boot so I didn't have the "device busy" problem you have... But if you can make a bootable CD or USB, or have your original installation boot media lying around you can achieve this pretty easily.

Once booted, you can easily examine the status of your RAID devices:

mdadm -D --scan
mdadm -D /dev/md0

Check that the relevant disk is listed, try to mount and make sure all your files are there:

mount /dev/md0 /mnt
# have a browse through the contents of /mnt until you're satisfied
umount /mnt

Then try adding your disk. Presumably you have already set up the partitions to match the other one.

mdadm --add /dev/md0 /dev/sda1

And check the status again:

mdadm -D /dev/md0

Your disk should be listed, and it should say that it's doing a resync or rebuilding the array. It should also indicate its progress as a percentage.

Then, my advice is just walk away and leave it. Come back periodically and run the above command again until it is done. Mine took several hours. When it's done, the status should indicate you have two active devices, two working devices, and that the state is either 'clean' or 'active'.

At that point, issue a reboot command and boot to your raid device. I don't know about grub, but presumably you have taken steps to make that work. I use LILO, so I had to make an initrd file that loaded the RAID drivers.

Good luck. It's nail-biting stuff reconfiguring your RAID when you only have one copy of your system =)

PS: I don't know how you'll go if you're using metadata version 1.20 with Ubuntu. In Slackware, this caused heaps of issues -- namely my devices renumbering themselves. I had to go through various iterations of zeroing the superblocks, recreating the array with metadata 0.90, forcing the super-minor to a value etc. If you have problems with /dev/md0 getting renumbered (as /dev/md127 for example) and then failing to boot, feel free to ask for help.

paddy
  • 238
  • 2
  • 7
  • 1
    Hmmm, after reading your question again I'm not sure I advised you correctly. I assumed that you had created an array using your system disk and then saying the *spare* disk is missing, so that when you then added the spare it would rebuild the array onto that disk. If you have reasons for doing it the other way around, that's cool. I just logically expected that if you have a single disk in an array, then it would use that disk as the 'master' and then mirror it to any new disk that is added. – paddy Dec 10 '12 at 04:43
  • No the key to solve this problem was that "I needed to boot with the degredaded raid-array first". Now I am stuck on how to setup grub to boot effectively from the raid-array but I guess this belongs to another question – George Pligoropoulos Dec 10 '12 at 13:30
0

Take a look at http://en.wikipedia.org/wiki/Mdadm

Under section: Convert an existing partition to RAID 5

You may be able to apply this to your raid1 setup. However, take note of the NOTE following this little section in regard to the /boot directory. In my test setup it seems that I was able to boot from the md1 raid partition, but because I didn't setup my test system with /boot in it's own partition, formating the /dev/sda1 partition broke my setup as there's no /boot partition to boot my system.

You may better understand this section than I do as I'm very new to mdadm.

kelxon10995