Ubuntu software RAID primary disk failure

OS: Ubuntu 6.06
Setup: 2 disks RAID 1.  3 partitions, 2 of which are md devices.
Problem:Primary disk failure with grub 25 error and bad sectors

Machine was not booting past grub 1.5 and was saying “Error 25”.

Grub error code 25:

 25 : Disk read error: This error is returned if there is a disk read error when trying to probe or read data from a particular disk.

Basically the primary disk was wasted, but, the second disk wouldn’t boot because the primary disk was active enough to start up grub stage 1.5… and fail.

Booted up with the Ubuntu 6.06 CDROM and selected rescue.  Setup networking and then was given an option to try and start a shell on any of the partitions.

Although disk0 was the faulty disk it was not possible to mount any of the disk1 partitions and it gave an error.

Was able to mount the root partition on the faulty disk and use a shell from the rescue disk.

Ran fsck.ext3  on /dev/hdc1, /dev/hdc3 and corrected any errors on the partitions.

In the shell it was possible to mount the mdX raid devices, but, not the individual /dev/hdcX devices as they were already in use.  “cat /proc/mdstat” showed that hdc was being used by the md0/md1 devices.

Mounted the file systems on the secondary disk with:

mount /dev/md1 /mnt
mount /dev/md0 /mnt/boot
chroot /mnt

Then ran grub and following commands:

grub>device (hd0) /dev/hdc
grub>root (hd0,0)
grub>setup (hd0)
grub>quit

Now, grub was definately installed on the second disk but on reboot it would still boot off the first disk.  Removed the partition table from the faulty disk0 using fdisk and rebooted and the system booted up fine other than numerous hda disk errors.

URL:

Linux Software RAID 1

I was in the situation where the primary disk (hda) had dropped out of the RAID arrays it was in due to seek errors so needed to replace the primary disk.

URLs:

  • http://www.royong.com/showthread.php?t=16
  • http://www.linuxselfhelp.com/gnu/grub/html_chapter/grub_3.html
  • http://www.linuxquestions.org/linux/answers/Applications_GUI_Multimedia/Set_up_Grub_by_hand

Needed to install the boot loader onto the secondary disk as no doubt it hadn’t been setup.

Tried the grub-install command:

grub-install /dev/hdc

Thinking that this would do everything required I rebooted and took the primary disk out. The machie started booting up and then it kept printing to the screen “grub grub grub……”. Obviously not right so put the primary disk back in and rebooted.

This time ran the following:

grub
grub>find /grub/stage1
grub>device (hd0) /dev/hdc
grub>root (hd0,0)
grub>setup (hd0)
grub>quit

Then I rebooted and removed the primary disk… this time it booted up fine so I added the new disk.

Partition the new disk:

 fdisk -l /dev/hdc

And create the same partitions on the new machine.

sfdisk -d /dev/hdc | sfdisk /dev/hda

Or manually using fdisk.

Re-add the disks using mdadm…

mdadm /dev/md0 -a /dev/hda1
etc…