RAID1 w/out a Reformat

Note: This article is replaced with http://krypted.com/mac-os-x/enabling-raid-mirrors-redux for Snow Leopard. Do not use these procedures for Snow Leopard or above as they are meant for 10.5 and below.

When you get an Xserve or one of the new Mac mini Leopard Server, it will come with the operating system on a single drive. In most cases, you’re likely gonna’ have a second drive in those devices. Most people are hopefully going to want to run a RAID1 on those drives. If so, many will simply choose to insert the disk, reboot and reinstall the operating system, using Disk Utility during the installation process to setup the RAID.

But you don’t have to. It’s three commands to convert a non-RAID volume into a RAID volume. Actually, it’s one command to do that, but keep readin’.

First up, find the lay of the land. Run diskutil with the list verb, which is going to show you all of the disks you have at your disposal along with their sizing, etc. For example:

diskutil list

In most cases you’re going to be booted to the volume you’re going to turn into a RAID and it’s likely to be disk0. Therefore, assuming that the volume is disk0 use the diskutil command with the enableRAID verb (which does basically what the name implies) and then list the type of RAID (in this case we’re going to use mirror as a stripe would require a complete rebuild) and then list the device (in our case again, this is disk0). So the complete second command, which will enable the RAID is as follows:

diskutil enableRAID mirror disk0

At this point you have a drive that wants to be a mirror but isn’t (without a second member). So to add the second drive (the beauty to our geek) go ahead and use the diskutil command with the repairMirror verb. Here, you will “repair” the mirror using the source (so-to-speak) followed by the destination (again, so-to-speak). Here we’re going to assume disk0 from earlier followed by disk1:

diskutil repairMirror disk0 disk1

Now wait. And wait and wait and wait. Then it will be done and you’ll be able to move on to other tasks. For example, if you have an Xserve you can move your journal to that SSD drive or resize a partition and use the free space for something else, effectively disassociating operating system from actual data sets. Overall, this is a huge time saver in some setup scenarios and can help to be able to spend more time on other important things, like workflow.

Finally, this can easily be scripted; however, when you do so keep in mind that the changes that you make programatically make a lot of assumptions and if you have servers that aren’t identical (or have existing data sets somewhere), that it can be more dangerous than simply typing the three commands in sequence (otherwise I’d of written a GUI app to do it a long time ago).

Note: I wasn’t sure where I initially learned how to do this since it was 5 years ago. My apologies for not initially looking up the reference and my hat off to Josh for teaching me how to do something that has saved me countless hours over the past few years:

http://www.afp548.com/article.php?story=20040827122302975

While I’m at it, thanks to everyone else. Sorry if I forget to acknowledge anyone in books, articles, etc. It is never intentional, I assure you.

  • http://ewhizz.net Charlie

    You need to update your commands to work with Snow Leopard.

    The commands are now (specifics below are for a factory Mac Mini Server)

    diskutil appleRAID enable mirror disk0s2

    diskutil appleRAID add mirror disk1s2 disk2
    (where disk1s2 is the other disk, and disk2 is your newly enabled raid disk)

    Doing it this way, using specific partitions rather than the entire disk, allows to keep the factory EFI diag partition on the disks too!

    Great article, by the way.

    Cheers,

    Charlie at ewhizz.net

  • http://krypted.com/mac-os-x/raid1-wout-a-reformat/ Phil Johnson

    I can’t wait to try this (got to buy a mini first!)

  • Mike Kingsley

    Can this actually be done while booted into the OS? I keep getting error -10000 could not unmount the disk while trying to do it within the OS

    • http://www.krypted.com admin

      Should be able to. Shouldn’t try to unmount. Is it throwing the error on enableraid or repairmirror?

  • Pingback: Enabling RAID Mirrors Redux | Krypted()

  • theboyk

    Have you guys been successful on this when enabling RAID 1 on your boot drive? I’m able to enable RAID 1, but it renders the drive unbootable under 10.6.2? As soon as I delete the RAID, the drive it bootable again. I’ve read a number of reports on this not working on boot drives and so just wanted to see if anyone here’s had success under SL doing this on a boot drive?

  • http://krypted.com/mac-os-x/raid1-wout-a-reformat/ Phil Johnson

    It worked for me. I used SuperDuper to copy my default Snow Leopard Server boot disk, to an external firewire drive, then rebooted to that external drive. Then I opened Disk Utility and selected Raid1 mode. It has been running great now on my refurbished Mini since mid February…

  • Pingback: OSX server 10.5 software raid()

  • PFudd

    I don’t know why, but instructions for 10.5.8 are:
    diskutil list
    diskutil enableRAID mirror disk0s2 (the source)
    diskutil addToRAID member disk1s2 /Volumes/raid-name
    diskutil listRAID (repeat as desired, until 100% finished)

    I had to boot from an external drive to make this happen.