# mkinitramfs??

## nbensa

Hello,

at work I use Debian boxes where you do mkinitramfs after a kernel compile but I can't find a similar tool for Gentoo. How do you make an initramfs for Gentoo?

Many thanks in advance,

Norberto

----------

## d_m

emerge -s mkinitrd

Good luck.

----------

## nbensa

Ok. I got mkinitrd (devs should rename this package as it reminds me the old-school-cramfs-initrd) but I can't get it to boot.

```
# mkinitrd -f -v /boot/initramfs-2.6.16-gentoo-r4 2.6.16-gentoo-r4

Creating initramfs

Looking for deps of module ide-disk      ide-core

Looking for deps of module ide-core

Looking for deps of module dm-mod

Looking for deps of module reiserfs

Using modules:  ./kernel/drivers/ide/ide-core.ko ./kernel/drivers/ide/ide-disk.ko ./kernel/drivers/md/dm-mod.ko ./kernel/fs/reiserfs/reiserfs.ko

/sbin/nash -> /var/tmp/initrd.NZ4r1V/bin/nash

/sbin/insmod.static -> /var/tmp/initrd.NZ4r1V/bin/insmod

copy from /lib/modules/2.6.16-gentoo-r4/./kernel/drivers/ide/ide-core.ko(elf32-i386) to /var/tmp/initrd.NZ4r1V/lib/ide-core.ko(elf32-i386)

copy from /lib/modules/2.6.16-gentoo-r4/./kernel/drivers/ide/ide-disk.ko(elf32-i386) to /var/tmp/initrd.NZ4r1V/lib/ide-disk.ko(elf32-i386)

copy from /lib/modules/2.6.16-gentoo-r4/./kernel/drivers/md/dm-mod.ko(elf32-i386) to /var/tmp/initrd.NZ4r1V/lib/dm-mod.ko(elf32-i386)

copy from /lib/modules/2.6.16-gentoo-r4/./kernel/fs/reiserfs/reiserfs.ko(elf32-i386) to /var/tmp/initrd.NZ4r1V/lib/reiserfs.ko(elf32-i386)

Loading module ide-core

Loading module ide-disk

Loading module dm-mod

Loading module reiserfs

```

Grub:

```
title=Gentoo GNU/Linux (2.6.16-gentoo-r4)

kernel /2.6.16-gentoo-r4 root=/dev/hda7 rw reboot=warm

initrd /initramfs-2.6.16-gentoo-r4

```

Gives "Can't mount root (unknown block 0,0)" Which is normal since there are no ide modules loaded, so then I've tried:

root=/dev/ram

root=/dev/ram0

Those give me "Can't mount root (unknown block 1,0)"

NOTE: I know ramfs is compiled in since I was using splash_geninitramfs without problems. BTW, when I try to append the splash I get:

```
# splash_geninitramfs -a /boot/initramfs-2.6.16-gentoo-r4 -r 800x600 --no8bpp -v  livecd-2006.0

o Unpacking /boot/initramfs-2.6.16-gentoo-r4..

cpio: premature end of file

o Creating directory structure..

o Copying /sbin/splash_helper..

o Copying themes..

  - livecd-2006.0

o Creating initramfs image..
```

Note the "cpio: premature end of file" message. Perhaps mkinitrd does something wrong? And before you ask, YES I've tried WITH and WITHOUT splash. This is the content of /boot/initramfs-2.6.16-gentoo-r4

```
# zcat /boot/initramfs-2.6.16-gentoo-r4 | cpio --list

.

lib

lib/ide-core.ko

lib/ide-disk.ko

lib/dm-mod.ko

lib/reiserfs.ko

bin

bin/nash

bin/insmod

bin/modprobe

etc

dev

dev/console

dev/null

dev/ram

dev/systty

dev/tty1

dev/tty2

dev/tty3

dev/tty4

loopfs

proc

sys

sysroot

sbin

init

2769 blocks

```

Can anyone please tell me what I'm doing wrong? 

Many thanks in advance,

Norberto

----------

## d_m

Did you make sure your image is smaller than the maximum size in the kernel? I think the default is something like 8 MB. To change the maximum size allowed, recompile your kernel.

----------

## nbensa

~1MB uncompressed

----------

## d_m

So hey, if you just want to mount the RAM fs and not actually mount your disk, take out the root= kernel option. The initrd is automatically mounted as root and the root=X partition is then mounted over it later. Or... you could put the kernel module in the initrd and then modprobe it yourself (using linuxrc or something).

Good luck.

----------

## nbensa

```
Unable to mount root fs on unknown block (3,7)
```

Yup. It seems that if I drop the root= option, the kernel tries to boot directly from the ide drive and since it doesn't have the modules compiled-in, it fails. 

Oh well... no initrd for me.

----------

## d_m

The thing I don't understand is: if your kernel doesn't have IDE support compiled in, and the module is not in your initrd... then how could you ever mount your root partition (with or without the initrd)?

----------

## nbensa

 *d_m wrote:*   

> The thing I don't understand is: if your kernel doesn't have IDE support compiled in, and the module is not in your initrd... then how could you ever mount your root partition (with or without the initrd)?

 

Hm?

I'm have two kernels. One with ide and rootfs modules built-in. The second one uses (or I'm trying to) an initramfs. I think the second kernel just ignores the initrd generated with mkinitrd: unable to mount root on unknown block (1,0)

Thanks d_m for trying to help me.

Regards,

Norberto

----------

## nbensa

Bug in mkinitd. It uses -c (old ascii format) and kernel seems to expect newc (srv4)

Everything is working now.

Just another example of why Linux is not ready for everyone    :Sad:   :Crying or Very sad: 

----------

## d_m

Well... glad you got it fixed at least.

----------

