Use Terminal to Create and Manage a RAID 0 (Striped) Array in OS X

of 04

Use Terminal to Create and Manage a RAID 0 (Striped) Array in OS X

External 5 Tray RAID enclosure
External 5 tray RAID enclosure. Roderick Chen | Getty Images

Feel the need for speed? Since its early days, OS X has supported multiple RAID types using appleRAID, software that Apple created. appleRAID is actually part of diskutil, the command line tool used for formatting, partitioning, and repairing storage devices on a Mac.

Up until OS X El Capitan, RAID support was built into the Disk Utility app, which allowed you to create and manage your RAID arrays using a standard Mac app that was easy to use. For some reason, Apple dropped the RAID support in the El Capitan version of the Disk Utility app but kept appleRAID available for those willing to use Terminal and the command line.

Where Did the RAID Utility Go?

I hope the removal of RAID support from Disk Utility was just an oversight, likely caused by time constraints in the development process. But I don’t really expect to see RAID return to Disk Utility anytime soon.

So, with that in mind, I’m going to show you how to create new RAID arrays, and how to manage both the RAID arrays you create and pre-existing ones from early versions of OS X.

appleRAID supports striped (RAID 0), mirrored (RAID 1), and concatenated (spanning) types of RAID. You can also create nested RAID arrays by combining the basic types to create new ones, such as RAID 0+1 and RAID 10.

This guide will provide you with the basics of creating and managing a striped RAID array (RAID 0).

What You Need to Create a RAID 0 Array

Two or more drives that can be dedicated as slices in your striped RAID array.

A current backup; the process of creating a RAID 0 array will erase all of the data on the drives used.

About 10 minutes of your time.

of 04

Using diskutil list Command to Create a Striped RAID for Your Mac

diskutil list Terminal command
screen shot courtesy of Coyote Moon, Inc.

Using Terminal to create a RAID 0 array, also known as a striped array, is an easy process that can be performed by any Mac user. No special skills are necessary, although you may find the Terminal app a bit strange if you've never used it before.

Before We Begin

We're going to create a striped RAID array to increase the speed at which data can be written to and read from a storage device. Striped arrays provide a speed increase, but they also increase the possibility of failure. A failure of any single drive that makes up a striped array will cause the entire RAID array to fail. There's no magical method to recover data from a failed striped array, which means you should have a very good backup system that you can use to restore data, should a failure of the RAID array occur.

Getting Ready

In this example, we're going to use two disks as slices of the RAID 0 array. Slices are just the nomenclature used to describe the individual volumes that make up the elements of any RAID array.

You could use more than two disks; adding more disks will increase performance as long as the interface between the drives and your Mac can support the additional speed. But our example is for a basic minimum setup of two slices to make up the array.

What Type of Drives Can Be Used?

Just about any drive type can be used; hard drives, SSDs, even USB flash drives. Although not a strict requirement of RAID 0, it's a good idea for the drives to be identical, both in size and model.

Back Up Your Data First

Remember, the process of creating the striped array will erase all data on the drives that will be used. Make sure you have a current backup before you begin.

Creating the Striped RAID Array

It's possible to use a partition from a drive that has been divided into multiple volumes. But while it's possible, it's not recommended. It's better to dedicate an entire drive to be a slice in your RAID array, and that's the approach we'll take in this guide.

If the drives you're planning to use haven't yet been formatted as a single volume using OS X Extended (Journaled) as the file system, please use one of the following guides:

Format a Mac's Drive Using Disk Utility (OS X El Capitan or later)

Format a Mac's Drive Using Disk Utility (OS X Yosemite or earlier)

Once the drives are properly formatted, it’s time to combine them into your RAID array.

  1. Launch Terminal, located at /Applications/Utilities/.
  2. Enter the following command at the prompt in Terminal. You can copy/paste the command to make the process a bit easier:
    diskutil list
  3. This will cause Terminal to display all of the drives connected to your Mac, along with the drive identifiers we'll need when creating the RAID array. Your drives will be displayed by the file entry point, usually /dev/disk0 or /dev/disk1. Each drive will have its individual partitions displayed, along with the size of the partition and the identifier (the name).

The identifier will likely not be the same as the name you used when you formatted your drives. As an example, I formatted two drives, giving them the name Slice1 and Slice2. In the image above, you can see that Slice1’s identifier is disk2s2, and Slice2's is disk3s2. It's the identifier that we'll use on the next page to actually create the RAID 0 array. 

of 04

Create a Striped RAID Array in OS X Using Terminal

diskutil command to create RAID
Screen shot courtesy of Coyote Moon, Inc.

So far, we've gone over what you need to create a RAID 0 array using Terminal, and used the diskutil list command to get a list of the attached drives connected to your Mac. We then used that list to find the identifier names associated with the drives we intend to use in our striped RAID. If you need to, you can return to page 1 or page 2 of this guide to catch up.

If you’re ready to create the striped RAID array, let's get started.

Terminal Command to Create a Striped RAID Array for a Mac

  1. Terminal should still be open; if not, launch the Terminal app located at /Applications/Utilities/.
  2. On page 2, we learned that the identifiers for the drives we want to use are disk2s2 and disk3s2. Your identifiers may be different, so be sure to replace our example identifiers in the command below with the correct ones for your Mac.
  3. Warning: The process of creating the RAID 0 array will erase any and all content currently on the drives that will make up the array. Be sure that you have a current backup of the data if needed.
  4. The command we're going to use is in the following format:
    Diskutil appleRAID create stripe NameofStripedArray Fileformat DiskIdentifiers
  5. NameofStripedArray is the name of the array that will be shown when mounted on your Mac's desktop.
  6. FileFormat is the format that will be used when the striped array is created. For Mac users, this will likely be hfs+.
  7. DiskIdentifers is the identifier names we discovered on page 2 using the diskutil list command.
  8. Enter the following command at the Terminal prompt. Be sure to change the drive identifiers to match your specific situation, as well as the name you wish to use for the RAID array. The command below can be copy/pasted into Terminal. An easy method for doing this is to triple-click on one of the words in the command; this will cause the entire command text to be selected. You can then copy/paste the command into Terminal:
    Diskutil appleRAID create stripe FastFred HFS+ disk2s2 disk3s2
  9. Terminal will display the process of building the array. After a short time, the new RAID array will mount on your desktop and Terminal will display the following text: “Finished RAID operation.”

You're all set to start using your speedy new striped RAID.

of 04

Delete a Striped RAID Array Using Terminal in OS X

diskutil command to delete RAID
Screen shot courtesy of Coyote Moon, Inc.

Now that you have created a striped RAID array for your Mac, at some point you're probably going to find a need to delete it. Once again the Terminal app combined with the diskutil command line tool can let you delete the RAID 0 array and return each RAID slice for use as individual volumes on your Mac.

Deleting a RAID 0 Array Using Terminal

Warning: Deleting your striped array will cause all date on the RAID to be erased. Make sure you have a backup before proceeding.

  1. Launch the Terminal app located at /Applications/Utilities/.
  2. The RAID delete command only requires the RAID name, which is the same as the name of the array when it is mounted on your Mac’s desktop. As such there is no reason to use the diskutil list command as we did on page 2 of this guide.
  3. Our example for creating a RAID 0 array resulted in a RAID array named FastFred, were going to use this same example for deleting the array.
  4. At the Terminal prompt enter the following, be sure and replace FastFred with the name of your striped RAID that you wish to delete. You can triple-click one of the words in the command to select the entire command line, then copy/paste the command into Terminal:
    Diskutil AppleRAID delete FastFred
  5. The results of the delete command will be to unmount the RAID 0 array, take the RAID offline, break the RAID into its individual elements. What does not happen is also important the individual drives that made up the array are not remounted or properly formatted.

You can use Disk Utility to reformat the drives so they are once again usable on your Mac.