# Installing GRUB on raid ! HELP! [SOLVED]

## Dreadful

hi, i'm still trying to install grub on my raid 0 but useless ...

```

tmpfs on / type tmpfs (rw)

/dev/hdb on /mnt/cdrom type iso9660 (ro)

/dev/loop0 on /mnt/livecd type squashfs (ro)

proc on /proc type proc (rw,nosuid,nodev,noexec)

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)

udev on /dev type tmpfs (rw,nosuid)

devpts on /dev/pts type devpts (rw,nosuid,noexec)

tmpfs on /mnt/livecd/lib/firmware type tmpfs (rw)

tmpfs on /mnt/livecd/usr/portage type tmpfs (rw)

usbfs on /proc/bus/usb type usbfs (rw,nosuid,noexec)

/dev/mapper/pdc_hacjeb3 on / type ext3 (rw,data=ordered)

none on /proc type proc (rw)

udev on /dev type tmpfs (rw,nosuid)

/dev/mapper/pdc_hacjeb1 on /boot type ext2 (rw,noatime)

```

and i have /dev/dm-1 (boot - ext2), /dev/dm-2 (swap) and /dev/dm-3 (root - ext3)

it's hardware raid, made from bios

grub doesn't detect my partitions/drives  :Sad: 

dmraid -r:

```

/dev/sdb: pdc, "pdc_hacjeb", stripe, ok, 388671872 sectors, data@ 0

/dev/sda: pdc, "pdc_hacjeb", stripe, ok, 388671872 sectors, data@ 0

```

---

after i booted (on with gentoo-minimal) i used dmraid -a yes to activate the array, /dev/dm-0 should be the device .. at least that's the one i used with fdisk to create my partitions (dm-1, dm-2, dm3) and it worked .. hdparm -tT /dev/dm-0 shows a 2x speed so the raid is ok .. or at least it seems ok ..

--

tryied with grub --install /dev/dm-0 ... tryied with grub --no-floppy then root(hd0,0) and setup(hd0) but it doesn't find it's files .. wich i can ..

ls /boot/grub:

```

boot     device.map     fat_stage1_5  grub.conf         jfs_stage1_5  minix_stage1_5     splash.xpm.gz  stage2      stage2_eltorito  vstafs_stage1_5

default  e2fs_stage1_5  ffs_stage1_5  iso9660_stage1_5  menu.lst      reiserfs_stage1_5  stage1         stage2.old  ufs2_stage1_5    xfs_stage1_5

```

cat /boot/grub/device.map:

```

(fd0)   /dev/fd0

(hd0)   /dev/sda

(hd1)   /dev/sdb

```

Last edited by Dreadful on Wed Nov 12, 2008 6:54 pm; edited 1 time in total

----------

## bunder

 *Quote:*   

> it's hardware raid, made from bios 

 

 *Quote:*   

> /dev/mapper/pdc_hacjeb3 on / type ext3 (rw,data=ordered) 

 

it's fake raid.

having said that, you might want to try removing /boot from the stripe and installing grub to /dev/sda1.

cheers

----------

## Dreadful

i was afraid of that  :Sad: 

how do i remove it ?!

----------

## bunder

easiest way is to drop /dev/mapper/pdc_hacjeb1 from the array and create a regular partition in its place.  not sure if that would require dropping the whole array though.

cheers

----------

## Dreadful

and how do i drop it ? by removing /dev/dm-1 (/dev/mapper/pdc_hacjeb1) from /dev/dm-0 (/dev/mapper/pdc_hacjeb) ? and then ? fdisk /dev/sda and create a partition ? i'm totally lost ..

----------

## bunder

that sounds about right.  you might want to back up the current contents before you do that though, just the kernel stuff, you'll have to reinstall grub afterwards anyways.

cheers

----------

## Dreadful

i did something else, inserted a 3rd hdd to use it for boot/swap and the raid will host the rest

my last question is .. is the array going to get activated automatically on boot ? because right now i need to exec "dmraid -a yes" before i can use it ..

----------

## danomac

 *bunder wrote:*   

> easiest way is to drop /dev/mapper/pdc_hacjeb1 from the array and create a regular partition in its place.  not sure if that would require dropping the whole array though.

 

That's not a good idea...

I managed to get grub to install on my nvidia fakeraid, I'll try to help.

First, what's the output of:

```

$ ls /dev/mapper

```

 *Dreadful wrote:*   

> i did something else, inserted a 3rd hdd to use it for boot/swap and the raid will host the rest
> 
> my last question is .. is the array going to get activated automatically on boot ? because right now i need to exec "dmraid -a yes" before i can use it ..

 

It is possible to get grub to boot from a fakeraid raid0. Using raid0 isn't really such a good idea as if one drive dies, you lose all data... I set up raid1+0 on mine.

I also need to know what kernel you used for the last question.

----------

## Dreadful

```

lrwxrwxrwx  1 root root     16 Nov 11 02:11 control -> ../device-mapper

brw-rw----  1 root disk 253, 0 Nov 11 02:11 pdc_hacjeb

brw-rw----  1 root disk 253, 1 Nov 11 02:11 pdc_hacjeb1

```

pdc_hacjeb1 = dm-1 (only one partition left on it)

kernel: 2.6.25-hardened-r9

now .. i already did some installing and i don't see the point why should i start all-over again just for the boot partition

all it pisses me off right now is that i can't manage to compile a working kernel (besides the one i created with genkernel - wich obviously works) .. i don't see why do i need so many extra drivers just because i did a fake raid

when booting it tells me no such file, error code 15

one thing .. do i really need initramfs ? (never used it before) / never used genkernel before either .. i created the initramfs with genkernel using my own kernel config but when booting (i finally passed that "no file" problem .. it stops when trying to detect dm-1 as it doesn't load any modules (no modules found in initrd - huh?) i used built-in drivers .. why would it care ?

----------

## danomac

To answer a few of your questions, yes you do need to use initramfs as the raids have to be assembled before the kernel does it's autodetection (as you've probably noticed be the 'no modules found in initrd' message.)

While you can make an initrd yourself that includes the necessary packages, it can be a PITA so I just stuck with genkernel. If you want to customize genkernel, you can, by invoking menuconfig. i.e

```

$ genkernel --dmraid --menuconfig all

```

I prefer to put that stuff in /etc/genkernel.conf (there's entries for menuconfig and dmraid, just set them there and a simple `genkernel all` will suffice. You can go and customize your kernel like usual (I set up the kernel like I would normally, and genkernel built it and the initrd to match.)

Once you do that you have to put 'dodmraid' on the kernel line in grub.conf or the initrd won't load the modules needed for device-mapper to work.

Also, a simple `dmraid -ay` will mount the arrays. You don't need to specify the 'yes'. I got so used to typing it that way cause it was shorter.  :Razz:  (I had so many troubles getting my raid to work too...)

Besides that, if you have the typical layout where 1 is /boot, 2 is swap, and 3 is / you can install grub to it, but you have to override the device map that the livecd uses:

(Using your example above, with 3 partitions)

```

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

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

grub> device (hd0,0) /dev/mapper/pdc_hacjeb1

grub> root (hd0,0)

grub> setup (hd0)

grub> exit

```

The above is what worked for me to install grub to the array.

I hope you find the information useful, I remember I was grumbling about not being able to use my own kernel, but hey... at least I found a way to customize it.

----------

## Dreadful

thanks for the info

i'll try again with the kernel (i knew about dodmraid, didn't try genkernel --menuconfig)

also it's sad i didn't figure to ask before going on a 3rd hdd .. it's hard to remake partitions again right now  :Neutral: 

but better do it 100% clean .. this time i'll go x64  :Very Happy: 

what really pisses me off is udev loading stupid modules (like firewire support .. wich i don't even have on this mainboard ..). it loaded me 109 modules .. 

thanks again, i'll post results asap

----------

## danomac

 *Dreadful wrote:*   

> also it's sad i didn't figure to ask before going on a 3rd hdd .. it's hard to remake partitions again right now 

 

Haha, I know that feeling. I installed Gentoo/Windows on my new PC four times before I got it right. I was fighting failing hardware and didn't know it though.  :Neutral: 

----------

## Dreadful

```

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

grub> device (hd0,0) /dev/mapper/pdc_hacjeb1

grub> root (hd0,0)Unknown partition table signature

Error 5: Partition table invalid or corrupt

```

 :Sad: 

dmraid -r:

```

/dev/sdb: pdc, "pdc_hacjeb", stripe, ok, 388671872 sectors, data@ 0

/dev/sda: pdc, "pdc_hacjeb", stripe, ok, 388671872 sectors, data@ 0

```

(command entered from livecd, not chrooted)

chrooted results:

```

ERROR: opening path /sys/block

ERROR: failed to discover devices

```

wich i belive it's normal .. till i boot from it

/etc/fstab:

```

/dev/dm-1               /boot           ext2            noauto,noatime  1 2

/dev/dm-3               /               ext3            noatime         0 1

/dev/dm-2               none            swap            sw              0 0

/dev/cdrom              /mnt/cdrom      auto            noauto,ro       0 0

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

```

ls /dev/mapper/:

```

control  pdc_hacjeb  pdc_hacjeb1  pdc_hacjeb2  pdc_hacjeb3

```

cat /proc/mounts:

```

rootfs / rootfs rw 0 0

tmpfs / tmpfs rw 0 0

/dev/hdb /mnt/cdrom iso9660 ro 0 0

/dev/loop0 /mnt/livecd squashfs ro 0 0

proc /proc proc rw,nosuid,nodev,noexec 0 0

sysfs /sys sysfs rw,nosuid,nodev,noexec 0 0

udev /dev tmpfs rw,nosuid 0 0

devpts /dev/pts devpts rw,nosuid,noexec 0 0

tmpfs /mnt/livecd/lib64/firmware tmpfs rw 0 0

tmpfs /mnt/livecd/usr/portage tmpfs rw 0 0

usbfs /proc/bus/usb usbfs rw,nosuid,noexec 0 0

/dev/mapper/pdc_hacjeb3 / ext3 rw,data=ordered 0 0

/dev/mapper/pdc_hacjeb1 /boot ext2 rw 0 0

none /proc proc rw 0 0

udev /dev tmpfs rw,nosuid 0 0

```

cat /boot/grub/device.map:

```

(fd0)   /dev/fd0

(hd0)   /dev/hda

(hd1)   /dev/sda

(hd2)   /dev/sdb

```

---> do i need to edit device.map ? (i think not as long as i'm starting grub shell with no device map ..)

ideas ?

----------

## danomac

Did you start grub with the --device-map option? You will need to do this.

I had that error when I forgot.

----------

## Dreadful

started it with "grub --device-map=/dev/null"

does it matter i also have a 3rd hdd ? (hda) wich MAY and should be the 1st hdd in bios .. ?

it should .. so it should be hd1,0 or hd0,1 .. i don't know .. help  :Neutral: 

----------

## danomac

I'm a little confused, you said you weren't chrooted? You need to be chrooted to do this.

What does

```

$ fdisk -l

```

show after you start dmraid?

----------

## Dreadful

i said i tryied "non-chrooted" too but .. i was running inside chroot

```

Disk /dev/hda: 41.1 GB, 41110142976 bytes

16 heads, 63 sectors/track, 79656 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Disk identifier: 0x35ba2481

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sda: 200.0 GB, 200049647616 bytes

255 heads, 63 sectors/track, 24321 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x911e8df2

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          17      136521   83  Linux

/dev/sda2              18         267     2008125   82  Linux swap / Solaris

/dev/sda3             268       48387   386523900   83  Linux

Disk /dev/sdb: 200.0 GB, 200049647616 bytes

255 heads, 63 sectors/track, 24321 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/dm-0: 397.9 GB, 397999996928 bytes

255 heads, 63 sectors/track, 48387 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x911e8df2

     Device Boot      Start         End      Blocks   Id  System

/dev/dm-0p1   *           1          17      136521   83  Linux

/dev/dm-0p2              18         267     2008125   82  Linux swap / Solaris

/dev/dm-0p3             268       48387   386523900   83  Linux

Disk /dev/dm-1: 139 MB, 139797504 bytes

255 heads, 63 sectors/track, 16 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x00000000

     Device Boot      Start         End      Blocks   Id  System

Disk /dev/dm-2: 2056 MB, 2056320000 bytes

255 heads, 63 sectors/track, 250 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x00000000

Disk /dev/dm-2 doesn't contain a valid partition table

Disk /dev/dm-3: 395.8 GB, 395800473600 bytes

255 heads, 63 sectors/track, 48120 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x00000000

Disk /dev/dm-3 doesn't contain a valid partition table

```

hmm .. why invalid partition table  :Neutral: 

question: when i add/create the partitions/file systems .. do i need to do this from /dev/sdaX or from /dev/dm-X ? (did it from /dev/dm-X)

----------

## danomac

I wonder if grub is finding your /dev/hda drive, as it looks like it has no partitions. I'd turn off the computer and unplug it, just to make sure. We did create a custom device map, but I guess you never know.

All file operations (including paritioning and formatting, /etc/fstab) I used the /dev/mapper/<device> directly. I never used the /dev/dm-* files (didn't know they existed.) Whatever you do, don't use the /dev/sdX directly, or bye-bye array.  :Wink: 

It's normal for the non-first drive in an array to not have a partition table. I seriously think that grub was still trying to use /dev/hda which has no partitions.

----------

## Dreadful

removed /dev/hda and tryied again

Error 5: Partition table invalid or corrupt

wtf  :Sad: 

ran e2fsck /dev/dm-1 and it's clean ..

later edit: tryied the same commands (just replaced /dev/mapper/pdc_hacjeb with /dev/hda and /dev/mapper/pdc_hacjeb1 with /dev/hda1) and got the same thing (3rd hdd added), it worked only with these steps:

grub --no-floppy

root (hd0,0)

setup (hd0)

i'm afraid there's something wrong on setting devices .. just a guess ..

for the moment i'm on with the other hdd too (installed grub/kernel and will boot from it) till i manage to install grub on /dev/dm-1 so i can get up with the rest of the system ..

----------

## danomac

That's pretty bizarre - I don't even know what could cause that. Did you try the gentoo-wiki? There's an article about nvraid on there that you could probably use. Maybe they have a workaround.

----------

## Dreadful

didn't think about the wiki as i knew it was lost  :Neutral:  and the last time i went to see it it only had 3 articles

... 1 hour later .. WORKS !!  :Very Happy:  WIKI POWER !!  :Very Happy: 

so, to know the mistakes:

was running this:

```

grub --device-map=/dev/null

grub> device (hd0,0)  /dev/mapper/pdc_hacjeb1

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

grub> root (hd0,0)

grub> setup(hd0)

```

instead of this:

```

grub --device-map=/dev/null

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

grub> device (hd0,0)  /dev/mapper/pdc_hacjeb1

grub> root (hd0,0)

grub> setup(hd0)

```

hehe  :Smile: 

----------

## danomac

That's what I wrote way up top somewhere!

At least you figured it out!

----------

## Dreadful

sort of, you had the mistake i posted in the first [code] and the correct was in the 2nd one

----------

