Difference between revisions of "Kernel configuration"

From LFScript
(Add instructions for cross-architecture configuring and upgrading old configurations.)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
[[Category:Documentation]]
 
Configuring your kernel is something that is often overlooked by new LFScript users. However, it is very important that you create a configuration file. It often makes the difference between a usable system and one that only gives you a kernel panic.
 
Configuring your kernel is something that is often overlooked by new LFScript users. However, it is very important that you create a configuration file. It often makes the difference between a usable system and one that only gives you a kernel panic.
  
Line 22: Line 23:
 
<pre>make mrproper</pre>
 
<pre>make mrproper</pre>
  
Next, create a default configuration. This is not strictly necessary, but it gives you a basis to build your own configuration on:
+
Next, create a default configuration. This gives you a basis to build your own configuration on. You can create kernel configurations for other CPU's than you are currently using by supplying the '''ARCH=<TYPE>''' option:
  
<pre>make defconfig</pre>
+
<pre>make ARCH=x86_64 defconfig</pre>
 +
 
 +
or
 +
 
 +
<pre>make ARCH=i386 defconfig</pre>
 +
 
 +
If you already have a configuration file from an earlier build, you can upgrade it in stead of starting from scratch. Replace '''x86_64''' in the next command with your target architecture:
 +
 
 +
<pre>cp -v <LOCATION OF OLD CONFIG> .config
 +
make ARCH=x86_64 oldconfig</pre>
  
 
The kernel source comes with a configuration tool included called <code>menuconfig</code>. Menuconfig has an ncurses based text user interface, which allows easy selection of the features you like to include in your kernel.
 
The kernel source comes with a configuration tool included called <code>menuconfig</code>. Menuconfig has an ncurses based text user interface, which allows easy selection of the features you like to include in your kernel.
Line 32: Line 42:
 
<pre>sudo apt-get install ncurses-dev</pre>
 
<pre>sudo apt-get install ncurses-dev</pre>
  
Then, start the configuration tool:
+
Then, start the configuration tool. Replace '''x86_64''' in the next command with your target architecture:
  
<pre>make menuconfig</pre>
+
<pre>make ARCH=x86_64 menuconfig</pre>
  
 
You can navigate the menu using the up and down keys, pressing enter to enter a submenu.
 
You can navigate the menu using the up and down keys, pressing enter to enter a submenu.
Line 79: Line 89:
  
 
<pre>cd ../../
 
<pre>cd ../../
rm -rf sources/linux-3.*/</pre>
+
rm&nbsp;-rf sources/linux-3.*/</pre>
  
 
== Using your configuration with LFScript ==
 
== Using your configuration with LFScript ==

Latest revision as of 11:28, 29 June 2014

Configuring your kernel is something that is often overlooked by new LFScript users. However, it is very important that you create a configuration file. It often makes the difference between a usable system and one that only gives you a kernel panic.

Downloading the kernel source

LFScript is capable of downloading all source code you need, automatically. The Linux kernel is part of the basic LFS system, which means that the next command will also download the kernel source for you:

./lfscript -BS

All source code is saved to the sources directory.

cd sources

Configuring the kernel

Extract your kernel source, and enter the source directory:

tar xf linux-3.*.tar.bz2
cd linux-3.*

It is recommended that you clean the source tree first:

make mrproper

Next, create a default configuration. This gives you a basis to build your own configuration on. You can create kernel configurations for other CPU's than you are currently using by supplying the ARCH=<TYPE> option:

make ARCH=x86_64 defconfig

or

make ARCH=i386 defconfig

If you already have a configuration file from an earlier build, you can upgrade it in stead of starting from scratch. Replace x86_64 in the next command with your target architecture:

cp -v <LOCATION OF OLD CONFIG> .config
make ARCH=x86_64 oldconfig

The kernel source comes with a configuration tool included called menuconfig. Menuconfig has an ncurses based text user interface, which allows easy selection of the features you like to include in your kernel.

If your host system does not have the ncurses development package installed, the command may fail. On Ubuntu, for example you may need to run the next command, prior to make menuconfig:

sudo apt-get install ncurses-dev

Then, start the configuration tool. Replace x86_64 in the next command with your target architecture:

make ARCH=x86_64 menuconfig

You can navigate the menu using the up and down keys, pressing enter to enter a submenu.

To select an option to include in the kernel, press Y. The option should become prefixed with a checked box: [*].

Important things to include

Recent development versions of LFS require you to include support for devtmpfs:

Device Drivers --->
  Generic Driver Options --->
     Maintain a devtmpfs filesystem to mount at /dev

You should also be sure to include support for the file systems you want to use when you install your system:

File systems --->
  Second extended fs support
  Ext3 journalling file system support
  The Extended 4 (ext4) filesystem

If you want to build a Live CD of your system, you also need SquashFS support:

File systems --->
  Miscellaneous filesystems --->
    SquashFS 4.0 - Squashed file system support --->
      Include support for ZLIB compressed file systems
      Include support for LZO compressed file systems
      Include support for XZ compressed file systems

fsOS Live CD

In the fsos folder in LFScript, there is a text file called kernel.features. It contains a complete list of everything selected for the fsOS Live CD.

Saving your configuration

When you quit the configuration tool, it will ask you if you want to save your configuration; Choose "yes".

Next, move the configuration file out of the kernel source:

cp -v .config ../../my_kernel.config

You don't need the kernel source tree any more, so remove it:

cd ../../
rm -rf sources/linux-3.*/

Using your configuration with LFScript

You can present your configuration to LFScript with the -k switch:

./lfscript <options> -k my_kernel.config

The following command will rebuild your kernel, this may be useful if you have changed your configuration file:

./lfscript -BU kernel -k my_kernel.config