You are not logged in.

#1 2010-04-12 01:26:54

jskier
Member
From: Minnesota, USA
Registered: 2003-07-30
Posts: 383
Website

Implementing RAID1 on already running system

I have two identically sized drives that I would like to convert to a software RAID1 on my already running single drive system. I'm comfortable with Linux but very very new to RAID. So far I have seen the wiki (and a few Google search hits that don't help too much):

http://wiki.archlinux.org/index.php/Con … em_to_RAID

However Grub just gives me an error 2 when I boot from the second drive after copying everything to it.

Seeing that the wiki article is a bit dated (no longer is there a raid hook), any suggestions on where to go from where I am at? Do I just use the mdadm hook for the kernel image? Currently, I have matching partition tables on sdb and sdc (sda is Windows). I plan on copying over sdb to sdc for the second time once I have a solid game plan. If anyone has any suggestions from this point I'd greatly appreciate it, thanks smile


--
JSkier

Offline

#2 2010-04-18 15:02:13

jskier
Member
From: Minnesota, USA
Registered: 2003-07-30
Posts: 383
Website

Re: Implementing RAID1 on already running system

From what I can find elsewhere, it doesn't seem like the combination of RAID1, Grub(1), and ext4 as / with no /boot play well roll


--
JSkier

Offline

#3 2010-04-19 19:14:09

pseudonomous
Member
Registered: 2008-04-23
Posts: 349

Re: Implementing RAID1 on already running system

jskier,

I don't think there should be a problem with what you are trying to do; since raid1 mirrors that data across the two drives exactly, grub should be capable of reading either drive in a raid1 array as a single hard drive; I personally have a desktop that has /boot mirrored in raid1 and don't have any trouble with it.

The only troubleshooting advice I can think of to give is:

Are you sure the two drives in raid1 were completely synced before you rebooted?

Did you remember to install grub to the mbr of both drives?

Play around with this some more, if you can't figure it out, post back with more detailed about what happens when you try to boot.

If you are successful you might want to post a little how-to here for other users trying to do this.

Edit:

I just read the "migrating to raid" page and it is a bit dated, but more so than that it seems a bit over complicated, unfortunately I don't have the time to update it right now, and also (this slipped my mind) the raid 5 array I used be using as my / partition failed a month ago so I've gone back to a single hard drive root.

Anyway, you do only need the mdadm line in mkinitcpio.conf; the "installing with Software Raid or LVM" page of the wiki is a much better source of info if you can figure out how to adapt the instructions to migrating from an existing install.

Last edited by pseudonomous (2010-04-19 19:27:31)

Offline

#4 2010-04-21 03:01:16

jskier
Member
From: Minnesota, USA
Registered: 2003-07-30
Posts: 383
Website

Re: Implementing RAID1 on already running system

I've put this on the back burner for now (sticking with rsync for backup to the other drive). Grub didn't seem to see the ext4 partition when I went to the Grub prompt itself for my secondary drive (oddly it sees the first ext4 partition on my primary Linux drive however). I also tried to install Grub by using grub-install sdc (states success), but "error 2" would come up before the Grub menu could have a chance when I set this drive to boot first. So I also pointed to it to my main hard drive (the working Grub boot code on the sda MBR and setting that back to the primary boot drive in the BIOS)- error 2 comes up after I select my RAID1 -or- secondary drive by itself. Not sure why this is occurring, but I don't have the time at the moment to keep plugging away on this for a few more weeks.

I found some shortcuts to the dated Wiki as well by looking over other sites (sfdisk for partition tables, dd with live cd instead of rysnc on live system in init 1, etc.). I'd update it if I could actually get this process working, but I'd rather not lead more users into a non-functioning RAID1 wink

Thank you for your input on this,

I'll keep an eye on the Wiki and the forums if anyone else has any luck with this.


--
JSkier

Offline

#5 2010-04-21 10:22:00

Ultraman
Member
Registered: 2009-12-24
Posts: 242

Re: Implementing RAID1 on already running system

I did this once using just rsync.
I partitioned a second drive the way I wanted it. A /boot (marked bootable), swap and a big partition for the rest. Marked all those type fd (Linux RAID). Also left 8MB unpartitioned at the end so small size variations between different disks are not a problem.
Told mdadm to create 3 broken RAID1 arrays, md0 for /boot, md1 for swap, md2 for the rest.
I use LVM to manage the space on the big partition, and made volumes for root, var and home.

Inserted the "mdadm" HOOK in my rc.conf and had mdadm make me a /etc/mdadm.conf using:

rm /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf

Check the mdadm.conf file is correct.
Rebuild your kernel mkinitcpio image (I believe you do that with "mkinitcpio -p kernel26" for the stock kernel) to include the mdadm hook, it will automatically pick up your mdadm.conf file so your RAID can be auto-detected on boot.
Check out http://wiki.archlinux.org/index.php/Ins … AID_or_LVM to make sure I didn't forget to mention anything important.

Than I used rsync to copy all the contents from my current disk to the second that I had prepared. Rsync guides helped me a lot there, as well as http://wiki.archlinux.org/index.php/Ful … with_rsync. Copied it all and checked everything was there.

Installed GRUB on the second drive and configured the menu.lst correctly (hd0,0) so it would boot from the first device, as the second disk we have prepared will become the first boot-device because you will have to change your boot order to boot from it.
And make sure you change the kernel boot line to the new disk in RAID style!
Also do not forget to alter the /etc/fstab on the new drive and set the proper mounts. I use UUID in there. You can check those out with "blkid" and "ls -lF /dev/disk/by-uuid/".

Reboot and boot from the disk you just prepared.
Does it work? Yay! if it does. And if it doesn't, try to fix the error, you still have your old disk you can boot from smile

In case it booted: Make sure you really are on the disk you just prepared wink
Check if all your files are there.

Now, time to organize the old disk and include it in the current array.
You can copy the partition table of the RAID1 disk to the old disk using sfdisk.

# sfdisk -d /dev/sda | sfdisk /dev/sdb

Than you can include the old disk in the RAID1 array. Tell mdadm to add the corresponding partitions on the old disk to the appropriate arrays. Example:

mdadm /dev/md0 -a /dev/sda1

Watch /proc/mdstat for status of the rebuild.

As finishing touch, set up GRUB on the old drive as well. That way you can boot off both devices should one of them fail.
How this is done can be found in the Software RAID wiki.

After the rebuild is done, you are on a RAID1 system ! big_smile

Another interesting source: http://en.gentoo-wiki.com/wiki/Migrate_to_RAID

Last edited by Ultraman (2010-04-21 12:37:52)

Offline

#6 2010-04-21 12:10:34

jskier
Member
From: Minnesota, USA
Registered: 2003-07-30
Posts: 383
Website

Re: Implementing RAID1 on already running system

Interesting, this brings up a good point about something I *may* have overlooked when changing drives in the BIOS- not for sure but when I get around to trying this again I will make note of some of the Grub stuff you mentioned. However this does not explain while when I was in Init 1 and chrooted into the new RAID1 going through the Grub prompt it doesn't see my secondary partition? It won't find any of the config files and fails. Yet, it is "successful" upon doing grub-install sdc (sdb is my already running Linux system)- only to clunk out with an "error 2" before even making it to the boot menu in Grub. Any thoughts on this?


--
JSkier

Offline

#7 2010-04-21 12:39:44

Ultraman
Member
Registered: 2009-12-24
Posts: 242

Re: Implementing RAID1 on already running system

No real thoughts on it, other than what has been said.
I just wanted to to show how I did it successfully. Could be that I did boot to a live CD to fix something minor, I think that was the rebuild of the mkinitcpio which I forgot to do over here, but I did include that in my method posted above wink

Offline

Board footer

Powered by FluxBB