Software Raid - recreate failed disk.
I'm running a redhat 9.0 server for a friend, that has 2 80GB disks mirrored together (hda and hdc). All has been working fine. I've been looking at what would happens if a disk fails, and I can see that you must manually re-create the partition table when you replace a disk, does any one know a way of doing this automatically ? What I would like to do is create some sort of script so all my firend would have to do is replace the failed drive and the script would re-create the partitions and then re-start the mirror process.At the moment I'm stuck on the first bit, duplicating the partition information onto another disk.
sfdisk is your friend in this situation..
Say I have /dev/hda and I want the same partition layout for /dev/hdc I would do:
/sbin/sfdisk /dev/hda -f /dev/hdc
Then you can use raidhotadd to add the raid devices to sync them up.
Take a look at /proc/mdstat for any existing raid setup and you can use raidhotadd to add the any partition to an existing raid device.
Wow thanks, thats just what I needed !! :)
I've been looking at the new utils - mdadm which seams to make life a little easier to use, but it's only on later versions at the moment (FC 1 and 2). anyway thanks for that help !
Sorry to report but just got home and tried it and it didn't work :(
sfdisk /dev/hdc -f /dev/hda as i trashed /dev/hda and I wanted to copy it back from C back to A.
and way go the following error
sfdisk : can only specify only one device (expect wit -s or -l)
Repartition the drive by hand using fdisk...try and get the partition sizes as close as you can to the survivng disk then raidhotadd the drive
Guys found the solution so thought I would share it with you.
This is my configuration.
Primary Master = hda
Secondary Master = hdc
CD-Rom = hdd.
You need to do this for both disks.
Firstly need to backup the disk's MBR, and basic partition table.
dd if=/dev/hda of=hda.mbr bs=512 count=1
Second - backup the disks partition table (including the extended information).
sfdisk -d /dev/hda > hda.sfd
Once a failed disk has been replaced, lets assume it was hda.
Restore the MBR.
dd if=hda.mbr of=/dev/hda bs=512 count=1
Restore the Extended Partition information as well.
sfdisk -O change.log /dev/hda <hda.sfd
Check that the partition table is loaded
fdisk -l /dev/hda
Restart the Mirror sync process.
raidhotadd /dev/md? /dev/hda
to see the progress of the mirroring - watch -n1 cat /proc/mdstat
Also to note that I'm using LILO - this seams to be installed on both disks, but grub only gets install on the primary disk. If you loose the primary disk - you cannot boot, but you can still boot if you loose the secondary disk. With lilo either disk can be lost and the system boots without problem.
Hope this helps anyone who was in the same boat i was......
|All times are GMT -5. The time now is 05:34 AM.|