Mac OS X: How to rebuild a software RAID mirror
Summary
Note: This article applies to Mac OS X 10.2 or later and Mac OS X Server 10.2 and later.
Occasionally, Disk Utility may report that a software mirror has become degraded and that it must be rebuilt. In such a situation, one drive has become out of sync with another. To rebuild the software mirror, follow these steps below.
Warning: Before proceeding, you must back up of all data, because failure to follow the steps correctly may result in data loss.
Products Affected
Mac OS X 10.4, Mac OS X 10.3, Mac OS X 10.2, Mac OS X 10.0
1. Open the Terminal (/Applications/Utilities/).
Note: If you are started up from CD, you may open the Terminal by choosing it from the File menu. Also note that you should not precede any commands with "sudo" if you have gone into single-user mode.
2. Type: sudo diskutil checkRAID
3. Press Return.
4. Enter your Admin user password when prompted, and press Return. This lists existing RAID sets on the computer. The output should look something like this:
RAID SETS
---------
Set Name: Test Mirror
Set Unique ID: Test Mirror53c35c34e6ca11d698410003938bb930
Set Type: Mirror
Set Device Node: disk4
-------------------------------------------------------------
# Device Node Status
-------------------------------------------------------------
0 disk1 (Bay 2 OK
1 Unknown Missing/Damaged
-------------------------------------------------------------
The numbers listed here are slice numbers. Make a note of which slice number on your system has issues for use later.
The example above shows that slice 0 of the mirror set "Test Mirror" is OK, but slice 1 is missing or damaged. It also shows that the Device Node for the mirror set "Test Mirror" is "disk4", and the Device Node for the OK disk in the mirror set is "disk1".
5. Type: sudo diskutil list
6. Press Return. This lists the available disks on the computer. Note that the numbers of the nodes will generally not correspond to the bays that the drives are in. The output will look something like this:
/dev/disk0
#: type name size Node
0: Apple_partition_scheme *57.3 GB disk0
1: Apple_partition_map 31.5 KB disk0s1
2: Apple_HFS Big Drive 60 GB Bay 3 57.3 GB disk0s2
/dev/disk1
#: type name size Node
0: Apple_partition_scheme *57.3 GB disk1
1: Apple_partition_map 31.5 KB disk1s1
2: Apple_Driver_OpenFirmware 512.0 KB disk1s2
3: Apple_Boot_RAID 57.3 GB disk1s3
/dev/disk2
#: type name size Node
0: Apple_partition_scheme *57.3 GB disk2
1: Apple_partition_map 31.5 KB disk2s1
2: Apple_Driver43 28.0 KB disk2s2
3: Apple_Driver43 28.0 KB disk2s3
4: Apple_Driver_ATA 28.0 KB disk2s4
5: Apple_Driver_ATA 28.0 KB disk2s5
6: Apple_FWDriver 256.0 KB disk2s6
7: Apple_Driver_IOKit 256.0 KB disk2s7
8: Apple_Patches 256.0 KB disk2s8
9: Apple_HFS Partition 1 14.3 GB disk2s9
10: Apple_HFS Partition 2 14.3 GB disk2s10
11: Apple_HFS Partition 3 14.3 GB disk2s11
12: Apple_HFS Partition 4 14.3 GB disk2s12
/dev/disk3
#: type name size Node
0: Apple_partition_scheme *57.3 GB disk3
/dev/disk4
#: type name size Node
0: Test Mirror *57.3 GB disk4
1: Test Mirror 57.3 GB disk4
This shows that the Device Node for the unformatted replacement disk is "disk3," as it is not yet formatted as a typical hard drive such as /dev/disk1. If a drive is missing altogether from the list, this may mean that the drive has failed. If so, replace the drive and repeat steps 5 and 6.
7. In Disk Utility, reformat either the drive that was labeled as "Missing/Damaged" or the drive that was replaced.
8. If the RAID was the computer's startup volume, start up to the Mac OS X or Mac OS X Server installation CD's. Once started up, select Disk Utility from the Installer Menu.
9. In the list of drives, you should see the RAID Mirror Volume and other hard drives. The intact RAID drive should be dimmed, but the newly formatted drive should be listed normally. From the list of Volumes, select the RAID Mirror Volume, and click the RAID tab. In the window below, there should be a list of drives that are currently in the RAID. From the list of drives to the left, select the newly-formatted drive, and drag it into the list of RAID drives. Click the Rebuild button below.
Note: In versions of Mac OS X prior to 10.4, a message says that " Adding this disk to the RAID will destroy its contents." This message indicates that the data on the replacement drive will be destroyed, not the data on the mirror. The current data on the mirror set will remain intact after the rebuild.
10. If the drive does not mount after the repair is complete, restart the server.
11. If the rebuild is not successful, it may be due to being started up from the RAID volume. If this is the case, start up to a Mac OS X or Mac OS X Server installation disc and repeat step 9. If the rebuild process fails and you are not started up from the RAID Volume, proceed to step 12.
12. Sometimes Disk Utility may not successfully rebuild a degraded RAID mirror. In such a situation, you should use the command line tool diskutil instead of Disk Utility to rebuild RAID mirror sets. Follow these steps:
If necessary, repeat steps 1 through 10.
13. Type the command indicated for your system version.
For 10.2 to 10.3.9:
sudo diskutil repairMirror DeviceNode sliceNumber fromDisk toDisk
Note: Replace "DeviceNode" with the actual Device Node for the mirror (disk4 in the example output). Replace "sliceNumber" with the actual slice number to be replaced (1 in the example output). Replace "fromDisk" with the actual Device Node for the OK disk in the mirror set (disk1 the example output). Replace "toDisk" with the actual Device Node for the replacement disk (disk3 in the example output). So to rebuild the mirror set "Test Mirror" in example, you would type:
sudo diskutil repairMirror disk4 1 disk1 disk3
For 10.4 or later:
sudo diskutil repairMirror DeviceNode DeviceNode
Note: Replace the first "DeviceNode" argument with the actual Device for the mirror (disk4 in the example output). Replace the second "DeviceNode" argument with the actual Device Node for the replacement disk (disk3 in the example output). So to rebuild the mirror set "Test Mirror" in example, you would type:
sudo diskutil repairMirror disk4 disk3
14. Press Return.
15. If the drive does not mount after the repair is complete, restart the server.