Raid 1 on a Mac - PPC - replace failed drive

home | blog | Terrible people and places | Covid-19 links | Teh Internet | guest blog |rants | placeholder | political | projects | Gwen and Liam | Citadel patched | Tools | Scouts



So nagios tells ya that one of the drives failed.  Here is how to fix it:

Check for which drive failed (hopefully only one).
Eg if sda fails:

root@blah:/etc# cat /proc/mdstat 
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md0 : active raid1 sda3[2](F) sdb3[1]
      966797248 blocks [2/1] [_U]
      
md1 : active raid1 sda4[0] sdb4[1]
      4882368 blocks [2/2] [UU]
      
unused devices: <none>

(crap, more work eh?)

And the drive geometry is:  - hint use mac-fdisk on the ppc machine as regular fdisk won't show Apple partitions!
----------------------------------------------------------------------------------------------------------
Command (? for help): p
/dev/sda
        #                    type name                   length   base       ( size )  system
/dev/sda1     Apple_partition_map Apple                      63 @ 1          ( 31.5k)  Partition map
/dev/sda2         Apple_Bootstrap untitled                 2048 @ 2048       (  1.0M)  NewWorld bootblock
/dev/sda3              Linux_RAID untitled           1933594624 @ 4096       (922.0G)  Unknown
/dev/sda4              Linux_RAID untitled              9764864 @ 1933598720 (  4.7G)  Unknown
/dev/sda5              Apple_Free Extra                    1984 @ 64         (992.0k)  Free space
/dev/sda6              Apple_Free Extra                10161584 @ 1943363584 (  4.8G)  Free space

Block size=512, Number of Blocks=1953525168
DeviceType=0x0, DeviceId=0x0
----------------------------------------------------------------------------------------------------------

Change /etc/yaboot.conf
edit boot=/dev/sda2 to point to the good /dev/sdb2 (boot partition for mac stuff)
run:

mkofboot
ybin

That makes the boot loader point to the good drive during boot.  Don't bother with yabootconfig as it seems broken for raid boot setups.

Now you should be able to partition the replacement disk the same as the remaining good one.  See the config on the main page for that.
To partition, you will need the mac-fdisk running on a ppc machine.

I did not have one, so I used the recovery in the debian ppc iso: 
qemu-system-ppc -m 1024 -vnc 192.168.1.44:5 -cdrom /home/youruser/Downloads/debian-6.0.0-powerpc-netinst.iso -boot d /dev/sdd
(where sdd is where the usb connected sata drive came up when connected to my system).
vncviewer 192.168.1.44:5 to see what is going on, and pick rescue to boot in to rescue mode

Now run:
mac-fdisk /dev/hda which is where the disk will probably be in the ppc emulator
Now, mostly easy, but you will need to start off with:
i (initialize the partition map) - makes the silly apple partition map (think mbr but for macs).
 - warning, the assumed size of the drive will be incorrect, you will need to make it match what is in the output of the mac-fdisk on the real hardware, currently : Number of Blocks=1953525168
b (create new 800K bootstrap) - makes a partition at hda2 for the "NewWorld boot block" yaboot crap.
 - The free space is the partition you create it in... If you are not keeping Mac OS, you can delete the "other" partitions
  -- and create the 800K bootstrap partition in the free space by answering 2P for the "first block" question - where the free space is the second partition.
  -- if no b command, use this: C XXXX YYYY bootstrap Apple_Bootstrap (where XXXX is the start block and YYYY is the end block - or use 800k for size).
 ---- Hell, just create all the partitions this way:
  -- C XXXX YYYY untitled Linux_RAID   (where XXXX is the base and YYYY is the length).  - and then move the partition as needed.

C (create the right size block for hda3,4 (one at a time, and move the blocks with (r)eorder to make them in the right spots to match the other disk) and have the right label and type.)
- Yes, I realize I left some space at the end of the drive, that is to account for different size disks.  If you get a non-1TB drive in future, you will thank me as it may not have exactly the same geometry!

Now hopefully we will have the ability to boot the live system bootable from the good drive /dev/sdb2 (might need to know open firmware boot options in case this needs to be forced (or press option during boot to fix))

Use mdadm to remove the faulty drive via:
mdadm --manage /dev/md0 --fail /dev/sda3
mdadm --manage /dev/md1 --fail /dev/sda4

Check:
cat /proc/mdstat again to see that you got rid of the failed drive - all of it's parts

mdadm --manage /dev/md0 --remove /dev/sda3
mdadm --manage /dev/md1 --remove /dev/sda4

Shutdown the system and pop in the drive you made the new geometry with in the emulator (or format it using mac-fdisk after bringing it back up before adding it back in to the raid)
Check things out with mac-fdisk to compare the drive layouts one more time...

mdadm --manage /dev/md0 --add /dev/sda3
mdadm --manage /dev/md1 --add /dev/sda4

Watch the rebuild with:
watch cat /proc/mdstat

Fin!



[æ]