Difference between pages "Building a Kernel from Source" and "Funtoo Linux Kernels"

From Funtoo
(Difference between pages)
Jump to: navigation, search
(Kernel Sources)
 
(openvz-rhel6-stable --> {{Package|sys-kernel/openvz-rhel6-stable}})
 
Line 1: Line 1:
Setting up a proper kernel yourself - lean, mean and tailored to your hardware,  is the challenge by which a linux user can graduate to becoming a Funtoo knight ;-)
+
This Section will give you an overview of kernels used in funtoo.
  
Even though many of us are using enterprise-ready kernels in datacenters, there is almost nobody who hasn't at least considered building a kernel for his laptop / PC.
+
Funtoo Linux provides a number of new kernels for your use. This is the official page for all Funtoo Linux kernel information.  
We are showing here how an intermediate Linux user can use an alternative to the standard beginners "genkernel" approach,  to compile a custom kernel,  in a relatively speedy and easy set up.
+
  
== Minimum Requirements ==
+
Some points of interest:
* '''Understand the command line'''
+
* '''Know where the kernel files are located'''
+
  
== Assumptions ==
+
* Most Funtoo Linux kernels support the handy <tt>[[#Binary USE|binary]]</tt> USE flag, described below.
You start from an installed Funtoo system on the disk, or at least, you are on stage3 in a chrooted environment from a live cd, following somehow the Funto [[Installation (Tutorial)|Installation Tutorial]].
+
* Funtoo Linux offers quality kernels from other Linux Distributions, like <tt>ubuntu-server</tt> and <tt>debian-sources</tt>.
 +
* A detailed [[#Kernel Features and Stability|Kernel Features and Stability]] table can be found below.
 +
* Advanced users may want to take a look at [[Additional Kernel Resources]].
 +
* There is a quick'n dirty howto to compile your own [[kernel]] with initramfs the funtoo way.
  
In this case we are building a kernel that is booting root in LVM over encrypted LUKS container.
+
== Overview of Kernels ==
If you don't have this setup, don't worry, you just don't need all the modules, but everything else is similar.
+
  
 +
=== sysrescue-std-sources --> {{Package|sys-kernel/sysrescue-std-sources}} ===
  
== Getting ready to start ==
+
This kernel is from the [http://www.sysresccd.org SystemRescueCD project], and is based on Fedora 14/15, plus some other patches related to booting from a live CD. It is a quality kernel, and is generally pretty stable. It is not suitable for production servers but is a good choice for Funtoo Linux desktops. Earlier,the [[Funtoo Linux Installation]] Guide recommended this kernel for general users, but now 'debian-sources' is recommended. Note however,  that by design all audio functions are removed from SystemRescue,  ie no sound when using this kernel.
  
First there is the decision which linux kernel sources we need.
+
=== vanilla-sources --> {{Package|sys-kernel/vanilla-sources}} ===
There are plenty of them in the repositories around, often it is not easy to distinguish between them.
+
  
I would always trust my distribution of choice and take what is has to offer - and funtoo has a lot to offer!
+
This will install the "vanilla" (unmodified) Linux kernel sources. Current recommended version is 3.x. Funtoo Linux fully supports Linux 3.x. The advantages of this kernel include recent improvements to [[Linux Containers]], a very modern networking stack with lots of bug fixes, and high reliability for desktops and servers. The downside is that this kernel must be manually configured by the user and does not have built-in <tt>genkernel</tt> support via the <tt>binary</tt> USE flag at this time.
  
I really do recommend (especially if it is your first time) to build a debian-sourced genkernel like described in chapter 5 "Using Debian-Sources with Genkernel" in the [[Funtoo_Linux_Kernels| Funtoo Kernels Tutorial]].
+
=== gentoo-sources --> {{Package|sys-kernel/gentoo-sources}} ===
  
From there you should have a running system booting nicely from your own build (just little bit bloated) kernel. This is more than you can expect from any other ready to go distribution.
+
This kernel tree is based on stable kernels from [https://www.kernel.org/ kernel.org] with genpatches applied [http://dev.gentoo.org/~mpagano/genpatches/about.htm genpatches].
 +
Gentoo patchset aims to support the entire range of Gentoo-supported architectures. List of available genpatched kernels: [http://dev.gentoo.org/~mpagano/genpatches/kernels.htm genpatches-kernels]
  
{{Note}} We are using RedHat's dracut in order to build a nice initramfs (containing all the necessary tools and extra drivers our kernel might need to start the system). Although dracut is the way to go, more sophisticated and not as buggy as gentoo's genkernel approach, more and more funtoo geeks start using slashbeast's better-initramfs, which we will cover at the end of this howto! So after having set up a genkernel from debian or gentoo sources we are going to build a kernel with either (or both) dracut or/and better-initramfs. So gentoo sources with genkernel is always my backup if anything is not working correctly on my system. For the slightly more geeky approach with my own initram I am using pf-sources, ck-sources or any other more or less heavily patched sources.
+
=== openvz-rhel6-stable --> {{Package|sys-kernel/openvz-rhel6-stable}} ===
  
Let's go!
+
This is a RHEL6-based kernel with OpenVZ support. This kernel is now the preferred kernel for production OpenVZ deployments. It requires gcc-4.4.5 to build, which it will use automatically without the user needing to use <code>gcc-config</code>. We use this version of <code>gcc</code> since this is the version of <code>gcc</code> used by Red Hat to build this kernel.
  
== Kernel Sources ==
+
=== openvz-rhel5-stable --> {{Package|sys-kernel/openvz-rhel5-stable}} ===
The source you use on your system is up to you. For a laptop or desktop system, the following are recommended:
+
* '''{{Package|sys-kernel/pf-sources}}'''
+
* '''{{Package|sys-kernel/ck-sources}}'''
+
* '''{{Package|sys-kernel/gentoo-sources}}'''
+
* '''{{Package|sys-kernel/git-sources}}'''
+
* '''{{Package|sys-kernel/sysrescue-std-sources}}'''
+
* '''{{Package|sys-kernel/debian-sources}}'''
+
{{Note}} If you are unsure for now, use sys-kernel/gentoo-sources. That's always a safe bet for a general system.
+
  
== Prerequisites ==
+
This kernel is based on the latest Red Hat Enterprise Linux 5.6 kernel, and contains additional OpenVZ (virtual containers) patches from the [[OpenVZ on Funtoo Linux|OpenVZ]] project. It is a very stable and reliable kernel, and is recommended for use in production environments. The only major downside to this kernel is that it is based on Linux 2.6.18 -- some parts of the kernel are out-of-date, and it is not compatible with modern versions of udev. However, it is pretty trivial to downgrade udev to an earlier version on Funtoo Linux and this kernel has a track-record of being rock-solid. When stability is paramount, you put up with the udev downgrade, use this kernel, and can enjoy hundreds of days of uptime. For more information on how to use this kernel with Funtoo Linux, see the [[RHEL5 Kernel HOWTO]].
  
I don't know which tools you have already installed, so some information here might be redundant.
+
=== ubuntu-server --> {{Package|sys-kernel/ubuntu-server}} ===
It doesn't harm to just copy and paste and do some steps again.
+
  
First, we look into our <code>/etc/make.conf</code>:
+
This is the kernel from Ubuntu Server. Version <tt>2.6.32.32.62</tt> is the same version used in Ubuntu Server 10.04 LTS, and version <tt>2.6.35.28.50</tt> is the one used in Ubuntu Server 10.10 (currently masked). In our testing of <tt>2.6.32.32.62</tt>, it has been very reliable and offers very good performance. One exception, which is common among 2.6.32-based kernels, is that it's recommended that you emerge <tt>broadcom-netxtreme2</tt> if you have any Broadcom-based NICs, as the in-kernel drivers have compatibility issues with certain models. This kernel is a very good option if you want a relatively modern server kernel and do not need [[OpenVZ]] support. We use gcc-4.4.5 to build this kernel. It will use gcc-4.4.5 automatically, without requiring the user to use <tt>gcc-config</tt>.
  
<console>
+
=== debian-sources --> {{Package|sys-kernel/debian-sources}} ===
###i## nano /etc/make.conf
+
#These compiler flags are just tweaking (optimazation) and NOT necessary:
+
CFLAGS="-O2 -pipe -march=native -ftracer -fforce-addr"
+
CXXFLAGS="${CFLAGS} -fpermissive -fomit-frame-pointer"
+
KDIR=/usr/src/linux
+
KERNEL="symlink build"
+
USE="$KERNEL ....here are your use flags...."
+
## These modules are available:
+
## DRACUT_MODULES="dracut_modules_biosdevname dracut_modules_btrfs dracut_modules_caps dracut_modules_crypt dracut_modules_crypt-gpg dracut_modules_dmraid dracut_modules_dmsquash-live dracut_modules_gensplash dracut_modules_iscsi dracut_modules_livenet dracut_modules_lvm dracut_modules_mdraid dracut_modules_multipath dracut_modules_nbd dracut_modules_nfs dracut_modules_plymouth dracut_modules_ssh-client dracut_modules_syslog"
+
## We will use these modules for LVM / LUKS:
+
DRACUT_MODULES="crypt lvm plymouth biosdevname dmraid crypt-gpg dmsquash-live ssh-client syslog"
+
</console>
+
  
Next, we set the package keywords:
+
This is the Debian kernel. '''These ebuilds now support the <tt>binary</tt> USE flag.''' Daniel has added a special <tt>config-extract</tt> command which can be used to list all available official Debian kernel configurations, and generate them from the Debian files included with the kernel. This kernel has optional [[OpenVZ]] support, but it is much better to use <tt>openvz-rhel6-stable</tt> if you want a production-quality OpenVZ installation. For more information about how to use <tt>debian-sources</tt> and <tt>config-extract</tt>, see [[#Using Debian-Sources with Genkernel|Using debian-sources with Genkernel]] below.
<console>
+
###i## nano /etc/portage/package.use/dracut
+
sys-kernel/dracut dm net device-mapper crypt lvm
+
</console>
+
  
{{Note}} If you don't have lvm over encrypted LUKS you probably just add the "net" keyword here, or "selinux".
+
=== debian-sources-lts --> {{Package|sys-kernel/debian-sources-lts}} ===
  
 +
This is the Debian long-term stable kernel. '''These ebuilds now support the <tt>binary</tt> USE flag.''' Daniel has added a special <tt>config-extract</tt> command which can be used to list all available official Debian kernel configurations, and generate them from the Debian files included with the kernel.
  
After that we are going to build our packages:
+
== Binary USE ==
<console>
+
###i## emerge -av app-portage/gentoolkit sys-kernel/pf-sources sys-kernel/dracut sys-boot/plymouth sys-boot/plymouth-openrc-plugin
+
</console>
+
  
Finished? Well, then let's go on and
+
Many of the kernel ebuilds in Funtoo Linux support the very useful <tt>binary</tt> USE flag. By enabling this USE flag and emerging the kernel, the ebuild will automatically build a binary kernel image, initramfs and kernel modules and install them to <tt>/boot</tt>. The binary kernel image and initramfs can be used to boot your Funtoo Linux system without requiring any additional configuration. This is a great way to get a Funtoo Linux system up and running quickly. Here's how to do it:
  
== Preparing the kernel ==
 
 
We go now to the sources directory and enter the following commands to update the kernel's  .config  file:
 
<console>
 
###i## cd /usr/src/linux/
 
###i## make clean
 
  CLEAN  .
 
  CLEAN  arch/x86/kernel/acpi/realmode
 
  CLEAN  arch/x86/kernel/cpu
 
  CLEAN  arch/x86/kernel
 
  CLEAN  arch/x86/vdso
 
  CLEAN  arch/x86/lib
 
  CLEAN  drivers/gpu/drm/radeon
 
  CLEAN  drivers/net/wan
 
  CLEAN  drivers/scsi/aic7xxx
 
  CLEAN  drivers/tty/vt
 
  CLEAN  drivers/video/logo
 
  CLEAN  firmware
 
  CLEAN  kernel
 
  CLEAN  lib/raid6
 
  CLEAN  lib
 
  CLEAN  security/apparmor
 
  CLEAN  security/selinux
 
  CLEAN  usr
 
  CLEAN  arch/x86/boot/compressed
 
  CLEAN  arch/x86/boot
 
  CLEAN  .tmp_versions
 
  CLEAN  vmlinux System.map .tmp_kallsyms2.S .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms1.S .tmp_vmlinux1 .tmp_vmlinux2 .tmp_System.map
 
###i## zcat /proc/config.gz > /usr/src/linux/.config
 
</console>
 
<br>
 
 
<console>
 
<console>
###i## make localmodconfig
+
# ##i##echo "sys-kernel/openvz-rhel5-stable binary" >> /etc/portage/package.use
 +
# ##i##emerge openvz-rhel5-stable
 +
# ##i##nano -w /etc/boot.conf
 +
# ##i##boot-update
 
</console>
 
</console>
  
You will get some questions which you can answer mostly with either M (compiled as a module) or Y (compiled directly into the kernel).
+
More information can be found in the [[Funtoo Linux Installation]] Guide.
<pre>
+
Enable different security models (SECURITY) [Y/n/?] y
+
Enable the securityfs filesystem (SECURITYFS) [Y/?] y
+
Socket and Networking Security Hooks (SECURITY_NETWORK) [Y/?] y
+
Security hooks for pathname based access control (SECURITY_PATH) [Y/?] y
+
Low address space for LSM to protect from user allocation (LSM_MMAP_MIN_ADDR) [65536] 65536
+
NSA SELinux Support (SECURITY_SELINUX) [Y/n/?] y
+
  NSA SELinux boot parameter (SECURITY_SELINUX_BOOTPARAM) [N/y/?] n
+
  NSA SELinux runtime disable (SECURITY_SELINUX_DISABLE) [N/y/?] n
+
  NSA SELinux Development Support (SECURITY_SELINUX_DEVELOP) [Y/n/?] y
+
  NSA SELinux AVC Statistics (SECURITY_SELINUX_AVC_STATS) [Y/n/?] y
+
  NSA SELinux checkreqprot default value (SECURITY_SELINUX_CHECKREQPROT_VALUE) [1] 1
+
  NSA SELinux maximum supported policy format version (SECURITY_SELINUX_POLICYDB_VERSION_MAX) [Y/n/?] y
+
    NSA SELinux maximum supported policy format version value (SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE) [19] 19
+
TOMOYO Linux Support (SECURITY_TOMOYO) [Y/n/?] y
+
  Default maximal count for learning mode (SECURITY_TOMOYO_MAX_ACCEPT_ENTRY) [2048] 2048
+
  Default maximal count for audit log (SECURITY_TOMOYO_MAX_AUDIT_LOG) [1024] 1024
+
  Activate without calling userspace policy loader. (SECURITY_TOMOYO_OMIT_USERSPACE_LOADER) [Y/n/?] y
+
AppArmor support (SECURITY_APPARMOR) [Y/n/?] y
+
  AppArmor boot parameter default value (SECURITY_APPARMOR_BOOTPARAM_VALUE) [1] 1
+
Integrity Measurement Architecture(IMA) (IMA) [Y/n/?] y
+
EVM support (EVM) [N/y/?] (NEW)
+
Default security module
+
  1. SELinux (DEFAULT_SECURITY_SELINUX)
+
  2. TOMOYO (DEFAULT_SECURITY_TOMOYO)
+
  3. AppArmor (DEFAULT_SECURITY_APPARMOR)
+
> 4. Unix Discretionary Access Controls (DEFAULT_SECURITY_DAC)
+
choice[1-4?]: 4
+
warning: (ACPI_HOTPLUG_CPU) selects ACPI_CONTAINER which has unmet direct dependencies (ACPI && EXPERIMENTAL)
+
warning: (MEDIA_TUNER) selects MEDIA_TUNER_TEA5761 which has unmet direct dependencies (MEDIA_SUPPORT && VIDEO_MEDIA && I2C && EXPERIMENTAL)
+
#
+
# configuration written to .config
+
#
+
warning: (GFS2_FS) selects DLM which has unmet direct dependencies (EXPERIMENTAL && INET && SYSFS && CONFIGFS_FS && (IPV6 || IPV6=n))
+
warning: (IMA) selects TCG_TPM which has unmet direct dependencies (HAS_IOMEM && EXPERIMENTAL)
+
warning: (MEDIA_TUNER) selects MEDIA_TUNER_TEA5761 which has unmet direct dependencies (MEDIA_SUPPORT && VIDEO_MEDIA && I2C && EXPERIMENTAL)
+
warning: (ACPI_HOTPLUG_CPU) selects ACPI_CONTAINER which has unmet direct dependencies (ACPI && EXPERIMENTAL)
+
root@[~src/linux] #
+
  
</pre>
+
== Funtoo Linux Genkernel ==
  
Now comes the most adventurous part!
+
Funtoo Linux contains a forked/enhanced version of genkernel with the following new capabilities:
  
== Building the Kernel ==
+
* genkernel can use a build directory that is separate from the kernel source directory. This is enabled using the new <tt>--build-dst</tt> option.
<console>
+
* <tt>--build-src</tt> is a new option that is equivalent to the <tt>--kerneldir</tt> option.
###i## make -j8  bzImage
+
* <tt>--fullname</tt> can be used to specify the entire name of the kernel and initramfs images -- everything after <tt>kernel-</tt> and <tt>initramfs-</tt>.
###i## make -j8 modules
+
* <tt>--firmware-src</tt> - a new option that works identically to <tt>--firmware-dir</tt>.
###i## make modules_install
+
* <tt>--firmware-dst</tt> - a new capability - you can now define where genkernel installs firmware.
###i## make install
+
* Genkernel uses Funtoo Linux <tt>lvm2</tt> rather than building its own.
</console>
+
* Some compile fixes.
  
 +
== Kernel Features and Stability ==
  
=== Initramfs, or not? ===
+
This page provides an overview of kernel features and stability information:
  
The reason to build a kernel with an initramfs is mostly for interoperability (e.g. live-cd's) and special features like an included busybox, ssh, etc. But mostly, and that's why we are doing this here now, to have a proper kernel up and running quick'n dirty in a reasonable time without fighting hours and days until a more or less exotic hardware is perfectly run by the kernel.  
+
{| {{table}}
After having a proper basic kernel running with the help of an initramfs, I really recommend you to go a step further and build a true kernel with all features includes without an initramfs. But this could be pain in the ass and very time consuming - so we do it the funtoo way here - at least in the second example when we stick to better-initramfs instead of Red-Hat's ''dracut''.
+
!Kernel Name
 +
!Version
 +
!USE flags
 +
!Stability
 +
!Extra Features
 +
!Req'd udev
 +
!Notes
 +
|-
 +
|<tt>[[#vanilla-sources|vanilla-sources]]</tt>
 +
|3.12.6
 +
|N/A
 +
|'''Excellent''' - recommended for desktops and servers.
 +
|N/A
 +
|Any
 +
|Recommended for modern networking stack, hardware and [[Linux Containers]] support. This kernel must be manually configured by the user. New Features: [http://kernelnewbies.org/Linux_3.12 kernelnewbies.org/linux_3.12]  New Drivers: [http://kernelnewbies.org/Linux_3.12-DriversArch kernelnewbies/Linux_3.12-DriversArch]
 +
|-
 +
|<tt>[[#gentoo-sources|gentoo-sources]]</tt>
 +
|3.12.6
 +
|N/A
 +
|'''Excellent''' - recommended for desktops and workstations
 +
|N/A
 +
|Any
 +
|Recommended for modern networking stack, hardware and [[Linux Containers]] support. This kernel must be manually configured by the user. New Features: [http://kernelnewbies.org/Linux_3.12 kernelnewbies.org/linux_3.12]  New Drivers: [http://kernelnewbies.org/Linux_3.12-DriversArch kernelnewbies/Linux_3.12-DriversArch]
 +
|-
 +
|<tt>[[#sysrescue-std-sources|sysrescue-std-sources]]</tt>
 +
|3.0.21.302
 +
|<tt>binary</tt>
 +
|''Good'' - recommended for desktops
 +
|N/A
 +
|Any
 +
|Nvidia card users: binary use flag installs nouveau drivers. Not compatible with nvidia-drivers.
 +
|-
 +
|<tt>[[#openvz-rhel6-stable|openvz-rhel6-stable]]</tt>
 +
|2.6.32.042.079.5
 +
|<tt>binary</tt>
 +
|'''Excellent''' - recommended for production servers
 +
|N/A
 +
|Any
 +
|This kernel is built with gcc-4.4.5. <tt>emerge broadcom-netxtreme2</tt> for reliable BCM5709+ support (integrated NIC)
 +
|-
 +
|<tt>[[#openvz-rhel5-stable|openvz-rhel5-stable]]</tt>
 +
|2.6.18.028.095.1
 +
|<tt>binary</tt>
 +
|'''Excellent''' - recommended for production servers
 +
|OpenVZ
 +
|=sys-fs/udev-146*
 +
|Broadcom <tt>bnx2</tt> driver module bundled with kernel appears to be OK. This kernel is built with gcc-4.1.2. Enabling the <tt>binary</tt> USE flag will cause gcc-4.1.2 to be emerged and used for building the kernel.
 +
|-
 +
|<tt>[[#ubuntu-server|ubuntu-server]]</tt>
 +
|2.6.32.32.62
 +
|<tt>binary</tt>
 +
|'''Excellent''' - recommended for production servers (still in extended testing)
 +
| N/A
 +
|Any
 +
|This kernel is built with gcc-4.4.5. <tt>emerge broadcom-netxtreme2</tt> for reliable BCM5709+ support (integrated NIC)
 +
|-
 +
|<tt>[[#ubuntu-server|ubuntu-server]]</tt>
 +
|2.6.35.28.50
 +
|<tt>binary</tt>
 +
|''not yet tested''
 +
| N/A
 +
|Any
 +
|This kernel is built with gcc-4.4.5. <tt>emerge broadcom-netxtreme2</tt> for reliable BCM5709+ support (integrated NIC)
 +
|-
 +
|<tt>[[#debian-sources|debian-sources]]</tt>
 +
|3.12.3
 +
|<tt>openvz</tt>
 +
|''Good'' - default kernel recommended by Funtoo
 +
|OpenVZ (optional)
 +
|Any
 +
|See [[#Using debian-sources with Genkernel]], below.
 +
|-
 +
|}
  
== Option one: Initrd with dracut ==
+
== Using Debian-Sources with Genkernel ==
  
To build the initrd, we just execute:
+
{{ fancyimportant|Debian-sources is now fully compatible with ''binary'' USE flag and recommended for desktop users. The below example is valid for manual installation. At least 12G of /var/tmp required to build  
<console>
+
}}
# ##i##dracut -f --fstab --xz /boot/initramfs-3.2.6-pf.img  3.2.6-pf
+
This section describes how to build a binary kernel with <tt>debian-sources</tt> and <tt>genkernel</tt>, and it also explains how to use Funtoo Linux's <tt>config-extract</tt> tool to list and create official Debian kernel configurations.
</console>
+
  
Generally, this really should be enough!
+
=== First step: emerging the required packages ===
If you experience booting problems like missing modules / drivers then just boot from the genkernel section and fix the initrd building. You can look into the man page to tweak the command a bit (e.g. --add-drivers "xz dm_crypt" etc...).
+
  
Ok let's go on and finish the taks, we are going to tell now grub how to boot off correctly!
+
The first step is to emerge:
  
<console>
+
# The Debian sources
###i## nano /etc/boot.conf
+
# Genkernel itself
  
boot {
+
This is achieved with:
        generate grub
+
        default "Funtoo Linux dracut"
+
        timeout 3
+
}
+
  
"Funtoo Linux genkernel" {
+
<console>
        kernel kernel-genkernel[-v]
+
# ##i##emerge sys-kernel/debian-sources sys-kernel/genkernel
        initrd initramfs-genkernel[-v]
+
</console>
        params = quiet rootfstype=ext4
+
        params += luks enc_root=/dev/sda3
+
        params += lvm root=/dev/mapper/vg-root
+
}
+
  
"Funtoo Linux dracut" {
+
Once the Debian kernel sources are deployed, you should find a directory named '''linux-debian-''version''''' (e.g. linux-debian-2.6.32.30) under '''/usr/src'''. Update your the '''linux''' symlink to point on this directory:
        kernel vmlinuz[-v]
+
<console>
## this is the better-initramfs generated initrd
+
# ##i##cd /usr/src
        initrd initramfs[-v].img
+
# ##i##rm linux
        params  = quiet rootfstype=ext4
+
# ##i##ln -s linux-debian-2.6.32.30 linux
        params += luks enc_root=/dev/sda3
+
        params += lvm root=/dev/mapper/vg-root
+
}
+
 
</console>
 
</console>
 +
Alternatively, emerge the debian-sources with USE="symlink"
  
That's it almost!
+
=== Second step: Grabbing a configuration file ===
  
Now write to the <code>grub.cfg</code> with the new handy boot-update script from funtoo:
+
If is now time to download the kernel configuration file. For this tutorial we will use a configuration file for AMD64 (several others architectures like MIPS or SPARC64 are available.)  To view a complete list of available kernel configurations, type <tt>./config-extract -l</tt> in the Debian kernel source directory:
<console>
+
###i## boot-update -v
+
  
boot-update 1.5.2 / Copyright 2009-2011 Funtoo Technologies
+
<pre>
 +
ninja1 linux-debian-2.6.32.30 # ./config-extract -l
  
[use option "-l" for license info, "-h" for help]
+
====== standard featureset ======
  
* Generating config for grub...
+
      alpha: alpha-generic, alpha-legacy, alpha-smp
 +
      amd64
 +
      armel: iop32x, ixp4xx, kirkwood, orion5x, versatile
 +
        hppa: parisc, parisc-smp, parisc64, parisc64-smp
 +
        i386: 486, 686, 686-bigmem, amd64
 +
        ia64: itanium, mckinley
 +
        m68k: amiga, atari, bvme6000, mac, mvme147, mvme16x
 +
        mips: 4kc-malta, 5kc-malta, r4k-ip22, r5k-ip32, sb1-bcm91250a, sb1a-bcm91480b
 +
      mipsel: 4kc-malta, 5kc-malta, r5k-cobalt, sb1-bcm91250a, sb1a-bcm91480b
 +
    powerpc: powerpc, powerpc-smp, powerpc64
 +
        s390: s390x, s390x-tape
 +
        sh4: sh7751r, sh7785lcr
 +
      sparc: sparc64, sparc64-smp
 +
    sparc64: sparc64, sparc64-smp
  
DEFAULT > Funtoo Linux - vmlinuz-3.2.6-pf
+
====== vserver featureset ======
          Funtoo Linux genkernel - kernel-genkernel-x86_64-3.2.6-pf
+
  
* Completed successfully.
+
      amd64
</console>
+
        i386: 686, 686-bigmem
 +
        ia64: itanium, mckinley
 +
    powerpc: powerpc, powerpc64
 +
        s390
 +
      sparc
 +
    sparc64
  
Okay,... here you go..! :)
+
====== xen featureset ======
  
Reboot and see how it works!
+
      amd64
 +
        i386
  
= Option two: using better-initramfs =
+
====== openvz featureset ======
  
Piotr's better-initramfs is another approach that is tiny, nice and shiny and seems to become more and more a favourite among funtoo'ers. The biggest plus is that, once built it is kernel version independant.
+
      amd64
 
+
        i386
For using this you just do the following steps:
+
<pre>
+
1. download sources
+
2. build kernel with "make bzImage"
+
3. download better-initramfs
+
4. run better-initramfs
+
5. adjust /etc/boot.conf
+
 
</pre>
 
</pre>
  
Here is how in detail:
+
Type <tt>config-extract -h</tt> for extended usage information:
  
Assuming you did install already a genkernel backup or at least you have a working bzImage + modules installed, we rush forward to step 3:
+
<pre>
 +
ninja1 linux-debian-2.6.32.30 # ./config-extract -h
 +
This work is free software.
  
=== Downloading Better-initramfs ===
+
Copyright 2011 Funtoo Technologies. You can redistribute and/or modify it under
 +
the terms of the GNU General Public License version 3 as published by the Free
 +
Software Foundation. Alternatively you may (at your option) use any other
 +
license that has been publicly approved for use with this program by Funtoo
 +
Technologies (or its successors, if any.)
  
<console>
+
usage: config-extract [options] arch [featureset] [subarch]
###i## cd /usr/src/;
+
###i## git clone https://github.com/slashbeast/better-initramfs.git
+
###i## /src #  cd better-initramfs
+
###i## better-initramfs git:(master) ls
+
AUTHORS    LICENSE  README.rst  bootstrap  output  sourceroot
+
ChangeLog  Makefile  TODO        examples  scripts
+
</console>
+
  
=== Build Better-Initramfs ===
+
  -h  --help        print this usage and exit
<console>
+
  ---list        list all available kernel configurations
###i## better-initramfs git:(master) sudo bootstrap/bootstrap-all
+
  -o  --outfile    specify kernel config outfile --
###i## sudo make prepare
+
                    defaults to .config in current directory
###i## sudo make image
+
  [featureset]      defaults to "none" if not specified
###i## sudo mv output/initramfs.cpio.gz /boot
+
  [subarch]        defaults to the only one available; otherwise required
</console>
+
  
=== adjust grub ===
+
This program was written by Daniel Robbins for Funtoo Linux, for the purpose of
 +
easily and conveniently extracting Debian kernel configurations. To see a nice
 +
list of all available kernel configurations, use the --list option.
  
Taking the above setup we edit the /etc/boot.conf
+
Debian's kernel configs are specified internally in arch_featureset_flavor
as I installed genkernel first, and dracut after - you see this setup:
+
format, such as: "amd64_openvz_amd64". The featureset typically describes an
 +
optional kernel configuration such as "xen" or "openvz", while the flavor in
 +
Debian terminology typically refers to the sub-architecture of the CPU.
  
<pre>
+
When using this command, you must specify an arch. A featureset of "none" is
boot {
+
assumed unless you specify one, and by default this program will pick the only
        generate grub
+
available subarch if there is only one to choose from. If not, you will need to
        default "Funtoo Linux"
+
pick one (and the program will remind you to do this.)
        timeout 3
+
}
+
  
# Rootfs over lvm over luks
+
The kernel configuration will be written to ".config" in the current directory,
# /dev/sda3 - encrypted lvm's pv
+
or the location you specified using the -o/--outfile option.
# /dev/mapper/vg-root - rootfs's lv
+
</pre>
  
"Funtoo Linux" {
+
Let's use <tt>config-extract</tt> to create a kernel configuration for an amd64 system:
        kernel bzImage[-v]
+
## this is the better-initramfs generated initrd
+
        initrd initramfs.cpio.gz
+
        params  = quiet rootfstype=ext4
+
        params += luks enc_root=/dev/sda3
+
        params += lvm root=/dev/mapper/vg-root
+
}
+
  
"Funtoo Linux dracut" {
+
<console>
        kernel vmlinuz[-v]
+
# ##i##cd linux
## this is the dracut generated initrd
+
# ##i##./config-extract amd64
        initrd initramfs[-v].img
+
Wrote amd64_none_amd64 kernel configuration to /usr/src/linux-debian-2.6.32.30/.config.
        params  = quiet rootfstype=ext4
+
</console>
        params += luks enc_root=/dev/sda3
+
        params += lvm root=/dev/mapper/vg-root
+
}
+
  
 
+
<tt>config-extract</tt> also allows you to extract special Debian featuresets, such as settings for Xen and [[OpenVZ]] kernels:
"Funtoo Linux genkernel" {
+
        kernel kernel-genkernel[-v]
+
        initrd initramfs-genkernel[-v]
+
        params = quiet rootfstype=ext4
+
        params += luks enc_root=/dev/sda3
+
        params += lvm root=/dev/mapper/vg-root
+
}
+
</pre>
+
Okay,... here you go..! :)
+
 
+
update the grub.cfg, then reboot and see how it works!
+
  
 
<console>
 
<console>
root@[~src/linux-3.2.6-pf] # boot-update -v   
+
# ##i##./config-extract amd64 openvz
 +
Wrote amd64_openvz_amd64 kernel configuration to /usr/src/linux-debian-2.6.32.30/.config.
 +
</console>
  
boot-update 1.5.2 / Copyright 2009-2011 Funtoo Technologies
+
'''It is necessary to name the kernel configuration file something other than ".config" to avoid errors with genkernel.'''
  
[use option "-l" for license info, "-h" for help]
 
  
* Generating config for grub...
+
After using <tt>config-extract</tt>, run <tt>make oldconfig</tt> and accept all default options by hitting Enter at all prompts.
  
DEFAULT > Funtoo Linux better-initramfs - vmlinuz-3.2.6-pf
+
=== Third step: Building and installing the kernel ===
          Funtoo Linux dracut - vmlinuz-3.2.6-pf
+
          Funtoo Linux genkernel - kernel-genkernel-x86_64-3.2.6-ck
+
  
* Completed successfully.
+
This is simply achieved by:
  
root@[~src/linux-3.2.6-pf] #
+
<console>
 +
# ##i##genkernel --kernel-config=config-2.6.32-5-amd64 all
 +
</console>
  
root@[~src/linux-3.2.6-pf] # reboot
+
* --kernel-config: use the given configfile. If you only give a filename here, it is searched for in your current working dir. You can also use a relative or an absolute path leading to your configfile here (for example: "--kernel-config=/usr/src/linux/configfile").
 +
* all: rebuild the kernel image and the initramfs ramdisk image (aside of kernel modules, the ramdisk image contains tools such as BusyBox and some generic startup scripts, depending on options you use on the command line several additional tools like lvm or raid volume management can be incorporated as well).
  
System going down for reboot!
+
{{ fancyimportant|Unless explicitly stated via ''--no-clean'' or ''--no-mrproper'', Genkernel will do a '''make mrproper''' in the kernel source tree, thus cleaning a previous build '''and removing the previous kernel configuration file''' in it.
 +
}}
  
</console>
+
If you use Genkernel to rebuild a Linux kernel on SPARC64, remember to either:
 +
* Set '''sparc64-unknown-linux-gnu-''' in ''General setup --> Cross-compiler tool prefix''
 +
* Put '''--kernel-cross-compile=sparc64-unknown-linux-gnu-''' on the Genkernel command line
  
 +
Once the kernel has been compiled and the ram disk has been generated, the kernel image plus its companion files (initramfs image and System.map) are placed in the /boot directory. You can use your favourite tool to update your bootloader configuration files.
  
[[Category:HOWTO]]
+
[[Category:Internals]]
[[Category:Featured]]
+
[[Category:Funtoo features]]
 
[[Category:Kernel]]
 
[[Category:Kernel]]

Revision as of 02:09, 11 January 2014

This Section will give you an overview of kernels used in funtoo.

Funtoo Linux provides a number of new kernels for your use. This is the official page for all Funtoo Linux kernel information.

Some points of interest:

  • Most Funtoo Linux kernels support the handy binary USE flag, described below.
  • Funtoo Linux offers quality kernels from other Linux Distributions, like ubuntu-server and debian-sources.
  • A detailed Kernel Features and Stability table can be found below.
  • Advanced users may want to take a look at Additional Kernel Resources.
  • There is a quick'n dirty howto to compile your own kernel with initramfs the funtoo way.

Contents

Overview of Kernels

sysrescue-std-sources --> sys-kernel/sysrescue-std-sources

This kernel is from the SystemRescueCD project, and is based on Fedora 14/15, plus some other patches related to booting from a live CD. It is a quality kernel, and is generally pretty stable. It is not suitable for production servers but is a good choice for Funtoo Linux desktops. Earlier,the Funtoo Linux Installation Guide recommended this kernel for general users, but now 'debian-sources' is recommended. Note however, that by design all audio functions are removed from SystemRescue, ie no sound when using this kernel.

vanilla-sources --> sys-kernel/vanilla-sources

This will install the "vanilla" (unmodified) Linux kernel sources. Current recommended version is 3.x. Funtoo Linux fully supports Linux 3.x. The advantages of this kernel include recent improvements to Linux Containers, a very modern networking stack with lots of bug fixes, and high reliability for desktops and servers. The downside is that this kernel must be manually configured by the user and does not have built-in genkernel support via the binary USE flag at this time.

gentoo-sources --> sys-kernel/gentoo-sources

This kernel tree is based on stable kernels from kernel.org with genpatches applied genpatches. Gentoo patchset aims to support the entire range of Gentoo-supported architectures. List of available genpatched kernels: genpatches-kernels

openvz-rhel6-stable --> sys-kernel/openvz-rhel6-stable

This is a RHEL6-based kernel with OpenVZ support. This kernel is now the preferred kernel for production OpenVZ deployments. It requires gcc-4.4.5 to build, which it will use automatically without the user needing to use gcc-config. We use this version of gcc since this is the version of gcc used by Red Hat to build this kernel.

openvz-rhel5-stable --> sys-kernel/openvz-rhel5-stable

This kernel is based on the latest Red Hat Enterprise Linux 5.6 kernel, and contains additional OpenVZ (virtual containers) patches from the OpenVZ project. It is a very stable and reliable kernel, and is recommended for use in production environments. The only major downside to this kernel is that it is based on Linux 2.6.18 -- some parts of the kernel are out-of-date, and it is not compatible with modern versions of udev. However, it is pretty trivial to downgrade udev to an earlier version on Funtoo Linux and this kernel has a track-record of being rock-solid. When stability is paramount, you put up with the udev downgrade, use this kernel, and can enjoy hundreds of days of uptime. For more information on how to use this kernel with Funtoo Linux, see the RHEL5 Kernel HOWTO.

ubuntu-server --> sys-kernel/ubuntu-server

This is the kernel from Ubuntu Server. Version 2.6.32.32.62 is the same version used in Ubuntu Server 10.04 LTS, and version 2.6.35.28.50 is the one used in Ubuntu Server 10.10 (currently masked). In our testing of 2.6.32.32.62, it has been very reliable and offers very good performance. One exception, which is common among 2.6.32-based kernels, is that it's recommended that you emerge broadcom-netxtreme2 if you have any Broadcom-based NICs, as the in-kernel drivers have compatibility issues with certain models. This kernel is a very good option if you want a relatively modern server kernel and do not need OpenVZ support. We use gcc-4.4.5 to build this kernel. It will use gcc-4.4.5 automatically, without requiring the user to use gcc-config.

debian-sources --> sys-kernel/debian-sources

This is the Debian kernel. These ebuilds now support the binary USE flag. Daniel has added a special config-extract command which can be used to list all available official Debian kernel configurations, and generate them from the Debian files included with the kernel. This kernel has optional OpenVZ support, but it is much better to use openvz-rhel6-stable if you want a production-quality OpenVZ installation. For more information about how to use debian-sources and config-extract, see Using debian-sources with Genkernel below.

debian-sources-lts --> sys-kernel/debian-sources-lts

This is the Debian long-term stable kernel. These ebuilds now support the binary USE flag. Daniel has added a special config-extract command which can be used to list all available official Debian kernel configurations, and generate them from the Debian files included with the kernel.

Binary USE

Many of the kernel ebuilds in Funtoo Linux support the very useful binary USE flag. By enabling this USE flag and emerging the kernel, the ebuild will automatically build a binary kernel image, initramfs and kernel modules and install them to /boot. The binary kernel image and initramfs can be used to boot your Funtoo Linux system without requiring any additional configuration. This is a great way to get a Funtoo Linux system up and running quickly. Here's how to do it:

# echo "sys-kernel/openvz-rhel5-stable binary" >> /etc/portage/package.use
# emerge openvz-rhel5-stable
# nano -w /etc/boot.conf
# boot-update

More information can be found in the Funtoo Linux Installation Guide.

Funtoo Linux Genkernel

Funtoo Linux contains a forked/enhanced version of genkernel with the following new capabilities:

  • genkernel can use a build directory that is separate from the kernel source directory. This is enabled using the new --build-dst option.
  • --build-src is a new option that is equivalent to the --kerneldir option.
  • --fullname can be used to specify the entire name of the kernel and initramfs images -- everything after kernel- and initramfs-.
  • --firmware-src - a new option that works identically to --firmware-dir.
  • --firmware-dst - a new capability - you can now define where genkernel installs firmware.
  • Genkernel uses Funtoo Linux lvm2 rather than building its own.
  • Some compile fixes.

Kernel Features and Stability

This page provides an overview of kernel features and stability information:

Kernel Name Version USE flags Stability Extra Features Req'd udev Notes
vanilla-sources 3.12.6 N/A Excellent - recommended for desktops and servers. N/A Any Recommended for modern networking stack, hardware and Linux Containers support. This kernel must be manually configured by the user. New Features: kernelnewbies.org/linux_3.12 New Drivers: kernelnewbies/Linux_3.12-DriversArch
gentoo-sources 3.12.6 N/A Excellent - recommended for desktops and workstations N/A Any Recommended for modern networking stack, hardware and Linux Containers support. This kernel must be manually configured by the user. New Features: kernelnewbies.org/linux_3.12 New Drivers: kernelnewbies/Linux_3.12-DriversArch
sysrescue-std-sources 3.0.21.302 binary Good - recommended for desktops N/A Any Nvidia card users: binary use flag installs nouveau drivers. Not compatible with nvidia-drivers.
openvz-rhel6-stable 2.6.32.042.079.5 binary Excellent - recommended for production servers N/A Any This kernel is built with gcc-4.4.5. emerge broadcom-netxtreme2 for reliable BCM5709+ support (integrated NIC)
openvz-rhel5-stable 2.6.18.028.095.1 binary Excellent - recommended for production servers OpenVZ =sys-fs/udev-146* Broadcom bnx2 driver module bundled with kernel appears to be OK. This kernel is built with gcc-4.1.2. Enabling the binary USE flag will cause gcc-4.1.2 to be emerged and used for building the kernel.
ubuntu-server 2.6.32.32.62 binary Excellent - recommended for production servers (still in extended testing) N/A Any This kernel is built with gcc-4.4.5. emerge broadcom-netxtreme2 for reliable BCM5709+ support (integrated NIC)
ubuntu-server 2.6.35.28.50 binary not yet tested N/A Any This kernel is built with gcc-4.4.5. emerge broadcom-netxtreme2 for reliable BCM5709+ support (integrated NIC)
debian-sources 3.12.3 openvz Good - default kernel recommended by Funtoo OpenVZ (optional) Any See #Using debian-sources with Genkernel, below.

Using Debian-Sources with Genkernel

Important: Debian-sources is now fully compatible with binary USE flag and recommended for desktop users. The below example is valid for manual installation. At least 12G of /var/tmp required to build

This section describes how to build a binary kernel with debian-sources and genkernel, and it also explains how to use Funtoo Linux's config-extract tool to list and create official Debian kernel configurations.

First step: emerging the required packages

The first step is to emerge:

  1. The Debian sources
  2. Genkernel itself

This is achieved with:

# emerge sys-kernel/debian-sources sys-kernel/genkernel

Once the Debian kernel sources are deployed, you should find a directory named linux-debian-version (e.g. linux-debian-2.6.32.30) under /usr/src. Update your the linux symlink to point on this directory:

# cd /usr/src
# rm linux
# ln -s linux-debian-2.6.32.30 linux

Alternatively, emerge the debian-sources with USE="symlink"

Second step: Grabbing a configuration file

If is now time to download the kernel configuration file. For this tutorial we will use a configuration file for AMD64 (several others architectures like MIPS or SPARC64 are available.) To view a complete list of available kernel configurations, type ./config-extract -l in the Debian kernel source directory:

ninja1 linux-debian-2.6.32.30 # ./config-extract -l

====== standard featureset ======

       alpha: alpha-generic, alpha-legacy, alpha-smp
       amd64
       armel: iop32x, ixp4xx, kirkwood, orion5x, versatile
        hppa: parisc, parisc-smp, parisc64, parisc64-smp
        i386: 486, 686, 686-bigmem, amd64
        ia64: itanium, mckinley
        m68k: amiga, atari, bvme6000, mac, mvme147, mvme16x
        mips: 4kc-malta, 5kc-malta, r4k-ip22, r5k-ip32, sb1-bcm91250a, sb1a-bcm91480b
      mipsel: 4kc-malta, 5kc-malta, r5k-cobalt, sb1-bcm91250a, sb1a-bcm91480b
     powerpc: powerpc, powerpc-smp, powerpc64
        s390: s390x, s390x-tape
         sh4: sh7751r, sh7785lcr
       sparc: sparc64, sparc64-smp
     sparc64: sparc64, sparc64-smp

====== vserver featureset ======

       amd64
        i386: 686, 686-bigmem
        ia64: itanium, mckinley
     powerpc: powerpc, powerpc64
        s390
       sparc
     sparc64

====== xen featureset ======

       amd64
        i386

====== openvz featureset ======

       amd64
        i386

Type config-extract -h for extended usage information:

ninja1 linux-debian-2.6.32.30 # ./config-extract -h
This work is free software.

Copyright 2011 Funtoo Technologies. You can redistribute and/or modify it under
the terms of the GNU General Public License version 3 as published by the Free
Software Foundation. Alternatively you may (at your option) use any other
license that has been publicly approved for use with this program by Funtoo
Technologies (or its successors, if any.)

usage: config-extract [options] arch [featureset] [subarch]

  -h  --help        print this usage and exit
  -l  --list        list all available kernel configurations
  -o  --outfile     specify kernel config outfile --
                    defaults to .config in current directory
  [featureset]      defaults to "none" if not specified
  [subarch]         defaults to the only one available; otherwise required

This program was written by Daniel Robbins for Funtoo Linux, for the purpose of
easily and conveniently extracting Debian kernel configurations. To see a nice
list of all available kernel configurations, use the --list option.

Debian's kernel configs are specified internally in arch_featureset_flavor
format, such as: "amd64_openvz_amd64". The featureset typically describes an
optional kernel configuration such as "xen" or "openvz", while the flavor in
Debian terminology typically refers to the sub-architecture of the CPU.

When using this command, you must specify an arch. A featureset of "none" is
assumed unless you specify one, and by default this program will pick the only
available subarch if there is only one to choose from. If not, you will need to
pick one (and the program will remind you to do this.)

The kernel configuration will be written to ".config" in the current directory,
or the location you specified using the -o/--outfile option.

Let's use config-extract to create a kernel configuration for an amd64 system:

# cd linux
# ./config-extract amd64
Wrote amd64_none_amd64 kernel configuration to /usr/src/linux-debian-2.6.32.30/.config.

config-extract also allows you to extract special Debian featuresets, such as settings for Xen and OpenVZ kernels:

# ./config-extract amd64 openvz
Wrote amd64_openvz_amd64 kernel configuration to /usr/src/linux-debian-2.6.32.30/.config.

It is necessary to name the kernel configuration file something other than ".config" to avoid errors with genkernel.


After using config-extract, run make oldconfig and accept all default options by hitting Enter at all prompts.

Third step: Building and installing the kernel

This is simply achieved by:

# genkernel --kernel-config=config-2.6.32-5-amd64 all
  • --kernel-config: use the given configfile. If you only give a filename here, it is searched for in your current working dir. You can also use a relative or an absolute path leading to your configfile here (for example: "--kernel-config=/usr/src/linux/configfile").
  • all: rebuild the kernel image and the initramfs ramdisk image (aside of kernel modules, the ramdisk image contains tools such as BusyBox and some generic startup scripts, depending on options you use on the command line several additional tools like lvm or raid volume management can be incorporated as well).
Important: Unless explicitly stated via --no-clean or --no-mrproper, Genkernel will do a make mrproper in the kernel source tree, thus cleaning a previous build and removing the previous kernel configuration file in it.

If you use Genkernel to rebuild a Linux kernel on SPARC64, remember to either:

  • Set sparc64-unknown-linux-gnu- in General setup --> Cross-compiler tool prefix
  • Put --kernel-cross-compile=sparc64-unknown-linux-gnu- on the Genkernel command line

Once the kernel has been compiled and the ram disk has been generated, the kernel image plus its companion files (initramfs image and System.map) are placed in the /boot directory. You can use your favourite tool to update your bootloader configuration files.