Re: [opensuse] Software RAID with existing drive



----- Original Message ----- From: "Joe Morris (NTM)" <Joe_Morris@xxxxxxx>
To: "Brandon Carl" <spleeyah@xxxxxxxxxxxx>
Sent: Saturday, July 07, 2007 9:28 PM
Subject: Re: [opensuse] Software RAID with existing drive


On 07/08/2007 10:25 AM, Brandon Carl wrote:
I am not too familiar with the DM RAID, which I think is the fake raid
driver for your motherboard (or raid card IIRC from your first post).
Assuming that is correct, I wouldn't use it.
Just for clarity, I wouldn't use it because I am not familiar with it.
Software raid now uses the
mdadm program instead of raidtools. You could do this, which I am sure
would work but will take time. You will need two drives with matching
partition sizes for each raid 1 partition. At the point you are at, I
don't think it really matters. If you like the partitioning scheme you
have on /dev/hda, match it on /dev/hdb. each partition will need to be
marked as Linux Raid. Then, you could create a raid 1 for each
partition on /dev/hdb with mdadm with only one disk initially, then
format the new raid 1 partitions, then copy from /dev/hda. After
copying, you will need to change the partition type of each raided
partition on /dev/hda to Linux raid. Then use mdadm to add those
partition to your raid 1 partitions from /dev/hdb. This will sync each
one in turn. You will then need to edit /etc/fstab to correct your
partitions, i.e /dev/hda2 / to /dev/md0 /, etc. You should also edit
/boot/grub/menu.lst and correct as necessary (root=/dev/md0, etc), then
I would double check everything and reboot. You may or may not need to
reinstall Grub, though I probably would via the grub command prompt to
triple check it can find everything it needs BEFORE I am booting and it
tells me it cannot find..... I have done the above, and it will work.
It is a bit of work, and depending on data size will take a while.
ALSO, one other thing I just thought about, you would need to add raid1
module to your initrd modules and run mkinitrd to create the raid
bootable image. Check out
http://lists.opensuse.org/opensuse-amd64/2006-09/msg00034.html for
additional info.
Ok, I got as far as creating a raid 1 array for each partition on
/dev/hdb.

I created these:
/dev/md0 /dev/hdb1 /
/dev/md1 /dev/hdb3 /home
/dev/md2 /dev/hdb5 swap

Those were the three partitions on the /dev/hda, and they are the
exact same size as the ones on /dev/hda, and even start and end at the
same cylinders.
Great, looks good so far.
I didn't know what to do about the extended partition on /dev/hda
which was used for the swap space, I assume. I created the exact same
things on /dev/hdb, including extended partition.
Personally, I try to have enough RAM and not need swap, and I do not
mirror swap partitions. I mount them as swap from fstab with the same
priority. I personally see no advantage to include a swap partition in
a raid 1, but it should work without any problem.

Now, I don't know what to do. I mount the /dev/md0 as /mnt/raid0, and
I can see all the files on it that must have been copied over when I
tried the hardware RAID card. It is the exact same thing as my "/"
directory. I created a new folder under "/" just to make sure, and it
didn't show up in the /dev/md0, so that's good.
It probably could have worked with the hardware raid card if you
corrected menu.lst's root= line to point to the correct root, included
the driver in the initrd modules, reran mkinitrd, and corrected fstab.
But now, assuming it already has been formatted with the filesystem you
wanted, since it already has most of the info as hda, I would probably
rsync the differences for all but /proc and /sys appropriately.
When I tried to mount /dev/md1 as /mnt/raid1, it gives me an error:
"mount: Operation not supported". So I don't know what that means.
Was there a mountpoint raid1 under mnt? What I would do is mount
/dev/md0 to /mnt, and if it already is formatted and mostly populated,
mount /dev/md1 to /mnt/home. That should work. After that, you can
rsync each directory under / to /mnt. Include -H for hard links.
Also, it won't let me mount the /dev/md2 because it says it looks like
swap space, which it is.
Correct, you would just use swapon for the swap partition.

Now, I don't know how to format the new raid 1 partitions on /dev/hdb
so i can copy my data over.

It sounds like they are already formatted, so no need. Once you have
synced the contents, I would first correct menu.lst for the raid root,
and I would suggest making a alternate boot entry to boot from hdb
(check out http://www.linuxsa.org.au/mailing-list/2003-07/1270.html ).
You would need to fix your initrd modules and rerun mkinitrd so your
/dev/md0 has the correct initrd, so you probably have to do it on hda
and sync it. It would be correct to edit fstab on /mnt/etc/fstab to
make root and home their md devices (and swap too in your case).
Correct menu.lst on /mnt/boot/grub/menu.lst. After your new raid / and
/home are synced and ready, go to /mnt and chroot /mnt. That will make
you new drive root. Then enter grub and install grub to the hdb MBR.
Assuming you have made an entry in your menu.lst to boot from hdb
(hd1,0) with root=/dev/md0, you should now be able to boot into your new
raid1 system without yet destroying your old drives and data. Assuming
it all works (howbeit raid is only running on one disk for each
partition), you can change the partition type for hda's partitions to
software raid, no need to format, then add the right partition to the
right raid, i.e. mdadm /dev/md0 -a /dev/hda1. Each one added will sync
(mdadm --detail /dev/md0) After they are all synced, install grub on
hd0,0, and test out your boot from both entries (i.e boot from hda and
hdb, with a fallback in menu.lst). Assuming these all worked, you
should be running as you wanted and successfully performed a delicate
data surgery. HTH.

--
Joe Morris
Registered Linux user 231871 running openSUSE 10.2 x86_64


Well, I've gotten really far, I think.
I mounted both raid partitions and copied over everything under "/" except for /sys, /mnt, and /proc

/dev/md10 (RAID1: /dev/hdb1 & missing) will mount as /
/dev/md11 (RAID1: /dev/hdb3 & missing) will mount as /home

I have grub installed in the MBR of both drives, so I can boot from either.
My menu.lst is setup as so:

title Boot from Hard Drive A
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hda1 noapic resume=/dev/hda5 splash=silent showopts
initrd /boot/initrd

title Boot from RAID
root (hd1,0)
kernel /boot/vmlinuz root=/dev/md10 noapic resume=/dev/hdb5 splash=silent showopts
initrd /boot/initrd

That way I can boot from either the first drive, or the one-drive RAID on the second drive.

I have run into a problem, however. When I attempt to choose "Boot from RAID" it gets to the boot commands, but it stalls at "Waiting for device /dev/md10 to appear: ................................. not found -- Exiting to /bin/sh".
After this I reboot my computer and choose the "Boot from Hard Drive A" and then when I try to mount the /dev/md10 as /mnt it says: "cannot read superblock". I get around this by going into the Yast partitioner and deleting the /dev/md10 and /dev/md11 and by doing "mdadm -S /dev/md10;mdadm -S /dev/md11" as super user. I then do "mdadm -C /dev/md10 -l raid1 -n 2 /dev/hdb1 missing; mdadm -C /dev/md11 -l raid1 -n 2 /dev/hdb3 missing" to recreate the two raid partitions. After that it is back to normal.

Here is the contents of my fstab under the /dev/md10, in case it's helpful:
/dev/md10 / reiserfs acl,user_xattr,usrquota,grpquota 1 1
/dev/md11 /home reiserfs acl,user_xattr,usrquota,grpquota 1 2
/dev/hdb5 swap swap defaults 0 0
proc /proc proc defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
/dev/fd0 /media/floppy auto noauto,user,sync 0 0

I have decided against mirroring the swap space, and just using both the /dev/hda5 and /dev/hdb5 as swap space, so it is doubled.

So that is where I am stuck. I cannot figure how to get past the "waiting for device /dev/md10 to appear......".
I have tried "mkinitrd" and "cd /mnt; chroot /mnt; mkinitrd" to try and fix it, but to no avail.

Anyone have any ideas?
Thanks for your help thus far!

--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx