New User? Register here - Existing Users: Username: Password: [Advanced Login]

 

 

Current Poll

Your preferred Interactive shell?









( 1391 votes ~ 15 comments )

 

Weblog entry #1 for martijnvanb

raid1 Replacing a disk
Posted by martijnvanb on Tue 13 May 2008 at 12:44
Tags: ,
- mdadm --detail /dev/md$ check which disk is alive
- shutdown
- replace crashed harddisk
- boot machine
- sfdisk -d /dev/sda | sfdisk /dev/sdb
- mdadm --detail /dev/md0
- check partitions
- rebuild partitions with mdadm --add /dev/md0 /dev/sdb1
- check for other raid partitions
- check status with watch "cat /proc/mdstats"

After that it is finished I am ready for the next harddisk crash

 

Comments on this Entry

Posted by undefined (192.91.xx.xx) on Wed 14 May 2008 at 18:44
[ Send Message ]
huh?

i presume you are replacing sdb (since you are mirroring the partition layout of sda onto sdb with sfdisk), but then you are adding sdc1, not sdb1, to the md0 raid array.

and why are you shutting down the machine? can't you hotswap? ;-) (i can't wait to build a new computer with a sata driver that supports hotswapping, as my last build was 4 years old and was before everybody standardized on AHCI; http://linux-ata.org/driver-status.html#matrix.)

[ Parent | Reply to this comment ]

Posted by martijnvanb (213.84.xx.xx) on Wed 14 May 2008 at 20:42
[ Send Message | View Weblogs ]
Yeah thanks you were right.
I had a crash of sdb, and the disk was not hot swapable

[ Parent | Reply to this comment ]

Posted by Anonymous (85.22.xx.xx) on Thu 15 May 2008 at 17:09
If you boot from one of the disks in your RAID, you should also install GRUB (or whatever bootloader you use) into the MBR of both disks. Whatever disk fails, your system will still be bootable.

[ Parent | Reply to this comment ]

Posted by undefined (192.91.xx.xx) on Thu 15 May 2008 at 19:00
[ Send Message ]
i presume you mean that /boot is on raid1 (eg md0), which is still accessible as a normal partition (eg sda1), to grub's benefit.

that's the configuration i have: three partitions (sd[ab]1, sd[ab]5, sd[ab]6 => md0, md1, md2) for /boot, swap, and lvm. i've tried to think through how to configure grub to support booting off either drive, but i see a few problems (and haven't had time to experiment and work through it). since moving to this configuration 3 years ago, i've not had a boot disk failure, so i have no practical experience.

how do you configure grub to accommodate this?

grub stage1 config

1. i presume a standard "grub-install" won't be sufficient to write a unique stage1 on each drive so that it is instructed to look for the stage2 on the same drive (ie sda1 on sda & sdb1 on sdb). what's a working example for the grub shell?

grub stage2 config

2. don't forget to configure menu.lst to use "fallback", but how well does a "fallback" config integrate with "update-grub"?

and this is assuming that your drive fails in such a way that the disk controller totally ignores it or eventually gives up on it (instead of getting hung up trying to access it) and the BIOS boots from the remaining drive (not getting confused by potential disk renumbering).

i've had PATA drives fail in a variety of ways and i've had BIOSes react in a variety of ways. i have no experience with SATA drives failing and how SATA disk controllers respond. with PATA controllers i've always had the drive name (either "hd0,0" for grub or "hda" for linux) assigned according to the port it was plugged into (but that's because each physical port was directly associated with a specific controller, ie primary or secondary). i don't have enough experience with SATA to know how it should and/or does work in failure modes.

[ Parent | Reply to this comment ]

Posted by daemon (146.231.xx.xx) on Thu 15 May 2008 at 22:50
[ Send Message | View Weblogs ]

"i presume you mean that /boot is on raid1 (eg md0), which is still accessible as a normal partition (eg sda1), to grub's benefit."

More than just that, there's the actual MBR code that sits in the first sector of the "primary" disk ("primary" according to the BIOS).

"that's the configuration i have: three partitions (sd[ab]1, sd[ab]5, sd[ab]6 => md0, md1, md2) for /boot, swap, and lvm. i've tried to think through how to configure grub to support booting off either drive, but i see a few problems (and haven't had time to experiment and work through it). since moving to this configuration 3 years ago, i've not had a boot disk failure, so i have no practical experience.

how do you configure grub to accommodate this?"

AFAICT you can't use any of the automated grub tools, you have to do it from the grub command shell, but it's pretty straight forward. If you had your /boot on /dev/sda1 and /dev/sdb1 (both of which are in a RAID 1 array as something like /dev/md0), then you could type this in the grub shell:

device (hd0) /dev/sda
root (hd0,0)
setup (hd0)

device (hd0) /dev/sdb
root (hd0,0)
setup (hd0)

If your disk is so borked that grub would be using the "redundant" copy of the MBR, grub will think that that disk is (hd0), which is why you need the device intructions, to fool the bootloader setup/installation routines into thinking that (at least while setting things up) each drives MBR is on "(hd0)". The rest should be pretty straight forward for anyone who's familiar with a grub menu.lst.

Cheers
:wq

[ Parent | Reply to this comment ]

Posted by martijnvanb (213.84.xx.xx) on Thu 15 May 2008 at 17:48
[ Send Message | View Weblogs ]
Thanks for the reminder of grub :)

[ Parent | Reply to this comment ]

 

 

Flattr