Kernel/genkernel

From Gentoo Linux Wiki

Jump to: navigation, search

Contents

[edit] Introduction

Genkernel is a script available with Gentoo Linux designed to allow users who are not previously used to compiling a kernel to generate a kernel that will autodetect their hardware in the same fashion as the Gentoo LiveCD's.

Some users may also be interested in using genkernel for hardware which requires initialization and a working kernel before it can be booted. Because genkernel also automatically compiles your kernel modules, thus allowing hardware which needs to be loaded with module parameters to be used.

[edit] Is Genkernel for me?

Genkernel is often a good choice to those who are unused to compiling their own kernel or those who are not certain about their hardware configurations, but is equally a good choice for those who are used to compiling their own kernels as it greatly simplifies the process.

Because genkernel is designed to use a generic configuration, it should be able to support all of your hardware - however, because all the drivers and modules have to be compiled as well, using the --menuconfig option to manually alter the default configuration (or a previously stored configuration) is advisable and often much faster provided you know what you need.

[edit] Getting genkernel

You can obtain genkernel by simply running emerge -av genkernel. If you want genkernel to automatically mount /boot, you should also set the USE flag "symlink". Don't forget to use the -k flag for emerge if you are using binary packages, i.e. GRP. Due to the GRP packages having an older version of genkernel, the flags are different. As a result, you should consult the Gentoo Handbook and genkernel --help if you are using GRP packages.

[edit] Supported platforms

As of genkernel 3.0.2; the following platforms should be supported: alpha, amd64, parisc, parisc64, ppc, ppc64, sparc, sparc64, and x86. If you believe that there is a bug with the support code, and not with genkernel, please file a bug at the Gentoo Bugzilla.

[edit] Genkernel usage

Genkernel is designed to work in three modes:

  • "all" mode: this builds the kernel, modules and the initrd
  • "bzImage" mode: this only builds the kernel image
  • "kernel" mode: this only builds the kernel image and modules
  • "initrd" mode: this only builds the initrd

Most users will only want the "all" mode, which runs the "kernel" mode and the "initrd" mode for you.

Although genkernel is mainly a command to make your life easier when you need to compile a kernel, genkernel is also packed full of different flags which allow you to customize how your kernel is compiled or configured.

[edit] Genkernel Flags

[edit] Genkernel compiler flags

Genkernel supports the following flags which are passed to the relevant applications when your kernel is assembled:

  • --kernel-as=someAssembler: This specifies an assembler which would be used for compiling your kernel.
  • --kernel-cc=someCompiler: This specifies a compiler which would be used for compiling your kernel.
  • --kernel-ld=someLinker: This specifies a linker which would be used for compiling your kernel.
  • --kernel-make=someMake: This specifies an alternate GNU Make which would be used for compiling your kernel.
  • --utils-as=someAssembler: This specifies an assembler which would be used for compiling the support utilities.
  • --utils-cc=someCompiler: This specifies a compiler which would be used for compiling the support utilities.
  • --utils-ld=someLinker: This specifies a linker which would be used for compiling the support utilities.
  • --utils-make=someMake: This specifies an alternate GNU Make which would be used for compiling the support utilities.
  • --makeopts=-jJobs: This specifies the flags which would be passed to GNU Make when the kernel and utilities are being compiled.

[edit] Genkernel kernel flags

Genkernel supports the following flags, some of which have --no-option equivalents that influence kernel compilation:

  • --callback="echo Hello": This routine calls the specified arguments after the kernel and the relevant modules have been built; but before the initrd has been built. This is useful where you might want external modules installed to the initrd by emerging the relevant item using the callback and then redefinining a Genkernel module group.
  • --no-clean: This runs or does not run make clean before compiling your kernel. This causes all object files and dependencies to be removed.
  • --no-mrproper: This runs or does not run make mrproper before compiling your kernel. This causes all object files, dependencies and your configuration to be removed.
  • --kerneldir=/path/to/sources: This specifies an alternative kernel source location, instead of the default location of /usr/src/linux.
  • --kernel-config=/path/to/config-file: This specifies an alternative kernel configuration which would be used; rather than the inpersistant /path/to/sources/.config which is used by default.
  • --no-splash: Activates [or deactivates] support for Fbsplash support in the genkernel-built initrd image. The Fbsplash utility is intended to be a replacement for bootsplash, and is designed for use with 2.6.x series kernels. To override the default theme used by Fbsplash, use --splash=PreferredTheme (where PreferredTheme is the title of one of the directories inside the /etc/splash/ directory.
  • --splash-res=PreferredResolution: This flag allows you to select which splash screen resolutions will be supported in the initrd during the start-up of the system. This is useful for two reasons: First, you are able to select only the splash screen resolution(s) relevant to your system. Second, you avoid the unnecessary increase in the disk space required by initrd (since the initrd does not have to support resolutions that are irrelevant for your system configuration.) However, you may want to omit this flag if the kernel is being compiled for an Installation CD; this allows Fbsplash support for all possible resolutions.
  • --no-menuconfig: This runs or does not run the kernel menu-based configurator before building your kernel, after make oldconfig has run.
  • --no-initrdmodules: This doesn't copy any modules to the initrd which genkernel creates.
  • --no-install: This installs or does not install your kernel, modules, and initrd once the compilation has finished.
  • --udev: This compile kernel with support for udev. (deprecated and no longer necesary as udev is on by default genkernel v3.4.0)

[edit] Genkernel miscellaneous flags

Genkernel also supports some miscellaneous flags which do not fit into the other two categories:

  • --arch-override=someArch: This flag can be used to override what architecture genkernel thinks you're on, if the auto-detection mechanism fails (please file a bug if it does!) or if you wish to cross-compile a kernel.
  • --busybox-config=/path/to/busybox-config: This overrides the default busybox configuration with the specified file
  • --busybox-bin=/path/to/busybox-binary.tar.bz2: Using this option means that a busybox binary would not be compiled, and the specified tarball would be used. Note that busybox must be compiled statically!
  • --minkernpackage=/output/to/yourkernel.tar.bz2: This flag outputs a tarball of the kernel, named as kernel and the initrd named as initrd to the specified file. No path information or modules will be includes in the tarball.

[edit] Using Genkernel

Most people look down on genkernel for taking all the fun out of installing Gentoo and/or your kernel. In reality genkernel can be quite helpful. For example after updating to the most current sources

emerge gentoo-sources

and installing genkernel

emerge genkernel

You can run the following genkernel command.

genkernel --install --menuconfig all

This will tell genkernel to let you use menuconfig, so you can now configure your kernel yourself, but genkernel will do all of the compiling and installing for you (except for your menu.lst, you still have to edit that yourself)! Menuconfig of course is not your only option here, you can also use

  • oldconfig
  • xconfig
  • gconfig

but make sure that you have the proper dependencies for "x" and "g" config.

If you would like, you can of course let genkernel do it all for you, then you would simply issue

genkernel --install all

The downside to this is that you may have a more bloated, slower kernel, than if you configured it yourself. This option will almost guarantee you a working kernel however.

[edit] disclaimer

This was essentially copied from http://www.gentoo.org/doc/en/genkernel.xml when I followed a link to "genkernel" which didn't exist - *gasp*. Anyway, I don't have time to finish it right now, so if anyone wants to, they can ,copy from "Genkernel Usage: Running Genkernel" down to the end. I'm planning on going back over this page and personalizing it to the wiki, as opposed to just being a page that could say "go here!"

Stagecrew 13:02, 21 Sep 2004 (GMT)
Personal tools