# Using genkernel to make a kernel

## jordanwb

So I've downloaded the 2.6.27.7 source tarball (I still find that a funny word) and extracted it to /usr/src and made a symlink to /usr/src/linux. I've emerged genkernel and make a .config file. How would I use genkernel to build the kernel with LVM2 root support?

----------

## djinnZ

Edit the /etc/genkernel.conf file, is the simplest way

----------

## richard.scott

 *djinnZ wrote:*   

> Edit the /etc/genkernel.conf file, is the simplest way

 

you don't need to do that with genkernel as its built in   :Wink: 

```
# emerge genkernel
```

you'll need to copy your .config into /etc/kernels with a filename like this:

```
kernel-config-x86-2.6.25-hardened-r10
```

If genkernel doesn't find this it will use a default generic one from /usr/share/genkernel/x86/kernel-config

and all you do is this to build a kernel:

```
genkernel --lvm --menuconfig all
```

and then add the relevant stuff into your grub config:

```
default 0

timeout 5

fallback 1

serial --unit=0 --speed=9600

terminal --timeout=15 console serial

title=Gentoo (2.6.25-hardened-r10) Console

root (hd0,0)

kernel /kernel-genkernel-x86-2.6.25-hardened-r10 root=/dev/ram0 init=/linuxrc real_root=/dev/vg0/root lvmraid=/dev/md2 dolvm console=ttyS0 console=tty1 vga=791 selinux=0

initrd /initramfs-genkernel-x86-2.6.25-hardened-r
```

note that the "kernel" line in grub ends with "selinux=0" so there are 4 lines to add to grub:

```
title

root

kernel

initrd

```

Hope this helps,

Rich

----------

## jordanwb

Okay that seems easy enough, but one thing I don't understand is why should I use this over the standard "make menuconfig, make && make modules_install"? I was told to use genkernel because I made a kernel and an initscript since root was on LVM and it wouldn't boot with the new kernel, despite the fact that I made the first kernel in the exact same way.

----------

## djinnZ

 *richard.scott wrote:*   

> you don't need to do that with genkernel as its built in  

   :Shocked:  leaving an option, critical to boot the system, as no default?

Is only the best way to have troubles. The way to hell is done with the good intentions (or the hope than we will never fail...  :Twisted Evil: 

Edit genkernel.conf and make the lvm support the default. (there are also some nice options in the genkernel's conf, do a look)

 *Quote:*   

> console=...

 sure than is a good choiche suggest to enable the serial console without hardware info?!  :Wink: 

In order to recicle the created .conf you can use --noclean option, than implies no mrproper but not disable the make oldconfig, so you must in every case recompile all. Is a good measure to prevent code mismatch but if you know what are doing... you can disable, but only by the conf file.

If you will boot from raid or lvm you need to build an "initrd" image. You can do it manually also but... better not repeating everytime the same commands (and configure genkernel to automatically add the builded images to grub).

----------

## jordanwb

 *djinnZ wrote:*   

> If you will boot from raid or lvm you need to build an "initrd" image. 

 

I know and that's what I did with the new kernel. I made a new initrd image using a script that was available on Gentoo-wiki before it went under. But when the new kernel boots, it can't find the LVM volumes.

----------

## jcat

Genkernel makes an "all encompassing" intird image.  There's nothing it can't do!   :Twisted Evil: 

Joking aside, it contains nearly every kernel feature by default, so you can't go too far wrong.  Hence why it's used for the LiveCD etc..

Cheers,

jcat

----------

## jordanwb

I'm trying to use genkernel and to me its like using a bazooka to open a window - just because you can doesn't mean you should.

I copied my .config file to /etc/kernels/kernel-config-x86_64-2.6.27.7 which genkernel sees but does not use. It wants to use .config.bak and I have no idea where that is or how to make it use kernel-config-whatever.

----------

## richard.scott

 *jordanwb wrote:*   

> I'm trying to use genkernel and to me its like using a bazooka to open a window - just because you can doesn't mean you should.
> 
> I copied my .config file to /etc/kernels/kernel-config-x86_64-2.6.27.7 which genkernel sees but does not use. It wants to use .config.bak and I have no idea where that is or how to make it use kernel-config-whatever.

 

I think if you messages are like mine (which I'd think they are) tells you this:

```
# genkernel --lvm --menuconfig all

* Gentoo Linux Genkernel; Version 3.4.10

* Running with options: --lvm --menuconfig all

* Linux Kernel 2.6.25-hardened-r10 for x86...

* kernel: >> Running mrproper...

* kernel: >> Running mrproper...

* config: Using config from /etc/kernels/kernel-config-x86-2.6.25-hardened-r10

*         Previous config backed up to .config.bak

*         >> Running oldconfig...
```

Which means that any existing /usr/src/linxux/.config file is now located here /usr/src/linxux/.config.bak

And as for it being har to use... there aren't many options you need to use on the command line. For all my kernels no matter what system they are on I build them with:

```
# genkernel  --lvm --menuconfig all
```

This works for all LVM, software raid and single hard drive setups.... oh and also for LiveUSB systems too!   :Very Happy: 

HTH

Rich

----------

## jcat

 *jordanwb wrote:*   

> I'm trying to use genkernel and to me its like using a bazooka to open a window - just because you can doesn't mean you should.
> 
> I copied my .config file to /etc/kernels/kernel-config-x86_64-2.6.27.7 which genkernel sees but does not use. It wants to use .config.bak and I have no idea where that is or how to make it use kernel-config-whatever.

 

That's where Genkernel saves configs after a successful kernel compile, not where it picks the config from.

On x86 it picks the config from

```
/usr/share/genkernel/x86/kernel-config-2.6
```

I'm not sure about x86_64, but you can configure the location in

```
/etc/genkernel.conf
```

look for the option

```
DEFAULT_KERNEL_CONFIG="${GK_SHARE}/%%ARCH%%/kernel-config"
```

Cheers,

jcat

----------

## djinnZ

What genkernel do:

if exist /etc/kernel/kernelxxx file use it or use the default in /usr/share/genkernel

if the option OLDCONFIG is set to yes (default) the .config will be copied to .config.bak, the /etc/kernel/kernel-config-xxx to .config and will be do a make oldconfig after a make mrproper or a make clean. If genkernel is called with option --noclean (or CLEAN=no on config) the mrproper will be disabled.

Very simple.

My suggestion remain to configure it, but how is more confortable is a your own choiche.

----------

## richard.scott

 *jcat wrote:*   

> ...That's where Genkernel saves configs after a successful kernel compile, not where it picks the config from.

 

That's not totally true....

Genkernel does use the files in /etc/kernels over /usr/share/genkernel/x86/kernel-config-2.6 but only if it exists.

If there is no specific file in /etc/kernels for your source then it will (by default) drop back to using /usr/share/genkernel/x86/kernel-config-2.6

Rich

----------

## richard.scott

lol, djinnZ you beat me to it   :Laughing: 

----------

## jcat

Ok, fair enough  :Smile: 

But I guess the advice for kernel _upgrade_ should still be to make sure the default config file is configured how you want it.

Cheers,

jcat

----------

## outermeasure

If you have already made the kernel, and just want the initrd, you can use

```

# genkernel --disklabel --lvm initrd

```

rather than making genkernel build the kernel+module+initrd as with "genkernel --disklabel --lvm all".

(I use --disklabel because I prefer to use UUID rather than the /dev/[hs]d*.)

----------

## jordanwb

I saved the config as  /etc/kernels/kernel-config-x86_64-2.6.27.7 but when I run genkernel --lvm all I get the menuconfig like I wanted but it has enabled almost everything.

----------

