[CentOS] Problem with dual-booting soft-RAID

Thu Jun 8 16:17:18 UTC 2006
Les Mikesell <lesmikesell at gmail.com>

On Thu, 2006-06-08 at 17:36 +0200, Kai Schaetzl wrote:
> >  
> > Is it boot from boot partition, install grub, copy to second disk.
> 
> No, I installed a normal RAID setup with the CentOS install CD on both 
> disks (no LVM) and then installed grub to the second disk additionally 
> after setup had finished. That could be done from the setup screen as well 
> but it's not supported, you can only choose which disk to install to, but 
> not to both of them. A serious flaw in the setup screen I think, but one 
> made at the upstream vendor.

There are two problems.  One is that you have to figure out what
physical disks make up the raid mirror.  That's not too hard because
you have the partition device names somewhere and can probably figure
out the underlying disk device from that and write the grub loader
into the MBRs.  The other problem is more complicated.  Once the bios
does the initial boot for you, loading the first part of grub, grub
needs to know how to tell bios to load the rest of the kernel.  That
means that grub -when installed- needs to know which bios device will
hold the /boot partition.  Scsi controllers generally map the drives
in the order detected and will 'shift up' the second drive in the bios
perspective if the first one fails. That means you can install an
identically-configured grub on both drives.  IDE, on the other hand
does not shift the bios view of the drives so some of the HOWTO
instructions you'll find for hand-installing grub take this into
account.  However, most of the ways that IDE drives fail will make
the machine unbootable until you open the case and unplug it.  Then
you may have to adjust the bios settings to boot from the other
position - but while you have the case open it is probably easier
to shift the jumper or cable position so the working drive is the
primary.  Then if you followed one of the sets of instructions, grub
will load but will be looking for the now-missing 2nd drive for the
/boot partition to load the kernel.  SATA probably has it's own way
of doing things too.

Anyway, the fix is to boot the install/rescue CD with
'linux rescue' at the boot prompt, do the chroot it suggests,
then reinstall grub making sure that the device mapping is
right for your current disk configuration.

> I think your scenario above would very well fit if one of the drives failed 
> and got replaced. I'd then need to copy the partition structure to it, 
> resync and then setup grub on it (or setup grub first and then resync). I'm 
> not sure how I should copy the partition structure.
> The grub+RAID howto (3 years old) gives the following for copying the 
> structure:
> # sfdisk - /dev/hdx | sfdisk /dev/hdy
> Does this sound to be the right way?

Maybe... It's not that hard to do it by hand.  Do an fdisk -l on the
existing drive, then an interactive fdisk of the new mate, creating
the same sized partitions with type FD.

cat /proc/mdstat will show you the current raid setup
use
mdadm --add /dev/mdxx /dev/hdxx
to add a partition (replacing the xx's with your real identifiers),
then  'cat /proc/mdstat' will show the progress of the re-sync.
And you can re-install grub, but you'll have the same issue with
drive positions next time around.

-- 
  Les Mikesell
   lesmikesell at gmail.com