# reconfiguring the kernel and initramfs

## dcljr

Having successfully installed Gentoo Linux on my AMD Sempron 2500+ system (using genkernel, resulting in 'kernel-genkernel-x86-2.6.12-gentoo-r9') and created a working system -- enough to do e-mail and web-browsing, anyway -- I decided to tackle my remaining problems with printing and sound (namely, that neither had been enabled). So I reconfigured the kernel starting from make menuconfig in /usr/src/linux (does this mean I was starting from the same place I would have been if I'd never used genkernel in the first place?) and named the result 'kernel-manual-x86-2.6.12-gentoo-r9'.

Referring to the sections of the x86 Handbook on Configuring the Kernel and Configuring the Bootloader, and cross-referencing those instructions with what it said in the Manual configuration section of the Gentoo Linux Kernel Upgrade Guide (even though I wasn't actually upgrading the kernel, just reconfiguring it), I copied the bzImage and System.map files as instructed and went to update /boot/grub/grub.conf.

Although the Handbook says in chapter 10:

 *Quote:*   

> Note: When you reinstall a kernel, you do not need to copy over the files anymore. Just run make install after compiling the kernel; it will automatically copy the necessary files and adjust the GRUB configuration.

 

I didn't remember that when I started this, so I ended up just compiling and installing as discussed in section 7.c. of the x86 Handbook. If I had used make install would it have overwritten the current setup (since I wasn't using a new version or release of the kernel) or would it have created a second, separate kernel as I've done? Should I have followed the Using your old kernel .config section of the Kernel Upgrade Guide instead?

Anyway, now that I'm editing /boot/grub/grub.conf, I realize that there's no /boot/initramfs-...-2.6.12-gentoo-r9 file (since I didn't use genkernel) and bascially I'm wondering why?

To get specific, here's my old /boot/grub/grub.conf:

 *Quote:*   

> # By default, boot the first entry after 5 seconds without splash screen.
> 
> default 0
> 
> timeout 5
> ...

 

And here's the new version:

 *Quote:*   

> # By default, boot the first entry after 7 seconds without splash screen; otherwise boot the second.
> 
> default 0
> 
> fallback 1
> ...

 

(There are no breaks between the kernel and initrd lines although the long kernel lines might have been wrapped on your screen.)

Will that do what I want it to? (In particular, I want to verify that removing "/dev/ram0 init=/linuxrc ramdisk=8192 real_root=" and "udev" from the kernel line and the entire initrd line is okay before I try rebooting. What can I say? I'm a paranoid newbie...)

So why is the other stuff necessary when using genkernel but not when using a manually configured kernel? I don't get it. I've scanned the Genkernel Guide and didn't see an explanation.

(I hope this post makes sense. I've had to rewrite portions of it as I'm learning things even as I type this up....)

 - dcljrLast edited by dcljr on Sun Sep 04, 2005 12:44 am; edited 2 times in total

----------

## aceFruchtsaft

Why don't you just keep using genkernel? You can manually configure your kernel options by running it with the --menuconfig argument, and if you want to keep your previous kernel which happens to have the same version as the new kernel, you can still use the --kernname option to specify a different name and thus prevent the old kernel from being overwritten.

It will also automatically create an initramfs with udev, lvm2, splash, etc. support.

----------

## dcljr

 *aceFruchtsaft wrote:*   

> Why don't you just keep using genkernel?

 

Well, mainly because I already did that and ended up with no printing or sound.

 *Quote:*   

> You can manually configure your kernel options by running it with the --menuconfig argument, and if you want to keep your previous kernel which happens to have the same version as the new kernel, you can still use the --kernname option to specify a different name and thus prevent the old kernel from being overwritten.

 

I guess that makes sense. I hadn't used genkernel --menuconfig originally because the Handbook only mentions it in the context of using a non-ext2 or -ext3 filesystem for /boot (which I wasn't doing). As I recall, when I first installed Gentoo I had to invoke genkernel  a few times to make sure I configured everything correctly (I think I kept quitting to look stuff up) and even then I didn't end up with everything I needed.

 *Quote:*   

> It will also automatically create an initramfs with udev, lvm2, splash, etc. support.

 

I've now found this document, which I think I understand, and... hey, looky there... man initrd.   :Smile: 

So lemme get the straight: since genkerel tries to be all things to all people, it creates an initramfs to take care of any kernel modules that are crucial to the initial boot. But if you don't use genkernel then ostensibly you've compiled everything you need for initial booting into the kernel itself and hence do not need initrd and the other stuff in grub.conf (see my original post).

Right?

But then why not have genkernel compile everything into the kernel just like a user would in make menucofig? I still don't understand why there's a difference.

(Oh, and I'm still waiting for someone to "bless" my grub.conf file...)

 - dcljr

----------

## drescherjm

 *Quote:*   

> Will that do what I want it to?

 

I am not sure as I am confused at what you are asking. It looks like you started out using genkernel and did not use the menuconfig option so you basically had a kernel that did not support your system. Instead of running genkernel with the correct option you manually configured and recompiled your kernel and now you want to know the correct or possibly minimal grub setting for your new manually configured kernel. 

[EDIT]

I just looked at the install guildes and I can not believe that they do not mention the -menuconfig parameter of genkernel. I am not sure if this has been removed from the guide or what. I did my first install about 16 months ago using the just the quick install guide and the faq of this forum and I know I used genkernel as I have done so just about every time since. 

[/EDIT]

 *Quote:*   

> In particular, I want to verify that removing "/dev/ram0 init=/linuxrc ramdisk=8192 real_root=" and "udev" from the kernel line

 

You should keep the init=/linuxrc.  Also I believe vga=0x318 and 1024x768-32@85 are incompatible parameters. Use one or the other depending on if you installed vesafb or vesafb-tng in your kernel. However, you don't appear to be using gensplash so you can delete the whole " vga=0x318 video=vesafb:mtrr,ywrap,1024x768-32@85" part as this is used mainly for the fancy boot up splash.

 *Quote:*   

> and the entire initrd line is okay before I try rebooting. What can I say? I'm a paranoid newbie...

 

If you want to experiment with boot settings add multiple configs in your grub settings so that if you muck something up you will be able to boot without having to resort to using a live cd to fix the problem.

----------

## aceFruchtsaft

BTW, you can still edit the boot settings directly from within grub if something goes wrong. So if you remove this or that you can still add prior to booting.

----------

## drescherjm

 *Quote:*   

> BTW, you can still edit the boot settings directly from within grub if something goes wrong. So if you remove this or that you can still add prior to booting.

 

Good point. I have used that many times... That is a very nice feature especially when you somehow got the wrong partition specified in the boot.

----------

## dcljr

 *drescherjm wrote:*   

> It looks like you started out using genkernel and did not use the menuconfig option so you basically had a kernel that did not support your system.

 

Yes.

 *drescherjm wrote:*   

> Instead of running genkernel with the correct option you manually configured and recompiled your kernel and now you want to know the correct or possibly minimal grub setting for your new manually configured kernel.

 

Right.

 *drescherjm wrote:*   

> I just looked at the install guildes and I can not believe that they do not mention the -menuconfig parameter of genkernel.

 

Well, they do, but it's not as obvious as you (or I) mght like. The x86 Handbook just says:

 *Quote:*   

> Note that, if your boot partition doesn't use ext2 or ext3 as filesystem you might need to manually configure your kernel using genkernel --menuconfig all and add support for your filesystem in the kernel...

 

 *drescherjm wrote:*   

> You should keep the init=/linuxrc. 

 

A-ha! I knew there was something that was gonna be wrong.... But wait a minute. Why isn't that in the Handbook's sample grub.conf for non-genkernel users?

 *drescherjm wrote:*   

> Also I believe vga=0x318 and 1024x768-32@85 are incompatible parameters. Use one or the other depending on if you installed vesafb or vesafb-tng in your kernel.

 

Ah, I see. That part of the Handbook was pretty confusing. I think I'm only now reading it right -- even after posting about it twice already. [1] [2] Thanks, drescherjm!

 *drescherjm wrote:*   

> However, you don't appear to be using gensplash so you can delete the whole " vga=0x318 video=vesafb:mtrr,ywrap,1024x768-32@85" part as this is used mainly for the fancy boot up splash.

 

Yeah, I figured that was probably the case. Believe me, I'm glad to be rid of that!

 *aceFruchtsaft wrote:*   

> BTW, you can still edit the boot settings directly from within grub if something goes wrong. So if you remove this or that you can still add prior to booting.

 

Oh, yeah, I remember seeing that option. I've never tried it to see how easy it is to use...

Okay, so here's where I stand. Please correct any mistakes:

When you invoke make menuconfig as I did, you are starting "from scratch", as it were, in configuring the kernel, not starting from any previous configuration, genkernel or otherwise.

In fact, if you use genkernel --menuconfig, you're still starting from scratch, you just get to config everything and then have genkernel take over to compile it. (Then you can use make install to install it and automatically modify grub.conf for you? [See second note under Code Listing 8 in chapter 10 of the x86 Handbook.] That's all you need to do?)

When manually configuring, you have to manually install also (copying bzImage and System.map to /boot) if you don't want to overwrite a previously configured same-release kernel.

If you're not using genkernel then you don't need the initrd line or the kernel options root=/dev/ram0 ramdisk=8192 real_root=/dev/hda3 (or something similar) in grub.conf, but you do need root=/dev/hda3 init=/linuxrc (or similar).

There's really no reason not to use genkernel, since you can manually configure it anyway with genkernel --menuconfig and tell it to use a different name with the --kernname option.

You still need init=/linuxrc on the kernel line of grub.conf even when you're not using genkernel because.....?

 - dcljr

----------

## aceFruchtsaft

To confuse you a little more, let me tell your that whether you need an initramfs or initrd does not depend on genkernel. You might also need them if you build your kernel manually. The purpose of initrd/initramfs is to provide any modules and resources (like framebuffer splash images) before the boot process is able to mount your root partition - otherwise, the boot loader could get that stuff from your / partition right away. So for example, if you have some IDE RAID controller and you compiled the driver as a kernel module, you would need the initrd cause otherwise the kernel would never find your hard disk. On the other hand, if you compiles everything right into the kernel, you wouldn't.

Also, make menuconfig and genkernel --no-clean --menuconfig use the .config file in your kernel directory if present, so they do not start from scratch. However, this is what you would want anyway, since you'll reuse the same kernel .config file for future kernels (you will have to run make oldconfig though to update it...).

----------

## gzunk

Just to put my 2 pennies worth in, I've just re-installed gentoo today (upgrading to X86-64) and I used genkernel this time. I too didn't have sound the first time round, and I was expecting it. I immediately caught onto the --menuconfig bit - probably because I've compiled lots of kernels in the past and the phrase "menuconfig" was a give-away, but I also agree that it's not really sign-posted in the handbook at all.

I put nv_sata and the USB mouse directly into the kernel as well, just to be safe. I've always been used to buliding monolithic kernels with everything I want into it - but this is the first time I was building an nforce4 based system and I wasn't sure what sata driver I would need... I'm sure I'll change back to a monolithic kernel, if I can figure out how to not use the initramfs...

----------

## dcljr

Well, after all that I just went back to genkernel again. Specifically:

 *Quote:*   

> genkernel --gconfig --save-config --no-clean --no-mrproper --no-bootsplash --install --kernname=genkernel2 --bootloader=grub all

 

And guess what? It zeroed out my grub.conf! (Son of a....) Fortunately, there's a backup version in grub.conf.bak.

(In case you're wondering, --bootloader=grub is an option in Genkernel 3.3.5 to "Add new kernel to GRUB configuration". Guess I won't be using that option ever again...)

 - dcljr

----------

## drescherjm

 *Quote:*   

> In case you're wondering, --bootloader=grub is an option in Genkernel 3.3.5 to "Add new kernel to GRUB configuration". Guess I won't be using that option ever again...

 

I had that option in my kernel build script. And I agree it is a bit buggy as it has trashed my genkernel.conf several times. Good thing I have always had a backup...

----------

