Archive for the ‘RAID’ Category

Configuring grub loader to boot from second drive of RAID1

May 12, 2010

The problem is, the grub boot loader doesn’t know about the software RAID, so it only installs the boot loader on the first drive. Which is good enough, unless the first drive is the one which fails after a few years.If the first drive fail or removed, the bootloader was unable to read its configuration leaving the system in an unusable and un-bootable state. All data was mirrored and RAIDed properly, only the bootloader was affected.

So here, the GRUB boot loader will be configured in such a way that the system will still be able to boot if one of the hard drives fails (no matter which one).

Preparing GRUB (Part 1)

We must install the GRUB boot loader on the second hard drive /dev/sdb: Follow these steps

grub
root (hd1,0)
grub> root (hd1,0)
 Filesystem type is ext2fs, partition type 0xfd

grub>
setup (hd1)
grub> setup (hd1)
 Checking if “/boot/grub/stage1” exists… no
 Checking if “/grub/stage1” exists… yes
 Checking if “/grub/stage2” exists… yes
 Checking if “/grub/e2fs_stage1_5” exists… yes
 Running “embed /grub/e2fs_stage1_5 (hd1)”…  15 sectors are embedded.
succeeded
 Running “install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2 /grub/menu.lst”… succeeded
Done.

grub>
quit
Now, back on the normal shell.

Preparing GRUB (Part 2)

We are almost done now. Now we must modify /boot/grub/menu.lst again. Right now it is configured to boot from /dev/sda (hd0,0). Of course, we still want the system to be able to boot in case /dev/sda fails. Therefore we copy the first kernel stanza (which contains hd0), paste it below and replace hd0 with hd1. Furthermore we comment out all other kernel stanzas so that it looks as follows:
vi /boot/grub/menu.lst
[…]
## ## End Default Options ##

title Debian GNU/Linux, kernel 2.6.18-4-486 RAID (hd0)
root (hd0,0)
kernel /vmlinuz-2.6.18-4-486 root=/dev/md0 ro
initrd /initrd.img-2.6.18-4-486
savedefault

title Debian GNU/Linux, kernel 2.6.18-4-486 RAID (hd1)
root (hd1,0)
kernel /vmlinuz-2.6.18-4-486 root=/dev/md0 ro
initrd /initrd.img-2.6.18-4-486
savedefault

In the same file, there’s a kopt line; check it have the raid device mentioned. (don’t remove the # at the beginning of the line!):
[…]
# kopt=root=/dev/md0 ro
[…]

Afterwards, update your ramdisk. Run,

update-initramfs -u

Now reboot your box!!
And finally your boot loader will looks like this – ( and try to boot from both drive ( hd0, hd1)

Implementing RAID-1

October 30, 2008

Here you will find the implementation of RAID level 1 (mirroring) with two different partition of same size on linux host.

First select 2 partition of equal size. If u have free space on your HDD u can create 2 new partition of same size using fdisk command, then run partprobe and create file system for newly created partition using mkfs.

Now install the mdadm package.
If you do not have md and raid1 module already loaded use modprobe to load it:
lsmod |grep raid1/md[to check whether they are loaded]

Load modules at boot time
No we need to make sure that raid kernel modules are loaded at the boot time.
echo raid1 >> /etc/modules
echo md >> /etc/modules
Load modules to the Kernel
modprobe raid1

modprobe md and again check with lsmod command.

N.B. The partition u just created need to be unmounted.

So your partitions are ready and raid1 and md modules also loaded on your kernel and make sure you have rsync installed on your system.

Then run the following command to create the raid device-

mdadm –create –verbose /dev/md0 –level=1 –raid-devices=2 /dev/sda10 /dev/sda11
Create a filesystem on RAID 1 Arrays
mkfs.xfs -f /dev/md0

Then mount the device
Edit mdadm.conf file
cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
mdadm –detail –scan >> /etc/mdadm/mdadm.conf
Edit /etc/fstab

As we want to make our system to mount new RAID 1 arrays after reboot we need to edit /etc/fstab file.
/dev/md0 /disk-1 ext3 defaults 0 2
To see the current status of your RAID partition type the following command

mdadm –detail /dev/md0