# [SOLVED] How to make a Initramfs image?

## Gen_Too

How could i make an Initramfs image for grub?

Thank you.Last edited by Gen_Too on Wed May 18, 2011 7:22 pm; edited 2 times in total

----------

## avx

Depends on what you need to have inside it. There's genkernel-stuff, mkinitrd, dracut and of course, you can do it by hand.

I've always done mine myself, it's not that complicated, but you learn something and have full control, so that in case something breaks, you don't have to understand the tool's magic.

Basics for doing it by hand:

- create a folder

- in there create the needed folder structure (dev, etc, bin, sbin, lib, ...)

- build busybox with the options you want/need and install it into the created folder

- populate the folder with statically linked programs you need, for example cryptsetup, udevadm, gpg, ...

- write an init-script, place it in the topdir, make it executable

- add devicenodes, if needed

- pack the whole folder using cpio and gzip

- done

----------

## John R. Graham

The easiest way is to use Gentoo's genkernel package (sys-kernel/genkernel). See the Gentoo Linux Genkernel Guide and the Handbook, Chapter 10: Configuring the Bootloader, Code Listing 2.4: grub.conf for genkernel users.

- John

----------

## Gen_Too

I think i explained bad. Ive an initramfs image and i get a new kernel. do i need to do a new initramfs image for grub and howto?

----------

## John R. Graham

Do you mean, "How do I tell grub about this initramfs that I have?" If so, then see the code listing that I referenced from the Handbook. If that's not what you mean, then could you explain further, please?

- John

----------

## Gen_Too

I will explain again. 

1. I dont know very much about this things, im new in gentoo and why not, in linux too.

2. I only now how to copy the kernel image to /boot.

3. I dont know nothing about Initramfs and the info in Google is a bit unhuman for my experience.

Now ill explain what have i done. I installed Gentoo. Then, i got a new kernel, copiled it and copied to /boot. 

The question is: Now what have i to do with Initramfs???

----------

## avx

Ok, since you are new, let me ask you this: Are you even sure you need an initrd? It's not that really everyone need one, in fact, most people don't. So if you think you do, tell us what purpose your initrd is for, that makes it easier to help you.

----------

## Gen_Too

I dont know what is it. Maybe it means i dont need one.

----------

## John R. Graham

Is your system booting on its own? If so, please post the kernel line(s) from your /boot/grub/grub.conf file. That'll tell us if you need an initramfs or not.

- John

----------

## Gen_Too

Yes, ive it added to grub by default

----------

## John R. Graham

Sorry; what I meant to as was, could you show us exactly what the "kernel" line in your /etc/grub/grub.conf file looks like? For example, mine looks like this:

```
kernel /boot/vmlinuz root=/dev/sda3
```

- John

----------

## Gen_Too

Its not well configured. Im not using a genkernel config:

# This is a sample grub.conf for use with Genkernel, per the Gentoo handbook

# http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10#doc_chap2

# If you are not using Genkernel and you need help creating this file, you

# should consult the handbook. Alternatively, consult the grub.conf.sample that

# is included with the Grub documentation.

default 0

timeout 30

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title Gentoo Linux 2.6.37-r4

root (hd0,0)

kernel /boot/kernel-genkernel-x86_64-2.6.37-gentoo-r4 root=/dev/sda3

initrd /boot/initramfs-genkernel-x86_64-2.6.37-gentoo-r4

title Gentoo Linux 2.6.37-r4 (Rescate)

root (hd0,0)

kernel /boot/kernel-genkernel-x86_64-2.6.37-gentoo-r4 root=/dev/sda3 init=/bin/bb

initrd /boot/initramfs-genkernel-x86_64-2.6.37-gentoo-r4

# vim:ft=conf:

----------

## John R. Graham

Hmm. You say that you are not using genkernel, but your grub.conf files shows a genkernel-generated kernel. Now I'm confused. Did you build your kernel with genkernel?

Note for ease of reading, it's nice to put code and configuration files inside [code] tags.

- John

----------

## Gen_Too

I say that because i used genkernel at first but im configuring it manually right now

----------

## John R. Graham

Well, two comments:First, if you configure manually, like this

```
cd /usr/src/linux

make menuconfig
```

and then you compile it manually, like this

```
make

make modules_install

```

then, the resultant kernel is not named "kernel-genkernel-x86_64-2.6.37-gentoo-r4". In other words, no matter what you're doing with your manual kernel build, you don't yet have grub set up to launch your manually configured and built kernel. What is the name of the kernel in /boot that you manually built?

Second, your current grub.conf is not using the initramfs that is mentioned there, so that answers your initial question. You do not need an initramfs.- John

----------

## avx

 *Gen_Too wrote:*   

> I say that because i used genkernel at first but im configuring it manually right now

 Do you (plan to) use anything not standard, ie. luks, mdadm/special RAID-controller, etc.? If not, then you won't really need an initrd.

Mine for example is just used, since I have fulldisk encryption running and I've got a minimal rescue system in there.

----------

## Gen_Too

 *Quote:*   

> then, the resultant kernel is not named "kernel-genkernel-x86_64-2.6.37-gentoo-r4". In other words, no matter what you're doing with your manual kernel build, you don't yet have grub set up to launch your manually configured and built kernel. What is the name of the kernel in /boot that you manually built? 

 

You are in error. Its only the name that says "genkernel", but i overwritted my own kernel to that with TAB (i said it hasnt configured well).

Thank you all very much!

----------

## John R. Graham

 *Gen_Too wrote:*   

> ...
> 
> You are in error.
> 
> ...

 Well, I'm glad you were able to straighten me out.   :Wink: 

- John

----------

## kipas_angin

well, it seems that this problem is quite the same as mine, but i think it's not solved yet,

here's the situation, i'm a baby-born to linux, just about a month using ubuntu and trying gentoo for my long lasting os

first, i've followed all the handbook intructed, and getting my sistem ready for first boot. the problem start after myself-compiled kernel extracted

it cannot enter the desktop like when i use live DVD. my screen just showing a message :"this is cacaa.unknown_domain (linux i686 2.6.39-gentoo-r3)"

FYI, cacaa is my localhost name, and my user that i've created after setting root's passwd (chapter 8.c on the handbook), i name my compiled kernel by gentoo, not linux i686 2.6.39-gentoo-r3

i thought that was my kernel problem, so i rebuilt it with genkernel. this time the log says error :"* ERROR: Could not copy the initramfs image to /boot!"

i've no idea of what is initramfs, and what it's used for.

FYI, i set my /boot on another partition which 7.4MiB harddrive. 

the question is:

1 may my sistem could start without initramfs?

2 or if it has to have initramfs, should i resize my /boot? 

3 is there any solution so i can resize my windows partition and /boot partition without making me to log in to windows first? because in fdisk there is no option for it.

----------

## gerard27

Slamet kipas_angin,

When you use genkernel and want to copy the kernel and initramfs to boot you should have boot mounted.

Initramfs contains modules needed to boot your system.

I suggest using rescuecd to install or repair the system.My sig contains a link where you can d/l it.

It also has tools to shrink Windows.Remember to defragment Windows first.

Gerard.

----------

## kipas_angin

actually i've mounted /boot on my sistem, but it full.

when i'm making /boot partition, i've choose 5GB actually, but fdisk says that i don't have that much space, actually i have 50GB empty space, but i can't set 5GB  for /boot partition, is there any partition size limit for the primary drive? all i know, the limit was for 4 primary partition, not for it size.

allright, I'd rather to defrag and shrink my windows partition from windows itself, so i do not lose any of my data.

thank you for your advice

----------

