Compile a Linux Kernel

How to Compile a Linux Kernel (YMMV) 1) determine current version: uname -r 3.16.7-21-desktop or: cat /proc/version (while interesting to see the use of files/process, this command would require additional filtering..., yet, you'll find info like this out there) Linux version 3.16.7-21-desktop (geeko@buildhost) (gcc version 4.8.3 20140627\ [gcc-4_8-branch revision 212064] (SUSE Linux) ) #1 SMP PREEMPT Tue Apr 14 07:11:37 UTC 2015 (93c1539) 2) go to kernel.org, find the latest stable version https://www.kernel.org/ https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.5.tar.xz - on the site as the latest https://www.kernel.org/pub/linux/kernel/v3.0/ - went down this branch 3) cd /usr/src 4) if there is an existing linux directory rename it to include the prior version 5) wget https://www.kernel.org/pub/linux/kernel/v3.0/ wget https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.18.28.tar.gz 6) unroll the source, -z for normal: tar xvzf linux.version.tar.gz tar xzf linux-3.18.28.tar.gz (drop the v for verbose) - unroll the source OPTION -j, --bzip2 with a bz2 extension: tar xvjf linux.version.tar.bz2 - NOTE: there are variations of tar and compression, YMMV. Note what the site recommends. 7) cd linux.version... cd linux-3.18.28 --> ls -FC linux-3.18.28 |grep / arch/ firmware/ kernel/ Module.symvers sound/ block/ fs/ lib/ net/ System.map COPYING include/ MAINTAINERS README tools/ CREDITS init/ Makefile REPORTING-BUGS usr/ crypto/ ipc/ mm/ samples/ virt/ Documentation/ Kbuild modules.builtin scripts/ vmlinux* drivers/ Kconfig modules.order security/ vmlinux.o arch - architecture crypto - DES, DES drivers - SATA, ethernet, wireless, etc. fs - file systems, ext4, FAT, NTFS net - netwokrign, ipv4, ipv6, tcp, 802.11 8) begin new kernel configuration: OPTION 1: make menuconfig using this version will result in a long Q&A session OPTION 2: alternate versions for "graphics" in a shell are: make qconfig | make xconfig | make gconfig OPTION 3: save current configuration as the default: sudo cp /boot/config-`uname -r` .config cat .config | wc -l 6597 cat .config # Automatically generated file; DO NOT EDIT. # Linux/x86_64 3.16.6 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y CONFIG_X86=y ... if you didn't change into the kernel directory before creating config and you type make gconfig, it'll say Stop. ------------------------------------------------ SuSE 13.2 --> luser@e7240-laptop [/usr/src] ------------------------------------------------ ------------------ --> sudo make gconfig make: *** No rule to make target 'gconfig'. Stop. ------------------------------------------------ SuSE 13.2 --> luser@e7240-laptop [/usr/src/linux-3.18.28] ------------------------------------------------ --> cd /usr/src/linux-3.18.28 --> sudo mv .config.old .config.older ;sudo mv .config .config.old ;sudo mv ../.config . ------------------ THEN, if you type make gconfig, but don't have the GTK+ installed: --> sudo make gconfig * * Unable to find the GTK+ installation. Please make sure that * the GTK+ 2.0 development package is correctly installed... * You need gtk+-2.0, glib-2.0 and libglade-2.0. * make[1]: *** No rule to make target 'scripts/kconfig/.tmp_gtkcheck', needed by 'scripts/kconfig/gconf.o'. Stop. Makefile:541: recipe for target 'gconfig' failed make: *** [gconfig] Error 2 ------------------ IF you try xconfig, but don't have QT4 installed... --> sudo make xconfig CHECK qt * Unable to find the QT4 tool qmake. Trying to use QT3 * * Unable to find any QT installation. Please make sure that * the QT4 or QT3 development package is correctly installed and * either qmake can be found or install pkg-config or set * the QTDIR environment variable to the correct location. * make[1]: *** No rule to make target 'scripts/kconfig/.tmp_qtcheck', needed by 'scripts/kconfig/qconf.o'. Stop. Makefile:541: recipe for target 'xconfig' failed make: *** [xconfig] Error 2 ------------------ so, you just keep it simple, SIMPLE ALWAYS WORKS (SAW): --> sudo make config scripts/kconfig/conf --oldaskconfig Kconfig * * Linux/x86 3.18.28 Kernel Configuration * 64-bit kernel (64BIT) [Y/n/?] Y * * General setup * Cross-compiler tool prefix (CROSS_COMPILE) [] 9) COMPILE THE KERNEL AND INSTALL This process takes a long time: compile the main kernel: make this will take 1 to 2 hours or longer. stores the kernel in binary form to arch/x86/boot/bzimage compile kernel modules: make modules_install this copies all the kernel modules (*.ko) to lib/modules//kernel/ install kernel: make install this copies the kernel from arch/x86/boot/bzImage to /boot and copies the .config file to /boot/config- and generates the System.map file or, run all from one line using double ampersands (&&) (can also use: "make -j" to fork separate processes, see man make) make && make modules_install && make install 10) make install may create the new kernel items in /boot: - vmlinuz-version... (kernel) - system-map-version... (system configuration for ramdisk) - initrd.img-version... (ram disk kernel) - config-version.... (kernel configuration) - ALSO updates grub.cfg but, if it doesn't (YMMV by distro), then create the new kernel by: mkinitrd -o intrd.img-3.18.28 or update-initramfs -c -k 3.18.28 11) make sure your boot loader is pointed to the new kernel, see /boot/grub2/grub.cfg update-grub 12)then, reboot, or init 6 --------- Alternate: Debian distros use one tool: make-kpkg (commands listed are from an older distro, YMMV) to install make-kpkg: sudo apt-get install kernel-package libncurses5-dev make-kpkg --initrd --append-to-version=-ramki kernel_image kernel_headers this creates two DEB files, install the Deb files: sudo dpkg -i kernel_image-ramki-i386.deb Script started on Sat Mar 12 19:51:41 2016 ------------------------------------------------ root@e7240-laptop [/usr/src] ------------------------------------------------ ####################################### ##### 1) determine current version: uname -r ####################################### --> uname -r 3.16.7-21-desktop ------------------------------------------------ root@e7240-laptop [/usr/src] ------------------------------------------------ ####################################### ##### 2) go to kernel.org, find the latest stable version (do some research, back things up) ##### 3) cd /usr/src ##### 4) - if there is an existing linux directory rename it to include the prior version ##### 5) wget http://kernel.org/version ######################################## wget https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.18.28.tar.gz --2016-03-12 19:51:58-- https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.18.28.tar.gz Resolving www.kernel.org (www.kernel.org)... 199.204.44.194, 198.145.20.140, 149.20.4.69, ... Connecting to www.kernel.org (www.kernel.org)|199.204.44.194|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 122392666 (117M) [application/x-gzip] Saving to: ‘linux-3.18.28.tar.gz’ linux-3.18.28.tar.gz 100%[===============================================>] 116.72M 10.4MB/s ina15ss 2016-03-12 19:52:13 (7.91 MB/s) - ‘linux-3.18.28.tar.gz’ saved [122392666/122392666] ------------------------------------------------ root@e7240-laptop [/usr/src] ------------------------------------------------ ######################################## ##### 6) unroll the source, -z for normal: tar xvzf linux.version.tar.gz ##### - unroll the source OPTION -j, --bzip2 with a bz2 extension: ##### tar xvjf linux.version.tar.bz2 ##### - NOTE: there are variations of tar and compression, YMMV. ##### Note what the site recommends. ######################################## --> tar xvzf linux-3.18.28.tar.gz linux-3.18.28/ linux-3.18.28/.gitignore (NOTE: skip "v" to save a lot of info on screen) ------------------------------------------------ root@e7240-laptop [/usr/src/linux-3.18.28] ------------------------------------------------ --> ll /usr/src/linux-3.18.28 total 596 -rw-rw-r-- 1 root root 18693 Mar 4 13:54 COPYING -rw-rw-r-- 1 root root 96089 Mar 4 13:54 CREDITS drwxrwxr-x 106 root root 12288 Mar 4 13:54 Documentation -rw-rw-r-- 1 root root 2536 Mar 4 13:54 Kbuild -rw-rw-r-- 1 root root 252 Mar 4 13:54 Kconfig -rw-rw-r-- 1 root root 292390 Mar 4 13:54 MAINTAINERS -rw-rw-r-- 1 root root 54432 Mar 4 13:54 Makefile -rw-rw-r-- 1 root root 18736 Mar 4 13:54 README -rw-rw-r-- 1 root root 7485 Mar 4 13:54 REPORTING-BUGS drwxrwxr-x 31 root root 4096 Mar 4 13:54 arch drwxrwxr-x 3 root root 4096 Mar 4 13:54 block drwxrwxr-x 4 root root 4096 Mar 4 13:54 crypto drwxrwxr-x 120 root root 4096 Mar 4 13:54 drivers drwxrwxr-x 36 root root 4096 Mar 4 13:54 firmware drwxrwxr-x 75 root root 4096 Mar 4 13:54 fs drwxrwxr-x 28 root root 4096 Mar 4 13:54 include drwxrwxr-x 2 root root 4096 Mar 4 13:54 init drwxrwxr-x 2 root root 4096 Mar 4 13:54 ipc drwxrwxr-x 15 root root 4096 Mar 4 13:54 kernel drwxrwxr-x 11 root root 12288 Mar 4 13:54 lib drwxrwxr-x 2 root root 4096 Mar 4 13:54 mm drwxrwxr-x 58 root root 4096 Mar 4 13:54 net drwxrwxr-x 13 root root 4096 Mar 4 13:54 samples drwxrwxr-x 13 root root 4096 Mar 4 13:54 scripts drwxrwxr-x 9 root root 4096 Mar 4 13:54 security drwxrwxr-x 22 root root 4096 Mar 4 13:54 sound drwxrwxr-x 19 root root 4096 Mar 4 13:54 tools drwxrwxr-x 2 root root 4096 Mar 4 13:54 usr drwxrwxr-x 3 root root 4096 Mar 4 13:54 virt ------------------------------------------------ --> ll /boot total 46804 -rw-r--r-- 1 root root 3003004 Apr 14 2015 System.map-3.16.7-21-desktop -rw-r--r-- 1 root root 3002010 Dec 17 2014 System.map-3.16.7-7-desktop -rw-r--r-- 1 root root 512 Nov 20 2014 backup_mbr lrwxrwxrwx 1 root root 1 Nov 20 2014 boot -> . -rw-r--r-- 1 root root 1484 Oct 21 2014 boot.readme -rw-r--r-- 1 root root 148309 Apr 14 2015 config-3.16.7-21-desktop -rw-r--r-- 1 root root 148308 Dec 17 2014 config-3.16.7-7-desktop drwxr-xr-x 2 root root 4096 Nov 27 2014 dracut drwxr-xr-x 2 root root 4096 Nov 20 2014 grub drwxr-xr-x 7 root root 4096 Aug 24 2015 grub2 lrwxrwxrwx 1 root root 24 Apr 22 2015 initrd -> initrd-3.16.7-21-desktop -rw-r--r-- 1 root root 7938496 Apr 22 2015 initrd-3.16.7-21-desktop -rw-r--r-- 1 root root 7888832 Apr 21 2015 initrd-3.16.7-7-desktop -rw-r--r-- 1 root root 424448 Oct 26 2014 message -rw-r--r-- 1 root root 309437 Apr 14 2015 symvers-3.16.7-21-desktop.gz -rw-r--r-- 1 root root 309458 Dec 17 2014 symvers-3.16.7-7-desktop.gz -rw-r--r-- 1 root root 516 Apr 14 2015 sysctl.conf-3.16.7-21-desktop -rw-r--r-- 1 root root 516 Dec 17 2014 sysctl.conf-3.16.7-7-desktop -rw-r--r-- 1 root root 6665656 Apr 14 2015 vmlinux-3.16.7-21-desktop.gz -rw-r--r-- 1 root root 6665774 Dec 17 2014 vmlinux-3.16.7-7-desktop.gz lrwxrwxrwx 1 root root 25 Apr 22 2015 vmlinuz -> vmlinuz-3.16.7-21-desktop -rw-r--r-- 1 root root 5682344 Apr 14 2015 vmlinuz-3.16.7-21-desktop -rw-r--r-- 1 root root 5682504 Dec 17 2014 vmlinuz-3.16.7-7-desktop ------------------------------------------------ cp /boot/config-3.16.7-21-desktop .config ------------------------------------------------ root@e7240-laptop [/usr/src/linux-3.18.28] ------------------------------------------------ --> make HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/zconf.lex.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf scripts/kconfig/conf --silentoldconfig Kconfig * * Restart config... * * * RCU Subsystem * RCU Implementation > 1. Preemptible tree-based hierarchical RCU (TREE_PREEMPT_RCU)
search for:
on the internet, or:
JohnMeister.com-fotos
LinuxMeister-Linux
BibleTech-
Bible overview


Wagoneers

FULL SIZE JEEPS

JeepMeister
"Jeep is America's
only real sports car."
-Enzo Ferrari


MeisterTech
Diesels +

One Page Overview

Intro to Linux


AMSOIL product guide,
or, AMSOIL web, or 1-800-956-5695,
use customer #283461

Amsoil dealer since 1983
purchase AMSOIL
at Midway Auto on SR9 in Snohomish,
or at Northland Diesel in Bellingham, WA


SJ - 1962-1991

XJ - 1984-2001

WJ - 1999-2004

KJ - 2002-2007

WK - 2005-2010

Find the recommended
AMSOIL synthetics
for your Jeep

CJ-10A - 1984-1986

Jeepsters

MJ - 1984-1992

Willys - 1946-1965

Other Jeeps (FC)