2

I've a linux server with 2 IDE HD & Raid (hda - hdb)

I've changed the "BAD" hdb with a new:

mdadm --fail /dev/md2 /dev/hdb3

mdadm --fail /dev/md0 /dev/hdb2

mdadm --fail /dev/md1 /dev/hdb1

mdadm --remove /dev/md1 /dev/hdb1

mdadm --remove /dev/md0 /dev/hdb2

mdadm --remove /dev/md2 /dev/hdb3

... change hdb .... fdisk the new hdb ..... and:

mdadm --add /dev/md1 /dev/hdb1

mdadm --add /dev/md0 /dev/hdb2

mdadm --add /dev/md2 /dev/hdb3

Now I need to rebuild the grub/mbr for new hdb

Is it the correct way?

grub

root (hd0,0) <-- ???

setup (hd0) <-- ???

quit

Thanks!

peterh
  • 4,914
  • 13
  • 29
  • 44
SmV
  • 25
  • 1
  • 5

3 Answers3

2

When the RAID array has finished to resync, run:

grub
root (hd1,0) 
setup (hd1) 

Here there is a full howto.

lg.
  • 4,579
  • 3
  • 20
  • 20
1

Instead of using grub on each drive. You can just copy the mbr over.

To copy the MBR from sda into a file called /mbrbackup:

dd if=/dev/sda of=/mbrbackup bs=512 count=1

Now to restore the image to sdb

dd if=/mbrbackup of=/dev/sdb bs=446 count=1

MBR is divided into 3 sections

  1. Bootstrap . 446 bytes

  2. Partition table. 64 bytes

  3. Signature. 2 bytes

See http://www.cyberciti.biz/faq/howto-copy-mbr/ for source.

Richard Holloway
  • 7,256
  • 2
  • 24
  • 30
  • It is trivial to use grub when you have two disks but it is a nuisance when you have 16 or more disks, and this copying approach is much quicker in those situations. The only thing to be careful of is not to copy the empty MBR over the good MBR. It can easily happen if you don't pay attention. – Richard Holloway Oct 05 '10 at 15:45
1

Will this work?

dd if=/dev/sda of=/dev/sdb bs=446 count=1
jscott
  • 24,204
  • 8
  • 77
  • 99