LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   RAID1 rebuilt after failure, won't boot OS (https://www.linuxquestions.org/questions/linux-server-73/raid1-rebuilt-after-failure-wont-boot-os-657073/)

ewolf 07-20-2008 11:00 PM

RAID1 rebuilt after failure, won't boot OS
 
Hello,

I recently had a small typo in my 'dd' command's of= parameter, which destroyed the first few kibibytes of data on my software RAID1's first disk, /dev/sda (I'm using mdadm).

/dev/sdb, the RAID1's second disk, was unaffected.

I figured that I could just manually 'fail' sda to take it out of the array. I would then copy the partition table of sdb to sda, re-add sda to the array, then let sda sync up to sdb. I did this, but after synchronization completed, I tried rebooting from sda (what my system had previously been booting from), but this time the console displayed "Operating System not Installed" or some similar message.

I then tried booting from sdb, but that would just hang, with nothing on the console. I had never tried booting from sdb before, so I think it was ver likely that way before my mishap with dd, since I didn't make changes to sdb.

Anyways, as far as my logic dictates, this should have worked, with sda booting up flawlessly and everything being back to normal. However, this is obviously not the case. Can anyone think of a step I may have missed? Do I need to reinstall grub on sda? What else could it be?

Thanks,
Elijah

archtoad6 07-21-2008 07:40 AM

1st, have you verified that the synchronization worked, that the RAID is re-built & readable? Can you access your data from a live CD?

If so, then I think you are right -- you need to re-install GRUB. This time put it in the MBR of both drives.

BTW, what command did you use to "copy the partition table of sdb to sda"? Was it something like:
Code:

dd if=/dev/sdb of=/dev/sda size=512 count=1
That would have copied the boot loader code as well as the partition table. Better to have used:
Code:

dd if=/dev/sdb of=/dev/sda skip=446 seek=446 size=64 count=1
See:
http://en.wikipedia.org/wiki/Master_boot_record

ewolf 07-21-2008 09:10 AM

Quote:

Originally Posted by archtoad6 (Post 3221411)
1st, have you verified that the synchronization worked, that the RAID is re-built & readable? Can you access your data from a live CD?

checking the status with
Code:

cat /proc/mdstat
showed that the sync had completed, with a 'UU' for all RAID partitions. I did boot up with a live cd, and gparted showed that my partitions were all there on both disks. Would I be able to mount RAID partitions as ext3 without messing up the RAID array?

Quote:

BTW, what command did you use to "copy the partition table of sdb to sda"? Was it something like:
Code:

dd if=/dev/sdb of=/dev/sda size=512 count=1
That would have copied the boot loader code as well as the partition table. Better to have used:
Code:

dd if=/dev/sdb of=/dev/sda skip=446 seek=446 size=64 count=1

I know what you mean, I've definitely made that mistake in the past, but wasn't sure how to how to use dd for just the partition table or just the mbr. :-)
For the partition table, I used
Code:

sfdisk –d /dev/sdb | sfdisk /dev/sda
I will try reinstalling grub on both disks tonight when I get home. Although, I have never reinstalled or switched bootloaders before, I have only done new installations. Are there any pitfalls to reinstalling the bootloader I need to be aware of? Will a simple
Code:

grub-install /dev/sdX
do the trick?

Thank you very much.

archtoad6 07-21-2008 04:04 PM

1) Checking w/ a live CD:

I would think that mounting either disk r/o as ext2/3 couldn't hurt & might give you the verification you need.

I was in fact wondering if you could mount & use the array w/ a live CD.


2) Bootloader reinstallation pitfalls:

I can't be much help here -- I use the MEPIS System Wizard to re-install GRUB. But if the command you propose would work in a non-RAID environment, it should work here.

If you want to dig deeper, post (in a "Code:" block, please) the output of:
Code:

fdisk -l
& explain, at least briefly, the use of each partition.


3) Good use of sfisk -d.

ewolf 07-21-2008 11:05 PM

Quote:

Originally Posted by archtoad6 (Post 3221941)
I was in fact wondering if you could mount &
use the array w/ a live CD.

1) I was able to successfully mount my ext3 RAID partitions in read-only
mode using an ubuntu livecd.

2)
Code:

ubuntu@ubuntu:/mnt3$ sudo fdisk -l /dev/sda

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          30      240943+  fd  Linux raid autodetect
/dev/sda2              31        358    2634660  fd  Linux raid autodetect
/dev/sda3            359      60801  485508397+  fd  Linux raid
autodetect

fdisk -l /dev/sdb looked exactly the same. sda1 is the /boot
partition, sda2 is a swap partition, and sda3 is the root filesystem.

I installed grub onto both drives, and am now typing from my RAIDed Debian installation. I tested booting from both drives, and all is well.
Thank you very much for your help.


All times are GMT -5. The time now is 12:42 AM.