# Creating a generic kernel

## dermund

Hi,

I am quite sure, that this was asked before, but I cannot find it with the 'search'.

Is it possible with genkernel to create a generic kernel, that will boot on most x86 machines (qemu, in my case) without having the "kernel .config" from the install cd's?

Or is there a faster way to create such a kernel?

Have a nice day,

dermund

----------

## VinzC

http://kernel-seeds.org/ ?

You can use a custom kernel configuration file with genkernel. Pappy's seeds only require you to set your critical boot devices. Once you have your kernel config right, use it as a template for genkernel.

----------

## dermund

Hey Starbuck,

Maybe I misunderstood kernel-seeds - but I thought it helps you with tailoring a specific kernel to your hardware. But I want a generic kernel that also runs on a qemu-system!

So maybe I just misconfigured genkernel. I expected that genkernel generates a whole lot of modules (like on a install-cd) , but this wasn't the case.

I generated my kernel with this command : "genkernel all" . This is my config:

```
# Configuration file for genkernel

# $Id: a71ce69bb2ebc75f83bf96545eb147b8d2485a32 $

# This file is sourced by genkernel at startup and determines which options

# we will be using to compile our kernel.  The order of precidence is simple,

# with the internal settings being least important, configuration file

# settings next, and command line options being most important.

# =========Common Command Line Option Defaults=========

# Run 'make oldconfig' before compiling this kernel?

OLDCONFIG="yes"

# Run 'make menuconfig' before compiling this kernel?

MENUCONFIG="no"

# Run 'make clean' before compilation?

# If set to NO, implies MRPROPER WILL NOT be run

# Also, if clean is NO, it won't copy over any configuration

# file, it will use what's there.

CLEAN="no"

# Run 'make mrproper' before configuration/compilation?

MRPROPER="yes"

# Override the arch detection?

# ARCH_OVERRIDE="x86"

# Mount BOOTDIR automatically if it isn't mounted?

MOUNTBOOT="no"

# Make symlinks in BOOTDIR automatically?

# SYMLINK="no"

# Save the new configuration in /etc/kernels upon

# successfull compilation

SAVE_CONFIG="no"

# Use Color output in Genkernel?

USECOLOR="yes"

# Clear build cache dir

# CLEAR_CACHE_DIR="yes"

# Genkernel uses an independent configuration for MAKEOPTS, and does not source

# /etc/make.conf . You can override the default setting by uncommenting and

# tweaking the following line. Default setting is set up by

# ${GK_SHARE}/${ARCH_OVERRIDE}/config.sh . The recommended value for -j

# argument is: <number of processors>*<number of cores per processor>+1

# MAKEOPTS="-j2"

# Add in LVM support from static binaries if they exist on the system, or

# compile static LVM binaries if static ones do not exist.

# LVM="no"

# Add in EVMS support from static binaries if they exist on the system: you

# should run "emerge evms" first.

# EVMS="no"

# Add DMRAID support.

# DMRAID="no"

# Include (or suppresses the inclusion of) busybox in the initrd or initramfs.

# If included, busybox is rebuilt if the cached copy is out of date.

# BUSYBOX="yes"

# Copy /etc/mdadm.conf to initramfs.

# MDADM="no"

# Add Multipath support.

# MULTIPATH="no"

# Add iSCSI support.

# ISCSI="no"

# Enable copying of firmware into initramfs

# FIRMWARE="no"

# Specify directory to pull from

# FIRMWARE_DIR="/lib/firmware"

# Specify specific firmware files to include. This overrides FIRMWARE_DIR

# FIRMWARE_FILES=""

# Enable disklabel support (copies blkid to initrd)

DISKLABEL="yes"

# Add new kernel to grub?

# BOOTLOADER="grub"

# =========Low Level Compile Settings=========

#

# GNU Make to use for kernel.  See also the --kernel-make command line option.

# KERNEL_MAKE="make"

# Compiler to use for the kernel (e.g. distcc).  See also the --kernel-cc

# command line option.

# KERNEL_CC="gcc"

# Assembler to use for the kernel.  See also the --kernel-as command line

# option.

# KERNEL_AS="as"

# Linker to use for the kernel.  See also the --kernel-ld command line option.

# KERNEL_LD="ld"

# GNU Make to use for the utilities.  See also the --utils-make command line

# option.

# UTILS_MAKE="make"

# Compiler to use for the utilities (e.g. distcc).  See also the --utils-cc

# command line option.

# UTILS_CC="gcc"

# Assembler to use for the utilities.  See also the --utils-as command line

# option.

# UTILS_AS="as"

# Linker to use for the utilities.  See also the --utils-ld command line

# option.

# UTILS_LD="ld"

# =========GENKERNEL LOCATION CONFIGURATION============

# Variables:

#   %%ARCH%%  - Final determined architecture

#   %%CACHE%% - Final determined cache location

# Set genkernel's temporary work directory.  Default is /var/tmp/genkernel

# TMPDIR="/var/tmp/genkernel"

# Set the boot directory, default is /boot

#BOOTDIR="/boot"

# Default share directory location

GK_SHARE="/usr/share/genkernel"

# Location of the default cache

CACHE_DIR="/var/cache/genkernel"

# Location of DISTDIR, where our source tarballs are stored

DISTDIR="${CACHE_DIR}/src"

# Log output file

LOGFILE="/var/log/genkernel.log"

# Debug Level

LOGLEVEL=1

# Default location of kernel source

DEFAULT_KERNEL_SOURCE="/usr/src/linux"

# Default kernel config (only use to override using

# arch/%%ARCH%%/kernel-config-${VER}.${PAT} !)

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

BUSYBOX_VER="1.7.4"

BUSYBOX_SRCTAR="${DISTDIR}/busybox-${BUSYBOX_VER}.tar.bz2"

BUSYBOX_DIR="busybox-${BUSYBOX_VER}"

BUSYBOX_BINCACHE="%%CACHE%%/busybox-${BUSYBOX_VER}-%%ARCH%%.tar.bz2"

DEVICE_MAPPER_VER="1.02.22"

DEVICE_MAPPER_DIR="device-mapper.${DEVICE_MAPPER_VER}"

DEVICE_MAPPER_SRCTAR="${DISTDIR}/device-mapper.${DEVICE_MAPPER_VER}.tgz"

DEVICE_MAPPER_BINCACHE="%%CACHE%%/device-mapper-${DEVICE_MAPPER_VER}-%%ARCH%%.tar.bz2"

LVM_VER="2.02.28"

LVM_DIR="LVM2.${LVM_VER}"

LVM_SRCTAR="${DISTDIR}/LVM2.${LVM_VER}.tgz"

LVM_BINCACHE="%%CACHE%%/LVM2.${LVM_VER}-%%ARCH%%.tar.bz2"

DMRAID_VER="1.0.0.rc14"

DMRAID_DIR="dmraid/${DMRAID_VER}"

DMRAID_SRCTAR="${DISTDIR}/dmraid-${DMRAID_VER}.tar.bz2"

DMRAID_BINCACHE="%%CACHE%%/dmraid-${DMRAID_VER}-%%ARCH%%.tar.bz2"

ISCSI_VER="2.0-871"

ISCSI_DIR="open-iscsi-${ISCSI_VER}"

ISCSI_SRCTAR="${DISTDIR}/open-iscsi-${ISCSI_VER}.tar.gz"

ISCSI_BINCACHE="%%CACHE%%/iscsi-${ISCSI_VER}-%%ARCH%%.bz2"

E2FSPROGS_VER="1.40.9"

E2FSPROGS_DIR="e2fsprogs-${E2FSPROGS_VER}"

E2FSPROGS_SRCTAR="${DISTDIR}/e2fsprogs-${E2FSPROGS_VER}.tar.gz"

BLKID_BINCACHE="%%CACHE%%/blkid-${E2FSPROGS_VER}-%%ARCH%%.bz2"

FUSE_VER="2.7.4"

FUSE_DIR="fuse-${FUSE_VER}"

FUSE_SRCTAR="${DISTDIR}/fuse-${FUSE_VER}.tar.gz"

FUSE_BINCACHE="%%CACHE%%/fuse-${FUSE_VER}-%%ARCH%%.tar.bz2"

UNIONFS_FUSE_VER="0.22"

UNIONFS_FUSE_DIR="unionfs-fuse-${UNIONFS_FUSE_VER}"

UNIONFS_FUSE_SRCTAR="${DISTDIR}/unionfs-fuse-${UNIONFS_FUSE_VER}.tar.bz2"

UNIONFS_FUSE_BINCACHE="%%CACHE%%/unionfs-fuse-${UNIONFS_FUSE_VER}-%%ARCH%%.bz2"

```

Also a .config from the install cd would do it. But where do I get for a 2.6.36.1 kernel without downloading the whole cd?

----------

## VinzC

Hmmm... I take Pappy Mc Fae's kernel seeds as the minimum kernel config that's required to make one's hardware work. Just add the "generic" options you want afterwards.

By the way, these kernel seeds do not take your specific hardware into account; you need to add support for your disks, video, aso. If you have a good knowledge of what x86 platform can be, just add the required support. Of course I guess it'll require a few attempts to check your kernel on several machines but at least you'll be certain you have a minimal, generic kernel with options that *you* have selected.

Other than that, run genkernel --menuconfig (IIRC) and uncheck the options you sure don't want. Save the configuration and you're done. You'll have a bigger kernel but generic.

EDIT: Forgot the "Starbuck" thing  :Very Happy:  . Nice catch however it's not Katee Sackhoff in BSG but in "Wonder Woman" playing Sarah Corvus  :Wink:  .

EDIT: Heck! Am I on crack or... WTF??? It was not "Wonder Woman", but "Bionic Woman" (facepalm)

----------

## dermund

 *Quote:*   

> Of course I guess it'll require a few attempts to check your kernel on several machines but at least you'll be certain you have a minimal, generic kernel with options that *you* have selected. 

 

Hmm. I really want a generic kernel.

A really big ass kernel with really a lot of modules.

When I try it with genkernel --menuconfig all the bastard always takes my current config into account - also if I remove /usr/src/linux/.config .

I think I will just add the qemu hardware options to kernel by hand and forget about the generic kernel idea...

 *Quote:*   

> EDIT: Forgot the "Starbuck" thing  . Nice catch however it's not Katee Sackhoff in BSG but in "Wonder Woman" playing Sarah Corvus  .

 

Haven't seen Wonder Woman. For me she is just Starbuck  :Wink: 

----------

## VinzC

 *dermund wrote:*   

> When I try it with genkernel --menuconfig all the bastard always takes my current config into account - also if I remove /usr/src/linux/.config .

 

Then try setting SAVE_CONFIG="yes" in genkernel.conf.

----------

## dermund

I can't approve that it worked, because I worked around this.

Because there were no modules in /lib/modules/... I thought that it didn't work - but I forgot that genkernel writes all the modules into the initrd.

So if I find time, I will check if the modules are there.

----------

## ShadowCat8

Well, 

What about configuring a kernel to *exactly* what qemu is going to provide you with?

 *man 1 qemu wrote:*   

> QEMU(1)
> 
> NAME
> 
>        qemu-doc - QEMU Emulator User Documentation
> ...

 

That's the list of what qemu is going to emulate by default.  So, what about just config'ing a kernel to that?

Just my 2¢.

----------

## dE_logics

Build from the Debian kernel sources.

----------

## rapsure

I have a very large kernel config that will boot qemu. The only change that will be needed is to change the arch. Other than that nearly all of the modules are built for all the supported network cards, usb, sound, etc. It could take a while to compile because there are so many config options enabled. I've been using it to make a single kernel config that can boot a large number of computers without me reconfiguring the kernel for each machine.

----------

