# Can't install boot loader using Raid 0 on VT8237 [Solved]

## daBron

My goal has been to get my system set up as dual boot (XP/Gentoo) using my BIOS's RAID 0. I've been working on getting it all setup for a couple of weeks now. And after much googling, reading through forums, and a lot of trial and error, I have my system running with both Gentoo and XP installed. The only thing holding me back right now is that I'm not able to install a boot loader!

My Setup:

Asus A7V600 (Latest BIOS #1008)

2 x Raptor 36G SATA

RAID 0 on Via VT8237

Windows XP Pro / Gentoo 2004.3

I first installed XP and created all my partitions at that time. Then I used the Gentoo LiveCD to change the partition types to Linux (85/83/82).

Here are my partitions:

/dev/mapper/rd1 -> /mnt/xp (40G)

/dev/mapper/rd5 -> /boot (100M)

/dev/mapper/rd6 -> swap (2G)

/dev/mapper/rd7 -> / (30G)

```
# modprobe dm-mod

# blockdev --getsize /dev/sda

72303840

# echo "0 144607680 striped 2 64 /dev/sda 0 /dev/sdb 0" | dmsetup create rd

# sfdisk -l -uS -q /dev/mapper/rd

Disk /dev/mapper/rd: cannot get geometry

Disk /dev/mapper/rd: 0 cylinders, 0 heads, 0 sectors/track

Warning: The partition table looks like it was made

  for C/H/S=*/255/63 (instead of 0/0/0).

For this listing I'll assume that geometry.

Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System

/dev/mapper/rd1   *        63  83891429   83891367   7  HPFS/NTFS

/dev/mapper/rd2      83891430 144584999   60693570  85  Linux extended

/dev/mapper/rd3             0         -          0   0  Empty

/dev/mapper/rd4             0         -          0   0  Empty

/dev/mapper/rd5   *  83891493  84100274     208782  83  Linux

/dev/mapper/rd6      84100338  88293239    4192902  82  Linux swap

/dev/mapper/rd7      88293303 144584999   56291697  83  Linux

# echo "0 83891367 linear /dev/mapper/rd 63" | dmsetup create rd1

# echo "0 208782 linear /dev/mapper/rd 83891493" | dmsetup create rd5

# echo "0 4192902 linear /dev/mapper/rd 84100338" | dmsetup create rd6

# echo "0 56291697 linear /dev/mapper/rd 88293303" | dmsetup create rd7

```

Now after mounting and chrooting:

```
# cat /etc/fstab

# <fs>                  <mountpoint>    <type>          <opts>                  <dump/pass>

/dev/mapper/rd1         /mnt/xp         ntfs            defaults                0 0

/dev/mapper/rd5         /boot           reiserfs        noatime,notail          1 2

/dev/mapper/rd6         none            swap            sw                      0 0

/dev/mapper/rd7         /               reiserfs        noatime,notail          0 1

/dev/hda                /mnt/dvd        auto            noauto,user,ro          0 0

/dev/hdc                /mnt/cd         auto            noauto,user             0 0

/dev/fd0                /mnt/floppy     auto            noauto,user             0 0

none                    /proc           proc            defaults                0 0

none                    /dev/shm        tmpfs           nodev,nosuid,noexec     0 0

none                    /proc/bus/usb   usbfs           defaults                0 0

# cat /boot/grub/grub.conf

default 0

timeout 15

title=Gentoo Linux 2.6.9-r13

root (hd0,4)

kernel /kernel-2.6.9-gentoo-r13 root=/dev/mapper/rd7

title=Windows XP

rootnoverify (hd0,0)

makeactive

chainloader +1

# cat /etc/lilo.conf

lba32

boot=/dev/mapper/rd

#disk=/dev/mapper/rd bios=0x80

prompt

timeout=150

delay=50

default=Gentoo

image=/boot/kernel-2.6.9-gentoo-r13

        root=/dev/mapper/rd7

        label=Gentoo

        read-only

other=/dev/mapper/rd1

        label=Windows

```

The Problem w/ GRUB:

```
# grub

grub> root (hd0,4)

Error 18: Selected cylinder exceeds maximum supported by BIOS

```

Is this a GRUB issue, or does my BIOS really only support having a boot partition within the first 8G? I thought this was only an issue on older motherboards.

And just to make sure GRUB detected my (hd0) correctly:

```
grub> root (hd0,0)

Filesystem type unknown, partition type 0x7

```

The Problem w/ LILO

```
# lilo

Fatal: Sorry, don't know how to handle device 0xfe00
```

I would prefer to use GRUB if possible, but any help getting either to work would be great. I know there are already tons of other post on getting RAID to work, but I hadn't been able to find the answer to these issues. Thank you in advance!

----------

## NeddySeagoon

daBron,

Grub on RAID 0 is a non starter and with BIOS software RAID, so you can dual boot. its extra pain. I looked into it then decided I didn't need dual boot so I didn't need BIOS software RAID either.

A grub boot is three stages. The stage 1 is loaded from the the MBR and fetches and runs the stage 1.5 using BIOS calls. This lives on disc just following the MBR and before the first partition starts.

This runs and knows how to read the filesystem to find stage 2 but it has no idea about RAID, so it fall in a heap here. It cannot use the kernel as its not yet loaded. Scratch Grub.

Lilo plants block lists for the things it loads and depends much more on the BIOS, which is why you need to rerun lilo when you change its config or add things to /boot. The block lists must be updated.

This would work but ...

The kernel cannot mount the root partttion becase the block driver for the BIOS RAID is not in the kerenel. Therfore you have to make an initrd so the kernel can load the modules to read the root partition.

There is more here  http://www.infowares.com/linux/

----------

## AnonNomis

DaBron,

   I've been trying to do the same thing on a Asus A8V using the promise controller.  I have pretty much the exact same setup with Windows XP on the first partition in the raid 0 array and Gentoo installed on logical partitions on the rest of the array.  My set up is pretty much the same as yours because I used your post as a guide.  Thanks for helping get this far.   Now I'm stuck exactly where you were.  I've been trying to set up a ramdisk as suggested but am not having any success.  I was wondering if you got this to work.   I set up an initrd file to be loaded from grub or lilo but I still cannot install either because my chooted environment doesn't see /dev/mapper/rd5 (the /boot partition that was originally created) and the original environment from the livecd doesn't have /sbin/lilo or grub.  How did you get around this?

----------

## daBron

After finding this page in google: https://www.redhat.com/archives/dm-devel/2003-November/msg00007.html, I decided to manually tell LILO about the hardware geometry.

```
disk=/dev/mapper/rd  bios=0x80 sectors=63 heads=255 cylinders=9000

disk=/dev/mapper/rd1 bios=0x80 sectors=63 heads=255 cylinders=5221

disk=/dev/mapper/rd5 bios=0x80 sectors=63 heads=255 cylinders=12

```

After doing this I was able to get LILO to install. But unfotunately when I rebooted, I just got "L 99 99 99 99 ...". After trying several other things I found that LILO has a devmap USE flag. I recompiled it and tried rerunning lilo, only to get a message saying that only "linear" mappings were supported. But I did find that the LILO patch on http://tienstra4.flatnet.tudelft.nl/~gerte/gen2dmraid/ seems to support other mappings. So after applying the patch I was able to get LILO to install and load the kernel. But the kernel is still not able to mount the root partition, so I am working on hacking together an initrd and linuxrc that will work without depending on dmraid. If I get this all working I will post my conf files and exact steps.

And AnonNomis, in regards to your question about accessing LILO/GRUB after booting from the LiveCD. I have to recreate my rd devices each time, mount them and then chroot. It is quite a pain to type it in each time so I usually get my sshd running and then from my wife's computer I log in and copy and paste all the commands to get to the point where I can try to reconfigure LILO once again.

And in order to get my chrooted environment to see the rd devices I just copied them and it seemed to work.

```
# cp -R /dev/mapper /mnt/gentoo/dev
```

----------

## daBron

Success!!!

After weeks of searching and failed attempts, I finally can dual boot Gentoo/WinXP on my Bios Raid 0 VT8237!

Hopefully I can remember everything I had to do in order to get things working. If something I say doesn't work, let me know, I probably ran into the same issue and just forgot to write that step.

Here goes:

1. Patch LILO:

```
# wget http://tienstra4.flatnet.tudelft.nl/~gerte/gen2dmraid/lilo-22.6-dmraid.patch

# cp /usr/portage/sys-boot/lilo/files/lilo-22.6.1-devmapper_gentoo.patch{,.backup}

# mv lilo-22.6-dmraid.patch /usr/portage/sys-boot/lilo/files/lilo-22.6.1-devmapper_gentoo.patch

# emerge lilo
```

Make sure you add devmap to your USE flags.

2. Configure linuxrc:

```
# wget http://tienstra4.flatnet.tudelft.nl/~gerte/gen2dmraid/linuxrc-0.93

# cp linuxrc{-0.93,}

# vi linuxrc
```

Replace

```
if (/sbin/dmraid -ay)

then

     echo -e "${GOOD}>>${NORMAL} dmraid was run successfully"

else

     echo -e "${BAD}>>${NORMAL} dmraid failed"

     #What to do now? I don't care, we'll deal with this problem later.

fi
```

with

```
echo "0 144607680 striped 2 64 /dev/sda 0 /dev/sdb 0" | dmsetup create rd

echo "0 83891367 linear /dev/mapper/rd 63" | dmsetup create rd1

echo "0 208782 linear /dev/mapper/rd 83891493" | dmsetup create rd5

echo "0 4192902 linear /dev/mapper/rd 84100338" | dmsetup create rd6

echo "0 56291697 linear /dev/mapper/rd 88293303" | dmsetup create rd7
```

Obviously customize partitions & sectors to match your need.

3. Configure mkinitrd:

```
# wget http://tienstra4.flatnet.tudelft.nl/~gerte/gen2dmraid/dmraidinitrd-0.93

# cp dmraidinitrd-0.93 mkinitrd

# vi mkinitrd
```

Add

```
cp $TMPDIR/opt/device-mapper/sbin/dmsetup.static ${TMPDIR}/tmp/sbin/dmsetup || die 'Fatal error: did dmsetup fail to compile?'

```

directly after

```
cp $TMPDIR/${DMRAID_DIR}/tools/dmraid ${TMPDIR}/tmp/sbin || die 'Fatal error: did dmraid fail to compile?'
```

(optional) 

I also commented out all the dmraid lines, since I wasn't using it.

```
#DMRAID_URI_PREFIX="http://people.redhat.com/~heinzm/sw/dmraid/src/"

#DMRAID_TARBALL="dmraid-1.0.0-rc5f.tar.bz2"

#DMRAID_DIR="dmraid/1.0.0-rc5f"

...

#fetch_dmraid() {

#     if [ ! -e ${DISTFILES_DIR}/${DMRAID_TARBALL} ]

#     then

#             ( cd ${DISTFILES_DIR}; wget ${DMRAID_URI_PREFIX}${DMRAID_TARBALL} )

#     fi

#}

...

#make_dmraid() {

#     echo 'Making dmraid...'

#     (cd $TMPDIR; \

#     tar -jxf ${DISTFILES_DIR}/${DMRAID_TARBALL}; \

#     cd ${DMRAID_DIR}; \

#     ./configure --enable-static_link >/dev/null 2>&1;\

#     if [ ${DEVICEMAPPER_INSTALLED} -eq 0 ]

#     then

#             make CC="cc -I ${TMPDIR}/opt/device-mapper/include -L ${TMPDIR}/opt/device-mapper/lib" >/dev/null 2>&1

#     else

#             make >/dev/null 2>&1

#     fi)

#}

...

#fetch_dmraid;

#make_dmraid;

...

#cp $TMPDIR/${DMRAID_DIR}/tools/dmraid ${TMPDIR}/tmp/sbin || die 'Fatal error: did dmraid fail to compile?'
```

4. Create initrd:

```
# chmod 700 mkinitrd

# ./mkinitrd linuxrc /boot/initrd
```

5. Configure & compile kernel:

```
Device Drivers  --->

 Block devices  --->

  <*> Loopback device support                                                                                 

   < >   Cryptoloop Support                                                                                    

  <*> RAM disk support                                  

  (16)  Default number of RAM disks                                                                           

  (4096) Default RAM disk size (kbytes)                                                         

  [*]   Initial RAM disk (initrd) support

 Multi-device support (RAID and LVM)  --->

  [*] Multiple devices driver support (RAID and LVM)   

  < >   RAID support                            

  <*>   Device mapper support                                           

   < >     Crypt target support                                        

   < >     Snapshot target (EXPERIMENTAL)                                                          

   < >     Mirror target (EXPERIMENTAL)                                                      

   < >     Zero target (EXPERIMENTAL)                                                    

   < >     Multipath target (EXPERIMENTAL)                                                          

   < >     Bad Block Relocation Device Target (EXPERIMENTAL)
```

6. Configure LILO:

```
# cat /etc/lilo.conf

lba32

boot=/dev/mapper/rd

prompt

timeout=50

default=Gentoo

image=/boot/kernel-2.6.10-gentoo-r4

        initrd=/boot/initrd

        root=/dev/ram0

        append="init=/linuxrc real_root=/dev/mapper/rd7 devfs"

        label=Gentoo

other=/dev/mapper/rd1

        label=Windows
```

7. Install LILO:

```
# lilo -v
```

8. Reboot:

```
# exit (because we're chrooted)

# reboot
```

Now it's time to gently fold your hands and say a little prayer.

References:

http://tienstra4.flatnet.tudelft.nl/~gerte/gen2dmraid/

https://forums.gentoo.org/viewtopic.php?t=244941&highlight

http://forums.viaarena.com/messageview.cfm?catid=28&threadid=55977&enterthread=y

----------

## irondog

Good job!

To make some things more clear about this subject I would like to add some information to this topic. 

about Lilo and Grub:

 *NeddySeagoon wrote:*   

> [...]
> 
> This runs and knows how to read the filesystem to find stage 2 but it has no idea about RAID, so it fall in a heap here.

 Grub and Lilo indeed don't know about the RAID. However, this is not the cause of the difficulty installing the bootloader. No bootloader should be aware of RAID! The booloader uses the bios and it's the bios task to represent the RAID as a normal disk. Runnig Linux 2.6 makes BIOS raid usage a little bit too far away from hardware and BIOS making it difficult to install a bootloader.

why?

The kernel (device mapper) isn't able to answer Lilo's requests of 'disk' geometry info and device numbering. Installing Lilo fails...

Grub on the other hand isn't able to understand that something represented by the device mapper can (in our case) be something bootable. Again the kernel (by design) is failing to provide information of device numbering when handling BIOS raid mappings.

 *daBron wrote:*   

> 
> 
> ```
> disk=/dev/mapper/rd  bios=0x80 sectors=63 heads=255 cylinders=9000
> 
> ...

 This was a very brave attempt, and I bet you were very close. But the syntax is different:

```

disk = /dev/mapper/rd

  bios = 0x80

  sectors = 63

  heads = 255

  cylinders = 9000

  partition = /dev/mapper/rd1

    start = 2048

  partition = /dev/mapper/rd2

    start = 204800

```

When using the version of the lilo-dmraid-patch, some of this information is fetched from the device mapper making the patch work for you without this information in /etc/lilo.conf

Never use the devmap patch in portage, it wil disable any chance on BIOS raid

To return to grub:

When you are able to explain grub /dev/mapper/${something} is (hdX,Y) for all devices grub has to know, grub will work for you. Grub reads all other geometry information from the partition table.

See:

http://tienhttp://tienstra4.flatnet.tudelft.nl/~gerte/gen2dmraid/

----------

## myrthas

 *daBron wrote:*   

> My goal has been to get my system set up as dual boot (XP/Gentoo) using my BIOS's RAID 0. I've been working on getting it all setup for a couple of weeks now. And after much googling, reading through forums, and a lot of trial and error, I have my system running with both Gentoo and XP installed. The only thing holding me back right now is that I'm not able to install a boot loader!
> 
> 

 

Hi, how did you actually get to install both Gentoo and XP? Can you let me know how you actually did that? I have similar hardware setup with you.  Thanks.

----------

## anderlin

I did it this way:

1. Install windows xp (64bit in my case) on the first partition. It would not let me install it on any other partition (I don't know why)

2. Make all the partitions from windows (I also made a little unused space at the end, because I read the metadata was placed there. I don't know if this is necessary)

3. Boot 2004.1 livecd (the only one that works for my hardware) (the cd gen2dmraid-99.iso would not let me chroot)

4. Use dmsetup and the guide on https://forums.gentoo.org/viewtopic.php?t=244941. Then copy with "cp -R /dev/mapper /mnt/gentoo/dev"

5. Format and mount partitions.

6. Continue ordinary installation.

7. Do something clever with the bootloader (I haven't figured it out. Since I use 64bit, grub is my only option)

----------

## anderlin

I now have grub loading windows, and the gentoo kernel. However the kernel panics:

```
Freeing unused kernel menory: 248k freed

Warning: unable to open an initial console.

Kernel panic - not syncing: No init found. Try passing init= option to the kernel.

```

What does this mean? I use udev and grub, both ~amd64.

FIXED: I made the initrd on a 32bit machine. I remade it on amd64, and after some messing around, it worked.

----------

## daBron

I used basically the same steps as anderlin described above:

1) First I created the raid array in the raid bios, which comes up right after the regular bios screen. For me I have to hit TAB to get into it. I set everything up as RAID 0 with 32K stripes.

2) I created all my partions using the WinXP install disk (had to insert a floppy w/ raid drivers and press F6) and then only formatted the first partition with NTFS and installed WinXP on it. It should be safe to use up the whole drive. Windows won't let you overwrite the metadata at the end of the drive, which is why we're using it to make our partitions in the first place.

When I'm in Windows I use TweakUI to hide the Linux partitions (D:,E:,F:) from Windows, so that I can't accidently format them.

3) Next I boot from the Gentoo LiveCD and use sfdisk to find the sector info for my partitions and away we go with what I've posted above.

anderlin, are you running BIOS RAID 0? If so, did you have to do anything special to get GRUB to install? I've gotten the patched version of LILO working, but still not GRUB.

----------

## anderlin

I am running BIOS raid 0. For details on how I did it, look here:

https://forums.gentoo.org/viewtopic.php?p=1996658#1996658

Please ask again if anything is unclear.

----------

## daBron

I was looking for differences between our setups, and I think that you were able to install GRUB just fine because you had /boot as your first partition. I looked at some more GRUB documention though and finally figured out how to tell it about my RAID's geometry.

```
# cat /boot/grub/grub.conf

timeout 5

default 0

title Gentoo Linux 2.6.10-r6

root(hd0,4)

kernel /kernel-2.6.10-gentoo-r6 root=/dev/ram0 real_root=/dev/mapper/rd7 init=/linuxrc devfs

initrd /initrd

title Windows XP

root(hd0,0)

rootnoverify

chainloader +1

# grub --device-map=/dev/null

grub> device (hd0) /dev/mapper/rd

grub> geometry (hd0) 9000 255 63

drive 0x80: C/H/S = 9000/255/63, The number of sectors = 144585000, /dev/mapper/rd

   Partition num: 0,  Filesystem type unknown, partition type 0x7

   Partition num: 4,  Filesystem type is reiserfs, partition type 0x83

   Partition num: 5,  Filesystem type unknown, partition type 0x82

   Partition num: 6,  Filesystem type is reiserfs, partition type 0x83

grub> root (hd0,4)

 Filesystem type is reiserfs, partition type 0x83

grub> setup (hd0)

 Checking if "/boot/grub/stage1" exists... yes

 Checking if "/boot/grub/stage2" exists... yes

 Checking if "/boot/grub/reiserfs_stage1_5" exists... yes

 Running "embed /boot/grub/reiserfs_stage1_5 (hd0)"...  26 sectors are embedded.

succeeded

 Running "install /boot/grub/stage1 (hd0) (hd0)1+26 p (hd0,4)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded

Done.

grub> quit

# reboot
```

Now that GRUB's working it looks like it's time to unmerge LILO!  :Smile: 

----------

## daBron

Actually I still haven't been able to get GRUB to boot into Windows. I was able to boot into Gentoo and figured GRUB was working just fine. When I choose Windows in GRUB I get: "Error 12: Invalid device". Any ideas?

If anyone has a simillar setup to mine, what does your grub.conf look like? In addition to my grub.conf from my previous post I've tried:

```
title Windows XP

rootnoverify(hd0,0)

makeactive

chainloader +1
```

----------

## jroo

I can't connect to http://tienstra4.flatnet.tudelft.nl/~gerte/gen2dmraid/lilo-22.6-dmraid.patch and get the patch. Could someone put that patch somewhere where I can grab it (I tried to google for that patch with no results other than the link posted here)

thanks

----------

