Dual Boot RAID Windows and Linux Page: 1
Wouldn't it be great if we had one OS to rule them all, but what Windows lacks, Linux has in abundance and vice versa. If you feel the need to install and use both operating systems, don't worry, you're not alone. But anyone can dual boot...so today I'm going to show you how to setup a dual-boot RAID Windows and Linux system. Both operating systems, both RAIDed, on a single machine without hours of endless hair pulling (hopefully). I bet you're wondering what the problem is in this day and age with onboard RAID controllers. Well, for a start they're not real RAID controllers. Unlike dedicated hardware RAID cards, all onboard motherboard RAID impllementations are affectionately known as 'fakeraid' because they're not hardware at all. The actual RAID processing is still done via your CPU through drivers. This means between the OS software RAID and the fakeraid controller, there's not a lot of difference, with these exceptions: software RAID is more flexible, portable and easier to install with operating systems than fakeraid. It's flexible because you can RAID just the partitions that you want, portable because you can move the drives to another system and they're readable (compared to fakeraid controllers which require you to use the same controller family) and easier to install because you don't need some fiddly F6 install floppy driver for Windows or the extreme hassle of trying to get fakeraid controllers working through a Linux install. Software RAID, under both operating systems, is the shiz. Plus anyone can do it with just standard controllers. So that's what we're gonna use!!!

Preparation is the key
Naturally, start by planning the partition layout you want to use. For the purposes of this guide, we'll use a layout that looks like the one in the diagram below. This layout assumes two drives to be setup as RAID 0 in each OS. I'm using software RAID, so naturally this requires the OS to be installed first, at least for Windows - oddly, the Microsoft Windows installer is unable to read its own dynamic disks that are used for software RAID, so you can't create them first and then install onto them. As a result the Windows boot drive needs to be installed on its own partition. Linux has no such problem... In the diagram included below, treat the first partition of the first drive just the way Windows likes it - as a C: boot drive. This is also where the NT boot manager will naturally go. You can however point the Windows core and/or the 'program files' directory to another drive. This certainly helps in putting all your apps and games on the RAIDed partition, but not Windows itself (because the installer can't see the RAID). The first partitions counterpart on the second drive is a great place to put your /boot directory, your /home, or anything else for which you don't want to risk to the redundancies (or lack thereof) of RAID 0. These directories don't, after all, really benefit from RAID anyway and it means that you can happily re-install your Linux desktop without wiping your /home.

Linux md RAIDs Drive 1 Drive 1

Linux md RAIDs Drive 2 Drive 2

......................Linux md RAIDs...................

1. Assuming a blank drive, boot your Windows install disk (or your own slipstreamed install version) and at the partitioning stage create a single partition where you'll install Windows.

2. Do the deed and install Windows. After you reboot into your fresh desktop click Start -> Run and type in 'diskmgmt.msc' Now use the Windows disk management interface to setup all the remaining partitions you need, as per the layout of your system, including where you'll be installing Linux. There is a reason for this: namely, Linux fdisks can't see or use Windows Dynamic Disks. What's a Dynamic Disk I hear you ask? Well you're about to make one!!!

3. You'll note that while all the drives are listed as 'Basic' you won't find any software RAID options for setting up your Windows software RAID drive. To access this, right click on the drive icon in the panel and select 'Convert to Dynamic Disk'. Dynamic Disks are Windows way of doing nifty things like JBOD and RAID. Unfortunately, it requires modifying the partition table to do so, and into a format only Windows understands (but not the Windows installer...sweet )

4. You'll see the drives change colour, but the partition structure remains the same. Right click on the partitions you set aside for Windows and delete them.

5. Right click on either one of the empty space partitions you want in the RAID and select to create a 'striped' partition.

6. Select the other partition from the list, click 'Add' and create your software RAID 0 array

7. Format it in NTFS as you would any other partition.

Now let's move on to getting Linux set up...

Dual Boot RAID Windows and Linux Page: 2
Reboot with your favourite distro install disk in the CD drive. For this to work you'll need a distro with the kernel on the install CD that supports two features: MD and LDM. The first, MD is the multiple disk driver - your software RAID support. It handles everything from RAID 0 to RAID 6 and JBOD. The other allows Linux to read and work with LDM, or Logical Disk Manager (aka Dynamic Disk) partitions. Without the LDM driver, ther kernel only sees a generic unified partition which Windows uses as its 'Dynamic Disk' format. Thankfully the LDM driver for Linux exists, or this guide wouldn't be possible.

#Note: Generally, MD and LDM are so common any modern distro should have them built into their kernels. If you prefer to build your own kernel on an install disk, you'll find LDM under Filesystems-> Partition types (then select 'Advanced Partition Selection' and Windows Logical Disk Manager') and the MD driver under Drivers-> Multi-disk driver.

1. At the partition stage you should be able to see and manipulate the same partitions you made in Windows. All you want to do here is create the Linux software RAID 0 array and install Linux onto it, with the exception of /boot. You may need to modprobe the MD driver if your distro doesn't load it. The LDM driver is a compile-in only affair.

2. If you're doing things the manual way (such as with Gentoo) you'll need to make sure the tools from either the 'raidtools' or 'mdadm' packages are available on the install disk. You can assemble your RAID 0 array with mdadm like so:

mdadm --create/dev/md0/devsda2
/dev/sdb2 -n 2 -1 0 -c 64

Distributions that have no problem loading and using both MD and LDM include Red Hat, SuSE, Mandriva, and Gentoo. The first three even include install features to setup RAID arrays from partitions for you. Neat eh!!!

3. Allocate the partitions as per the layout you want, and install Linux. Going by the diagram I had included previously, this means allocating /dev/sda2 and /dev/sdb2 to md0, /dev/sda3 and /dev/sdb3 to md1, and installing / to md0 and allocating your swap to md1.

#Note: You can also use other methods of building drives into spanned file systems with evms, device mapper, and the like but as you'll see sticking with straight MD keeps it simple and, as I'll cover below, cross platform.

The Boot Loader
So far, it's been relatively simple. It's just a standard dual boot install making use of software RAID under each OS, and it's been made possible by the kernel's support of LDM. Which if you think about it presents us with a bit of a chicken and egg problem: In order to see LDM partitions, the kernel needs to load. But in order to load the kernel...the partitions need to be visible. No problerm!!! Well, actually it is a little. There are two ways to handle this.

A) The first is to install your /boot and boot manager to a third hard drive. Even if it's just a simple data drive, there's nothing stopping you making this your bootable drive in the system, loading a Linux boot manager, and booting Linux or Windows accordingly. It's certainly a safe and simple option. Alternatively, this boot device could be a USB key.

B) The other option is to install LILO onto the second drive (so as to not overwrite the Windows NT boot manager, which you need). LILO can handle LDM partitions, whereas Grub cannot, so it's your only choice here. Your distro, if it's got a nice installer, will offer to install LILO for you and will even find and add to the boot menu your Windows boot. Just because you're running different OS's, and different software RAID arrays no less, doesn't mean the two can't play together. You'd think that the chances of Windows being able to read a Linux software RAID array are next to nil. And you'd be right. You'd also think that, naturally, Linux wouldn't be able to read that lovely NTFS Windows software RAID array from Windows. But in actual fact it can. To be more precise, the MD driver can, with no more configuration than you've already done to setup a Linux software RAID array. The easiest way to do this on a permanent basis where you can mount and unmount the Windows RAID as you desire is to set it up as an entry in your /etc/raidtab, like so:

raiddev /dev/md2
raid-level 0
chunk-size 64k
persitent-superblock 0
nr-raid-disks 2
device /dev/sda4
raid-disk 0
device /dev/sdb4
raid-disk 1

The two most important settings to specify here are 0 for the persistent superblock (because of course NTFS partitions don't), and to use a chunk size of 64KB. And of course, you need the NTFS file system module installed or loadable. After that, accessing the Windows RAID is as simple as running:

raid0run /dev/md2
mount -t ntfs /dev/md2 /mnt/windows

Or whatever directory you want to mount it to. The raid0run command is part of the 'raidtools' package. You could probably use mdadm to force it to run, but raid0run will do as it says without playing with switched. The raid0run command forces the assembly of a RAID device, irrespective of whether the partitions sport a valid superblock or not. You can unmount it anytime with:

unmount /mnt/windows
raidstop /dev/md2

If MD complains that there aren't enough MD devices present in /dev, you can make another like so ( the example being here md2):

mknod 2 b 9 2

Now that we've installed Windows and Linux and organised the boot loader, let's get onto booting up...

Dual Boot RAID Windows and Linux Page: 3
Booting Up
Your dual-boot dual-RAID system is almost complete. Similar to the boot issue, the loading of the MD driver to assemble RAID arrays is also a bit of a chicken and egg.. How can you boot your root partition off the RAID array if the configuration for arrays is stored in the /etc/raidtab or /etc/mdadm.conf files? No problem! The MD driver is capable of assembling arrays on the fly. Add the following to your kernel statement in the boot loader:


The first value is the MD array number, the second is the RAID level, the third a logarithmic base 2 value offset by 12 (yeah easy lol) representing the chunk size, and the fourth is merely a compatability value. The last two, of course, are the array constituents. Now, RAID partitions sport a spiffy 'RAID autodetect' flag ('fd') on the partition so MD can detect and build arrays on the fly...but!!! It depends on how your array was originally built with a persitent superblock or not. And keep in mind that Linux fdisks can't read LMD partitions (because it needs to access disks directly), and so can't set this flag for you. All fdisk sees are the Windows LDM container partitions. Regardless, you don't need to rely on this when you can specify the array components at the command line and always ensure that the right partitions are constructed accordingly. Well, that's pretty much it. You can boot Windows through the boot menu (if your installer didn't do this for you, great for adding an NT boot loader to it) and of course linux. Windows will boot off a single drive, but Program Files and everything else (such as games) can be installed to the RAID partition (D: drive). Linux has its kernel stored/loaded on a single drive in /boot, but loads the root from /dev/md0.

Additional Information on chunk or stripe
Usually RAID 0 devices are referenced by the size of the information that's literally 'striped' across the drives in your array. Most onboard RAID controllers and Windows refer to this block of information as the stripe size. The default stripe size for a software RAID array under Windows is 128KB. Linux does things a little differently. In Linux, MD devices are configured with a chunk size. This isn't merely another name for the same thing. For the MD driver, data is striped across drives in chunk size, so for example a 64KB over two drives under Linux is the equivalent of a two-drive 128KB stripe array under Windows. Which is why you use the 64KB setting to mount your 128KB stripe NTFS RAID 0 array. If you don't mind playing with your data this can actually be seen by running and mounting your Windows software RAID 0 array with a chunk size near but not exact to the default - for example, using a 32KB or 128KB chunk size. Some parts of the directory structure will be perfectly visible (and accessible), while others will generate read errors (namely, those files that would be striped). It's a fun insight into RAID. Well, welcome to dual-boot, RAID 0 goodness. It's a little fiddly the first time, but once you're aware of LDM and confident to specify your arrays at the command line, it's pretty simple.
Lemme know what speed your getting from Sandra and hdparm.

Big thanks goes out to Slashdot and A. Mills for their assistance and knowledge.