Scott Robinson Technical Lead

Replace a RAID Hard Disk in OSX Based Servers

I recently had to replace a hard disk in our OSX server at work. It had been a while since I had done this so I noted down the steps here to run through and change it. Work out which disk in your machine is faulty and replace it with a new drive.

To get started, open up terminal and run:

sh-3.2# diskutil list

This will give you a list of all the disks in your machine:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            999.9 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS Server HD               999.3 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS Untitled 1              2.0 TB     disk2s2
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk3
   1:                        EFI EFI                     209.7 MB   disk3s1
   2:                 Apple_RAID                         2.0 TB     disk3s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk3s3
/dev/disk4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk4
   1:                        EFI EFI                     209.7 MB   disk4s1
   2:                  Apple_HFS TimeMachine             2.0 TB     disk4s2
/dev/disk5
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Work                   *2.0 TB     disk5

The new disk in this machine is /dev/disk2. We now need to work out the Unique ID for our RAID array. So we’ll run the following command so that we can get our Unique ID:

sh-3.2# diskutil appleraid list

Which will provide the following output:

AppleRAID sets (1 found)
===============================================================================
Name:                 2TB Mirror
Unique ID:            E07AE421-43C5-4778-B1E3-DC3365F3266B
Type:                 Mirror
Status:               Degraded
Size:                 2.0 TB (2000054943744 Bytes)
Rebuild:              manual
Device Node:          disk5
-------------------------------------------------------------------------------
#  DevNode   UUID                                  Status     Size
-------------------------------------------------------------------------------
-  -none-    82D0A9C3-5ACB-4B3C-A4FC-FD473709E186  Missing/Damaged
1  disk3s2   81D8BD2A-894F-4720-8924-D4654001CF69  Online     2000054943744
===============================================================================

Next, we’ll add this disk to the existing array, the bad disk is listed in the array above as missing, because we’ve replaced it with a new disk.

sh-3.2# diskutil appleraid add member disk2 E07AE421-43C5-4778-B1E3-DC3365F3266B

This will now perform an operation to add this disk to the RAID array:

Started RAID operation on disk5 Work
Unmounting disk
Repartitioning disk2 so it can be in a RAID set
Unmounting disk
Creating the partition map
Adding disk2s2 to the RAID Set
Finished RAID operation on disk5 Work 2012+

And you’re now done for the addition of the drive. You now need to remove the old slice from the array by using this command:

sh-3.2# diskutil appleraid remove 82D0A9C3-5ACB-4B3C-A4FC-FD473709E186 E07AE421-43C5-4778-B1E3-DC3365F3266B

You can now check that your RAID looks good by running:

sh-3.2# diskutil appleraid list

The RAID status should now be showing as online.

Found this useful? Everything here is free and stays that way. If it saved you an afternoon, you can buy me a coffee.