OS X diskutil appleRaid Tips and Tricks

root's picture

Create RAID 1 with missing volume (will destroy the data on the volume):

[osx@mini Volumes]$ diskutil appleRaid create mirror vbox JHFS+ disk2s2
Started RAID operation
Unmounting proposed new member disk2s2
Adding a booter for the RAID partition disk2s2
Creating a RAID set
Bringing the RAID partitions online
Waiting for the new RAID to spin up "2134725A-668E-45C3-BBD6-AAD5FF4D1991"
Initialized /dev/rdisk10 as a 477 GB case-insensitive HFS Plus volume with a 40960k journal
Mounting disk
Finished RAID operation
[osx@mini Volumes]$ diskutil ar list
AppleRAID sets (1 found)
===============================================================================
Name:                 vbox
Unique ID:            2134725A-668E-45C3-BBD6-AAD5FF4D1991
Type:                 Mirror
Status:               Online
Size:                 512.0 GB (511999967232 Bytes)
Rebuild:              manual
Device Node:          disk10
-------------------------------------------------------------------------------
#  DevNode   UUID                                  Status     Size
-------------------------------------------------------------------------------
0  disk2s2   C8F51C23-9D89-4C4D-8F5D-E41A2CAEAEF5  Online     511999967232
===============================================================================

Remove the raid on a volume. This won't destroy the data on the partition, it will simply be converted to normal:

[osx@mini Volumes]$ diskutil ar delete vbox
Started RAID operation on disk10 vbox
Unmounting volume for RAID set 2134725A-668E-45C3-BBD6-AAD5FF4D1991
Destroying the RAID set 2134725A-668E-45C3-BBD6-AAD5FF4D1991
Finished RAID operation on disk10 vbox

How to create (enable) mirror raid (RAID1) on a volume without destroying the data:

[osx@mini Volumes]$ diskutil ar enable mirror /dev/disk2s2
Started RAID operation on disk2s2 vbox
Resizing disk
Unmounting disk
Adding a booter for the disk
Creating a RAID set
Bringing the RAID partition online
Waiting for the new RAID to spin up "B580C0B1-6EEA-4A43-879C-49119544B093"
Finished RAID operation on disk2s2 vbox
[osx@mini Volumes]$ diskutil ar list
AppleRAID sets (1 found)
===============================================================================
Name:                 vbox
Unique ID:            B580C0B1-6EEA-4A43-879C-49119544B093
Type:                 Mirror
Status:               Online
Size:                 512.0 GB (511999967232 Bytes)
Rebuild:              manual
Device Node:          disk10
-------------------------------------------------------------------------------
#  DevNode   UUID                                  Status     Size
-------------------------------------------------------------------------------
0  disk2s2   2F5FD0BB-D9CF-45B6-BEAC-DCAE2287F3F2  Online     511999967232
===============================================================================

How to add new partition to the mirror:

Data will be deleted on the new disk - will be untouched on the existing raid volume.

[osx@mini scripts]$ diskutil ar add member disk1s2 vbox
Started RAID operation on disk10 vbox
Unmounting disk
Adding a booter for the RAID partition disk1s2
Adding disk1s2 to the RAID Set
Finished RAID operation on disk10 vbox
[osx@mini scripts]$ diskutil ar list
AppleRAID sets (1 found)
===============================================================================
Name:                 vbox
Unique ID:            B580C0B1-6EEA-4A43-879C-49119544B093
Type:                 Mirror
Status:               Degraded
Size:                 512.0 GB (511999967232 Bytes)
Rebuild:              manual
Device Node:          disk10
-------------------------------------------------------------------------------
#  DevNode   UUID                                  Status     Size
-------------------------------------------------------------------------------
0  disk2s2   2F5FD0BB-D9CF-45B6-BEAC-DCAE2287F3F2  Online     511999967232
1  disk1s2   1C29B1E0-C4AE-49E3-826F-624480A3208A  0% (Rebuilding)511999967232
===============================================================================

As you can see above, the rebuilding is started. It will take a wile, depending on your disk speed and partition size. At the end, you should see this:

[osx@mini sonic]$ diskutil ar list
AppleRAID sets (1 found)
===============================================================================
Name:                 vbox
Unique ID:            B580C0B1-6EEA-4A43-879C-49119544B093
Type:                 Mirror
Status:               Online
Size:                 512.0 GB (511999967232 Bytes)
Rebuild:              manual
Device Node:          disk10
-------------------------------------------------------------------------------
#  DevNode   UUID                                  Status     Size
-------------------------------------------------------------------------------
0  disk2s2   2F5FD0BB-D9CF-45B6-BEAC-DCAE2287F3F2  Online     511999967232
1  disk1s2   1C29B1E0-C4AE-49E3-826F-624480A3208A  Online     511999967232
===============================================================================

How to repair a mirror raid (RAID1):

mini:~ root# diskutil ar list
AppleRAID sets (1 found)
===============================================================================
Name:                 vbox
Unique ID:            B580C0B1-6EEA-4A43-879C-49119544B093
Type:                 Mirror
Status:               Degraded
Size:                 512.0 GB (511999967232 Bytes)
Rebuild:              manual
Device Node:          disk3
-------------------------------------------------------------------------------
#  DevNode   UUID                                  Status     Size
-------------------------------------------------------------------------------
0  disk1s2   2F5FD0BB-D9CF-45B6-BEAC-DCAE2287F3F2  Failed     511999967232
1  disk2s2   1C29B1E0-C4AE-49E3-826F-624480A3208A  Online     511999967232
===============================================================================
mini:~ root# diskutil ar repairMirror vbox 2F5FD0BB-D9CF-45B6-BEAC-DCAE2287F3F2
Started RAID operation on disk3 vbox
Unmounting disk
Adding a booter for the RAID partition disk1s2
Adding disk1s2 to the RAID Set
Finished RAID operation on disk3 vbox

Note: Syncing data between mirror partitions can take a very long time.
Note: The mirror should now be repairing itself.  You can check its status using 'diskutil appleRAID list'.
mini:~ root# diskutil ar list
AppleRAID sets (1 found)
===============================================================================
Name:                 vbox
Unique ID:            B580C0B1-6EEA-4A43-879C-49119544B093
Type:                 Mirror
Status:               Degraded
Size:                 512.0 GB (511999967232 Bytes)
Rebuild:              manual
Device Node:          disk3
-------------------------------------------------------------------------------
#  DevNode   UUID                                  Status     Size
-------------------------------------------------------------------------------
0  disk1s2   A4D2C14C-89C8-4D22-82B2-FEF0F30AECBE  1% (Rebuilding)511999967232
1  disk2s2   1C29B1E0-C4AE-49E3-826F-624480A3208A  Online     511999967232
===============================================================================

How to enable the automatic rebuild on a raid partition:

In the example above, you can see the Rebuild is equal to manual. We want to be automatic.

mini:~ root# diskutil ar update AutoRebuild 1 vbox
The RAID has been successfully updated
mini:~ root# diskutil ar list
AppleRAID sets (1 found)
===============================================================================
Name:                 vbox
Unique ID:            B580C0B1-6EEA-4A43-879C-49119544B093
Type:                 Mirror
Status:               Online
Size:                 512.0 GB (511999967232 Bytes)
[color=green]Rebuild:              automatic[/color]
Device Node:          disk3
-------------------------------------------------------------------------------
#  DevNode   UUID                                  Status     Size
-------------------------------------------------------------------------------
0  disk1s2   A4D2C14C-89C8-4D22-82B2-FEF0F30AECBE  Online     511999967232
1  disk2s2   1C29B1E0-C4AE-49E3-826F-624480A3208A  Online     511999967232
===============================================================================

How to convert a raid volume into a HFS one (will destroy the data on it):

In the example below, Apple_RAID_Offline is to be destroyed and a new normal HFS+ partition will be created.
You want to do this if, for example, you removed a volume from an existing raid set and want to make it normal.
It is not an appleRaid trick but will stay here since an Apple Raid volume is involved.

[osx@mini ~]$ diskutil list disk6
/dev/disk6 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *3.0 TB     disk6
   1:                        EFI EFI                     209.7 MB   disk6s1
   2:                 Apple_RAID                         512.0 GB   disk6s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk6s3
   4:         Apple_RAID_Offline                         2.5 TB     disk6s4
   5:                 Apple_Boot Boot OS X               134.2 MB   disk6s5
   
[osx@mini ~]$ [color=green]diskutil eraseVolume JHFS+ pool-bkp disk6s4[/color]
Started erase on disk6s4
Unmounting disk
Erasing
Initialized /dev/rdisk6s4 as a 2 TB case-insensitive HFS Plus volume with a 196608k journal
Mounting disk
Finished erase on disk6s4 pool-bkp

[osx@mini ~]$ diskutil list disk6
/dev/disk6 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *3.0 TB     disk6
   1:                        EFI EFI                     209.7 MB   disk6s1
   2:                 Apple_RAID                         512.0 GB   disk6s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk6s3
   4:                  Apple_HFS pool-bkp                2.5 TB     disk6s4

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content

root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root