Guide: Dual-boot RAID Windows and Linux system

PV5150

New member
Disclaimer: As with any guide you see here at Overclock3d Forum, we encourage you to try them. But beware, any damage resulting from following the information included here, is solely your responsibility. OC3D Forum shall not be held accountable for any damage to hardware, nor shall it be held responsible in the event of a non-bootable system.

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.

Drive-1.gif
Drive 1



Drive-2.gif
Drive 2

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

Windows

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:D )

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.

Linux

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


#Note: 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



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:

md=0,04,0,/dev/sda2,/dev/sdb2

root=/dev/md0


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. :yumyum:

Big thanks goes to:

Slashdot and A. Mills for their assistance and knowledge
 
Just what I've been looking for :yumyum:

I assume a similar procedure would work to establish the following configuration?:

Drive 1: 2 partitions, both with Win XP Pro

Drive 2: 2 partitions, one with Linux and another non-OS NTFS for file storage

I'm going to attempt to set up such a configuration at some point in the future, I'm too busy with school atm. I'll read up on it and probably be back with questions :rolleyes:
 
zomg I've been struggling all day trying to install the new ubuntu on my fakeraid setup, in fact I was about to post up asking for help until i stumbled on this! EXACTLY WHAT IM AFTER :cool:

kudos to you sir

edit: one thing...you mention a diagram, i cant see any :(
 
I've been trying to install linux on my 82801ER SATA RAID array alongside XP on two seperate partitions, although I'm not having any luck. Is it not possible to just get a linux driver for the fakeraid controller just like how windows requires one (F6 during install)?
 
So you're combining 2drivers together, then splitting them into 2?

Nothig wrong with that just find it funny :p
 
Very nice guide, but would this work for a RAID 1 (mirror) settup?

I would be going for a /swap /system and /home (linux) partitions and c: and d: partions (windows) and be using 2 SATA disks, any clues?

cheers,
 
Don't work :(

Hi,

thats exactly what I need!.

One question: exactly, where do you install LILO?

BIOS would try to boot from first disk, where LILO isn't installed and windows is.

Should I install LILO in first disk MBR?
 
Following this guide on Fedora

Hi,

Great guide, thanks. I've followed this using Windows 2003 and Fedora 10. The setup I'm after is a single, simple, non-RAID OS disk, with a triple disk array for my data, that is also split in half. Each of the media disks is 640GB so I converted them to Dynamic Disks and split each disk with a 320GB Windows RAID-5 array and left three 320GB partitions ready for Linux.

Everything went fine until it comes to installing Linux. Then the Fedora installer cannot see partitions on the array disks, only an unknown partition type spanning the whole disk.

From what you say, it sounds like my kernel doesnt support LDM, but you also said that all Red Hat kernels work natively this and that was in 2006... How do I go about finding explicitly if my kernel does or not?

This behaviour is the same on the standard Fedora install DVDs, both 32-bit and 64-bit, and it also occurs with the LiveCD.

Any help will be gratefully received, thanks.

Jonathan
 
Back
Top