Tuesday, September 1, 2009

Software RAID 5 in Windows 7

A bit of Googling around reveals that MS has removed the old software RAID 5 feature from Windows 7, although it's still present in Server 2008. My experience with the stuff in Windows 2003 was that it was very reliable, but for some reason much slower than mdadm's implementation on identical hardware. I know there is some complexity around RAID 5 with write holes and potential data corruption, so I don't know if mdadm's implementation is better or just more dangerous. I certainly don't have battery backup for writing the data from cache to the disk in the event of a total power failure, and I hope mdadm doesn't think I do.

But if you are really desperate for software RAID 5 (or you happen to have an old mdadm array lying around, like me), there is one very free, very hacky solution that will let you run software RAID 5 in Windows 7: virtualize linux.

That's right: you can download the free VirtualBox, install linux, map your SATA drives, and then run mdadm just as if linux were running natively. In fact, I created the array with the machine booted into to linux, then switched to Windows and mounted the array with a virtual machine. Samba is probably the best tool for interacting with the ext3 fs from Windows.

Scrub throughput is only about 22MB/s with this setup on my 4x500GB array, but then speed probably wasn't your top concern if you really wanted software RAID 5.

For some reason the Virtualbox documentation is only available as PDF, so I can't link you to the section on mapping physical drives which unfortunately is not as easy as it is with the for-pay VMWare Workstation. Mdadm is pretty easy to use, so getting the physical drives mapped correctly is the hardest part of the process, and may involve painful things like forcing VirtualBox to run as administrator.


Update: Initially I planned for this to be a stop-gap solution while I looked for a different medium to migrate the array to, but I continue to be surprised by how well it works. With a network drive mapped to the Samba share I can even hibernate Windows while the VM is running and everything just picks up right where it left off on resume. Even media files that were playing from the array! The array still works fine from within a native linux boot as well.


Update 2: This post is ranking pretty highly in Google for "Raid 5 Windows 7" and a lot of you are undoubtedly looking for solutions. David wrote in to ask for clairification:

> So you installed VirtualBox (which I assume works like VMWare,
> roughly speaking), mounted all the SATA drives in Linux, used
> mdadm to create a RAID array. I understand that. But the next
> part you say you "switched to Windows and mounted the array
> with a virtual machine". What do you mean by this?

Yes, it is similar to VMWare Workstation.

To clarify: I originally created the mdadm array while running a linux operating system on the host. Later, I wanted to access the array while running Windows 7 as the host operating system.

The fact that I was using linux as the original host OS should be an incidental detail: I was merely trying to illustrate that the solution is not dependent on the host OS. You can switch between linux and Windows and still create, access, or destroy mdadm arrays based on physical devices from within either host OS.

So, you should be able to create an array just fine with Windows as the host OS once the drives are mapped correctly.

> Then you mention Samba -- did you share the drive via Samba in
> the Linux VM and then essentially use Windows' "Map Network
> Drive" to map the share?

Precisely.

> If there are any other specifics you think might be helpful,
> that would be fantastic as well.

VirtualBox doesn't offer a nice interface for setting up physical drives like VMWare does; you have to muck about with XML files and might need to run the VirtualBox process with elevated privileges. If you have a VMWare license I'd definitely try that first. But VirtualBox is free, so...

> Is there any way (VMWare or VirtualBox) to easily make the RAID
> array visible as an actual device in Windows?

Probably not unless Windows 7 has some native support for mounting devices over the network. I don't know of such features but they may exist. Samba is probably also not the ideal choice for a protocol in terms of performance, but it has the advantage that it's easy to setup and the mapped drive behaves almost like a regular drive in the windows explorer.

9 comments:

  1. I contemplated this route for awhile. Ended up with doing a better hybrid hard/fake RAID that has a built in XOR processor (RR2680).

    Anyhow, if you go your route, you're probably better off doing OpenSolaris with its ZFS filesystem. It does not have the write hole problems of RAID5 and supposdly more efficient and better data protected.

    --
    Lawrence

    ReplyDelete
  2. I'd love to get a setup with ZFS going, but OpenSolaris doesn't seem to run very well on any of my old hardware. I keep hoping eventually it will be ported into Linux...

    ReplyDelete
  3. Brandon, Thanks for this article. How exactly did you map the hard drives in VirtualBox? The problem I have is that Win7 won't allow me to assign a drive letter to the HDD because they are linux raid drives...
    --
    Alex

    ReplyDelete
  4. Unfortunately I don't recall exactly what I did and I'm not running Windows 7 anymore. Though I don't recall running into any problems assigning the drive letters, I used the Disk Management tool you can access from Computer -> Manage.

    Sorry I can't be of more help :(

    ReplyDelete
  5. ...MS has removed the old software RAID 5 feature from Windows 7...

    Mmm...
    WinXP had no software RAID-5 natively, but with some little hack (patch dmboot.sys, dmconfig.dll and dmadmin.exe) it works.
    Are you talking about this feature?
    And you said this way do not work on Win7 anymore?

    ReplyDelete
  6. This is a related and step-by-step approach for "getting the drives visible and accessible by virtual box" http://www.ubuntugeek.com/howto-access-ext3-partition-from-windows.html

    The point about "running virtualbox as administrator" was key for me - virtualbox complained that it couldn't access the drives otherwise.

    I should stress, I am still in the process of actually making this work - I too have a raid5 array made in a linux that I am attempting to re-assemble and use in a virtualbox linux under windows 7. So far, I am not able to get mdadm to reassemble the array - it complains about not finding superblock information. If I do get it working, I'll write my own blog (with blackjack! and hookers!) flagrantly stealing from the linked entry and this one!

    G

    ReplyDelete
  7. @anonymous, brandon re: assigning drive letters.

    You don't assign drive letters in windows. Windows itself doesn't mount these raid drives - only virtualbox will access them. The linked URL above details how to let you add the drives to the virtualbox server linux instance you made.

    An additional note, once you have made the drives visible to VirtualBox - the default IDE controller for new Virtualbox machines is the standard 4 port PIIX controller. Well, the boot drive, and the cdrom drive take two ports, so if your raid array is raid5 or higher (3+ disks) you will need to ADD another disk controller. May as well make it a SATA controller, then you add the RAID drives on to THAT controller using the virtualbox storage section of the machine configuration GUI.

    ReplyDelete
  8. Might be able to take a linux-software RAID and turn it into an iSCSI target. FreeNAS has this capability (low overhead), and Windows 7 has the ability to attach to iSCSI built-in.

    ReplyDelete
  9. @Anonymous Interesting idea. I didn't know FreeBSD supported linux software raid. Or was that a special addition for FreeNAS?

    ReplyDelete