I'm not going to attempt to answer all these questions as I'm out of time...
Software Raid devices do not have partitions on them. You would typically
mke2fs -j /dev/md0 to format it, alternately put LVM on it but that's
another topic.
Software RAID mirroring has a nice side effect, you can mount half of the
mirror in it's own right in case of emergency. Similarly, the boot files,
namely the kernel and initrd will appear in consistent locations within
each component device.
Thus if /dev/hda1 and /dev/hdc1 are components of /dev/md0 you can do this:-
$ touch /boot/hereplease
$ grub
grub> find /boot/hereplease
(hd0,0)
(hd1,0)
{your actual results may vary}
grub> root (hd0,0)
grub> setup (hd0)
grub> root (hd1,0)
grub> setup (hd1)
grub> quit
$
I typically do a find to make sure GURB's idea of the partitions is in
line with what I am thinking. The setup command does all the hard work for
you of finding the stage1 and stage2 files and writing the boot sectors.
Another thing to help is to write yourself a device.map file somewhere in
/tmp or something just for doing the recovery work.
On Sun, August 6, 2006 8:29 pm, Luke Kendall wrote:
> I'm halfway through setting up the root partition (and /home) to be
> raid1 mirrors (thanks to help from Jeff Waugh and Jamie Wilkinson).
>
> I've booted up from my old installation on /dev/hda6 to set up the real
> /dev/hda7,/dev/sda7 to be /dev/md0 for /, and /dev/hda8,/dev/sda8 to be
> /dev/md2 for /home.
>
> I've set the partition types on hda7, sda7, hda8 and sda8 to "fd",
> Linux RAID autodetect.
>
> I've also installed grub on (hd0,6) and (hd1,6) (i.e. on /dev/hda7 and
> /dev/sda7).
>
> My two questions are: is a raid mirror device supposed to have a
> partition table? If so, what should it be set to - just one partition
> containing the number of blocks that the real partitions making it up
> have? What should the start and end cylinders be set to? (The reason I
> ask is that the raid devices are failing the filesystem check upon
> boot.)
>
> And secondly, how do you tell grub to use md0 instead of hd0 or hd1?
> Is it as simple as telling it that device (hd0) is /dev/md0? (Though I
> don't see a way to do that in /boot/grub/menu.lst)
>
> How I created the raid arrays
> -----------------------------
> I basically unmounted the drives I wanted to turn into pieces of the
> raid, used mdadm to add the (empty) partitions from sda into the raid
> array, telling it that the other piece was missing, then mounted the
> raid drive and copied the files from the (populated) partition, then
> unmounted that populated partition and added it to the raid and
> watched
> as the raid rebuilt itself. I could then mount /dev/md2 as /home and
> ls
> files.
>
> My first question is: how do you tell grub what to use as the root
> drive, given that grub seems to want a physical drive spec (e.g. hd0 or
> hd1)? How do you tell grub to use md0 instead of hd0 or hd1?
>
> In my case, hd0 is /dev/hda and hd1 is /dev/sda.
>
> I've only created md0 from hda7 and sda7 and md2 from hda8 and sda8.
> I also have this in /etc/mdadm/mdadm.conf:
>
> DEVICE /dev/hda* /dev/sda*
> ARRAY /dev/md0 devices=/dev/hda7,/dev/sda7
> ARRAY /dev/md2 devices=/dev/hda8,/dev/sda8
>
> (My plan is that if I can get md0 working as /, then I'll setup md1 as
> another raid array for the older system I installed initially, on hda6.
> I'll use sda6 as its mirror.)
>
> But cat /proc/mdstat though shows already md1 exists (!) and it seems to
> be what I thought should be md2!
>
> Personalities : [raid1]
> md2 : active raid1 dm-5[1] dm-4[0]
> 121531584 blocks [2/2] [UU]
>
> md1 : active raid1 sda8[0] hda8[1]
> 121531584 blocks [2/2] [UU]
>
> md0 : active raid1 sda7[0] hda7[1]
> 12586816 blocks [2/2] [UU]
>
> Where did md1 come from? What device is "dm-5" and "dm-4"?
>
> I should mention that when trying to create the md0 raid array I got an
> mdadm error something like "Invalid parameter", and an mdadm -Ds showed
> that md0 had the same ID as md2. I had to do an mdadm --stop --scan
> before I could get the "mdadm --create /dev/md0 --level=1
> --raid-devices=2 /dev/sda7 missing" to work. After it did, an
> "mdadm -Ds" showed that md0 had a different ID to md2 (and there was no
> md1 at that point, either).
>
> Though just now checking that again I see that mdadm -Ds shows that
> there is a /dev/md1 array and that it has the same UUID as /dev/md2!
>
> Also when I try to boot up now the system drops me into maintenance
> mode when it attempts to check /dev/md2 (/home) and fsck reports this
> error:
>
> /dev/md2: the filesystem size according to the superblock is
> 30,382,923 blocks.
> Physical size of the device is 30,382,896 blocks.
> Either the superblock or the partition table is likely to be
> corrupt!
>
> If I run fdisk on /dev/hda or /dev/sda it tells me that hda8 and sda8
> have 121,531,693+ blocks.
>
> If I run fdisk on /dev/md2 it says it contains no partition table, and
> that it has 30,382,896 cylinders.
>
> I've previously copied /home to a spare partition, so wasn't too
> frightened of running fsck on /dev/md2. It seemed to complete fine,
> reporting no errors, but it always reports "the filesystem size according
> to the superblock is 30,382,923 blocks. Physical size of the device is
> 30,382,896 blocks. Either the superblock or the partition table is likely
> to be corrupt! Abort<y>? "
>
> If I "mount /dev/md2 /home", everything looks good - all the files seem
> to be there.
>
> So my two questions are: is a raid mirror device supposed to have a
> partition table? If so, what should it be set to - just one partition
> containing the number of blocks that the real partitions making it up
> have? What should the start and end cylinders be set to?
>
> And secondly, how do you tell grub to use md0 instead of hd0 or hd1?
>
> luke
>
> ------------------ For reference: ----------------------
>
> From: Jeff Waugh <[EMAIL PROTECTED]>
> Subject: Re: [SLUG] Adding RAID to Linux *after* installation?
> Date: Sun, 30 Jul 2006 07:03:37 -0700
> To: [email protected]
>
> <quote who="[EMAIL PROTECTED]">
>
>> mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hda7 /dev/sda7
>>
>> it refuses, as /dev/hda7 ("/") is mounted.
>
> Okay, so do this instead:
>
> mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda7 missing
>
> That will create a 2 device array with one missing device. You need to
> bring
> up the array (watch /proc/mdstat to see its status), mount it, then copy
> over everything from / (using cp -a or similar). Now set up everything in
> the copied partition to boot from /dev/md0 instead of /dev/hda7, and then
> reboot. Boot from /dev/hda0 by using the grub menus (if you've made sure
> they're changed), or edit the boot command line to do it manually. You
> should find yourself running a system with / on /dev/md0. At this point,
> you
> can use mdadm to add /dev/sda7 to the array - after checking everything is
> okay, of course! :-)
>
> This is not a wildly uncommon thing to do, but it's so easy to install
> with
> RAID now that I think most people just do that.
>
>> Obviously I should try this on the /home partition, not slash, until I
>> get
>> the steps worked out. At least that way if I lose any data, it'll be a
>> tiny amount of junk instead of 10GB of carefully setup Linux system!
>
> That's a good idea. :-) Running an array reliably on / or /boot requires
> some extra work anyway.
>
> - Jeff
>
> -----------------------------
>
> From: Jamie Wilkinson <[EMAIL PROTECTED]>
> Subject: Re: [SLUG] Adding RAID to Linux *after* installation?
> Date: Mon, 31 Jul 2006 15:11:56 +1000
> To: [email protected]
>
> This one time, at band camp, [EMAIL PROTECTED] wrote:
>>I couldn't even find a howto for setting up a software raid (well, not
>>one that talked about mdadm - only old ones talking about the older
>>raidtools).
>
> http://lists.slug.org.au/archives/slug/2004/05/msg00374.html
> --
>
>
> --
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
>
>
--
---<GRiP>---
Electronic Hobbyist, Former Arcadia BBS nut, Occasional nudist, Linux
Guru, SLUG President, AUUG and Linux Australia member, Sydney
Flashmobber, Tenpin Bowler, BMX rider, Walker, Raver & rave music lover,
Big kid that refuses to grow up. I'd make a good family pet, take me home
today!
Some people actually read these things it seems.
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html