September 23, 2009

RAID: Installing grub on the other Disks

So, you've followed my previous blog: Replacing faulted drive on Linux software RAID (MDTOOLS), you already know how to swap a faulty drive with a new one, but what happens if you need to substitute primary disk where your Computer makes boot ?

After adding a new disk to your raid chain it's a good idea to make it bootable as well by installing grub on MBR. When boot drive in your raid array becomes faulty all you've to do is to power off your machine, substitute your faulty drive and boot your computer again. If you've properly set bios boot sequence to iterate between primary, secondary, ... you can boot your raid array again, second or third HD makes the boot because you've installed grub on it, pretty easy and straightforward, this contributes to have a bulletproof system.

How to install grub on other disks ?

First enter grub console:

~# grub
Probing devices to guess BIOS drives. This may take a long time.


GNU GRUB  version 0.97  (640K lower / 7168K upper memory)
[ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]
grub> root (hd1,0)
grub> setup (hd1)
grub> quit

Where HD1 means second disk (grub starts counting from 0), HD2 means third disk and so on

If you've your boot partition inside a drive array as well it becomes easy to swap disks and replace them when faulty, here's an example:

boba:~# fdisk -l /dev/sda
Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0003272d
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          12       96358+  fd  Linux raid autodetect
/dev/sda2              13          73      489982+  fd  Linux raid autodetect
/dev/sda3              74         681     4883760   fd  Linux raid autodetect
/dev/sda4             682       38913   307098540   fd  Linux raid autodetect

take a look at my fstab:

boba:~# cat /etc/fstab
# /etc/fstab: static file system information.
# proc /proc proc defaults 0 0
/dev/md2 / ext3 errors=remount-ro 0 1
/dev/md0 /boot ext2 defaults 0 2
/dev/mapper/storage-storage /home xfs defaults 0 2
/dev/md1 none swap sw 0 0
/dev/hda /media/cdrom0 udf,iso9660 user,noauto 0 0

As you can see my /dev/md0 is the boot partition, /dev/sda1 is a part of it, it doesn't matter if you're using RAID1,5,6,10,...

With this hint you can boot your machine again, even if your primary disk has gone 

Hope it helps


Andrea (Ben) Benini


Click Here!