LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   want to (safely) test raid setup and ability to boot from alternate drives (http://www.linuxquestions.org/questions/linux-general-1/want-to-safely-test-raid-setup-and-ability-to-boot-from-alternate-drives-658678/)

checkmate3001 07-28-2008 12:01 AM

install grub with software raid (mdadm) - safetly boot from alternate drive(s)
 
Hello all,

I have successfully setup software raid1 with hot spare (total 3 drives) on my system and I want to test its ability to boot from one of the alternate drives if the primary dies.

/proc/mdstat
Code:

Personalities : [raid1]
md2 : active raid1 sdc6[2](S) sda6[0] sdb6[1]
      146480512 blocks [2/2] [UU]

md1 : active raid1 sdc5[2](S) sda5[0] sdb5[1]
      4883648 blocks [2/2] [UU]

md0 : active raid1 sdc1[2](S) sda1[0] sdb1[1]
      3903680 blocks [2/2] [UU]

md3 : active raid1 sdc7[2](S) sda7[0] sdb7[1]
      1020032 blocks [2/2] [UU]

fdisk -l
Code:

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1        486    3903763+  fd  Linux raid autodetect
/dev/sda2            487      19457  152384557+  5  Extended
/dev/sda5            487        1094    4883728+  fd  Linux raid autodetect
/dev/sda6            1095      19330  146480638+  fd  Linux raid autodetect
/dev/sda7          19331      19457    1020096  fd  Linux raid autodetect

Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1  *          1        486    3903763+  fd  Linux raid autodetect
/dev/sdb2            487      19457  152384557+  5  Extended
/dev/sdb5            487        1094    4883728+  fd  Linux raid autodetect
/dev/sdb6            1095      19330  146480638+  fd  Linux raid autodetect
/dev/sdb7          19331      19457    1020096  fd  Linux raid autodetect

Disk /dev/sdc: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdc1  *          1        486    3903763+  fd  Linux raid autodetect
/dev/sdc2            487      19457  152384557+  5  Extended
/dev/sdc5            487        1094    4883728+  fd  Linux raid autodetect
/dev/sdc6            1095      19330  146480638+  fd  Linux raid autodetect
/dev/sdc7          19331      19457    1020096  fd  Linux raid autodetect

End of grub\menu.lst
Code:

## ## End Default Options ##

title          Debian GNU/Linux, kernel 2.6.26
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.26 root=/dev/md0 ro
initrd          /boot/initrd.img-2.6.26
savedefault

title          Debian GNU/Linux, kernel 2.6.26 (single-user mode)
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.26 root=/dev/md0 ro single
initrd          /boot/initrd.img-2.6.26
savedefault

title          Debian GNU/Linux, kernel 2.6.18-6-amd64
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.18-6-amd64 root=/dev/md0 ro
initrd          /boot/initrd.img-2.6.18-6-amd64
savedefault

title          Debian GNU/Linux, kernel 2.6.18-6-amd64 (single-user mode)
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.18-6-amd64 root=/dev/md0 ro single
initrd          /boot/initrd.img-2.6.18-6-amd64
savedefault

title          Debian GNU/Linux, kernel memtest86+
root            (hd0,0)
kernel          /boot/memtest86+.bin

### END DEBIAN AUTOMAGIC KERNELS LIST

Should I be able to remove sda1 from the array and boot just fine? I'd rather know for sure before I give it a go.

Thank you.

mritch 07-28-2008 01:29 AM

backup. be sure to have the grub bootloader on all drives MBRs (important w/ sw-raid; grub-install hdX). now just remove one drive.. ;). there's an alternative way by marking a drive faulty - see man mdadm for more info.

sl, ritch

storkus 07-28-2008 01:59 AM

I just have to ask because it seems so obvious to me, but if you have 3 drives why aren't you running RAID 5 to get the best of both worlds?

Mike

checkmate3001 07-29-2008 12:32 AM

Why not RAID 5
 
I choose to use RAID1 over RAID5 primarily for reliability over speed.

I bought all 3 drives together and if for some reason 1 dies, I would naturally start to wonder about the other 2. Also, in the rare chance that 2 drives have faults I'm still ok.

I've also read about it and it seems that using RAID5 on a 3 drive setup doesn't really offer a huge amount of performance. I would rather have RAID5 with 5 or more drives.

Ideally I would like to have RAID6.

Correct me if I'm wrong.

checkmate3001 07-29-2008 12:35 AM

Quote:

Originally Posted by mritch (Post 3228305)
backup. be sure to have the grub bootloader on all drives MBRs (important w/ sw-raid; grub-install hdX). now just remove one drive.. ;). there's an alternative way by marking a drive faulty - see man mdadm for more info.

sl, ritch


Thank you. I will try that out sometime this week, when I get a chance.

checkmate3001 08-02-2008 03:20 PM

Check if grub is installed on hard drives
 
OK - before I attempt to install grub on my alternate hard drives I want to check to see if it is already installed. I also want to know (after I try to install it) whether or not it is installed.

Is there a way to verify that grub is installed on my alternate hard drives?

checkmate3001 08-03-2008 04:46 AM

install grub mdadm raid1 with hotspare
 
Well, I didn't find a (good) way to verify if grub was installed on my alternate drives. The only way I could really find out is unplug my primary drive and boot the system. I was left with a blinking cursor. So I took that as a 'NO'.

After a few searches and fiddling around I found out how to install grub on the alternate drives.

Some of this may be debian specific so double check before using yourself.

I ran:
Code:

grub-install /dev/sdb1
Searching for GRUB installation directory ... found: /boot/grub
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(fd0)  /dev/fd0
(hd0)  /dev/sda
(hd1)  /dev/sdb
(hd2)  /dev/sdc

grub-install /dev/sdc1
Searching for GRUB installation directory ... found: /boot/grub
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(fd0)  /dev/fd0
(hd0)  /dev/sda
(hd1)  /dev/sdb
(hd2)  /dev/sdc

Note: If you get an error like "grub: no corresponding bios drive" try running:
Code:

grub-install --recheck /dev/sdx
Where X is your primary drive (ie: sda1)
It checks for all the available drives to boot from and puts them in the device.map file. I choose to just re-install on the primary drive, because it doesn't work if you don't put a drive location... It should IMO - it just updates the device.map. I suppose you can manually alter this file also... but I would read the man page to find out for sure.

Then I ran:
Code:

#grub

    GNU GRUB  version 0.97  (640K lower / 3072K 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)
 Filesystem type is ext2fs, partition type 0xfd

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

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

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

Finally I added a couple boot entries to my menu.lst for fallback and to manually select if I need to.
my menu.lst (this is VERY debian specific):
Code:

== cut to save space ==
## fallback num
# Set the fallback entry. This allows you to boot from an alternate drive
# if the first drive of the array fails.
fallback        5

== cut to save space ==

### END DEBIAN AUTOMAGIC KERNELS LIST

## Fallback Entry (fallback 5)

title          Debian GNU/Linux, kernel 2.6.26 (sdb)
root            (hd1,0)
kernel          /boot/vmlinuz-2.6.26 root=/dev/md0 ro
initrd          /boot/initrd.img-2.6.26

## Fallback Entry (fallback 6)
title          Debian GNU/Linux, kernel 2.6.26 (sdc)
root            (hd2,0)
kernel          /boot/vmlinuz-2.6.26 root=/dev/md0 ro
initrd          /boot/initrd.img-2.6.26


I unplugged my primary drive (after shutdown of course) and booted it up. Lo and behold it came alive!
I haven't tried to boot off of one drive, but I'm sure it would work. I'm going to make a boot floppy as an additional backup just in case.

Hope this helps someone.

mostlyharmless 08-06-2008 01:35 PM

nice post
 
Nice post on raid 1 and grub; I'm sure it'll be helpful for a lot of people who ask the same grub questions. Not at all Debian specific though; other than the word "Debian" it ought to work with any distro. Certainly ought to work with minimal renaming of files for slackware, pclinux, ubuntu as far as I know. Still, probably a good idea to put a warning/disclaimer on it.


All times are GMT -5. The time now is 11:26 AM.