Reference resources :

《 Bird brother Linux Private dishes 》 The first 26 Chapter

http://hi.baidu.com/wg_wang/item/f9375c2f00ca75c0ee10f1db

http://www.linuxdiyf.com/bbs/thread-193762-1-1.html

Environmental Science :

Wind7 host +Debian6 virtual machine , Virtual machine software is VirtualBox

First step 、 download Linux Source code

First you need to look at the current Linux Version used

pengdl@debian:~$ uname -r

2.6.32-5-686

You can see , Currently in use Linux The kernel version is :2.6.32.5

To illustrate , We also download it from the Internet linux-2.6.32.5( Of course, you can also download the latest version , But there are risks ). The download address is as follows :

ftp://ftp.kernel.org/pub/linux/kernel/v2.6/

I downloaded it :linux-2.6.32.5.tar.xz

The second step 、 decompression Linux kernel

In the future, unzip the kernel source code to /usr/src/kernels Next

mkdir -p /usr/src/kernels

 

tar -xJf linux-2.6.32.5.tar.xz -C /usr/src/kernels/

The third step 、 compile Linux kernel

Clean up the rubbish :

cd /usr/src/kernels/linux-2.6.32.5

make mrproper

make clean

Before you compile the kernel, you need to configure , To illustrate , Direct the configuration of the machine config-2.6.32-5-686 Copy it to the directory you just unzipped ( If you download a newer kernel , We need to compare config-2.6.32-5-686 I have configured ), And rename to .config

cp     /boot/config-2.6.32-5-686     /usr/src/kernels/linux-2.6.32.5/.config

cd   /usr/src/kernels/linux-2.6.32.5

make menucongfig

modify General setup Internal Local version by pengdl, The aim is to prevent the execution of make install and make modules_install It's a conflict with the old .

make bzImage  -j4

make modules  -j4

make modules_install

make install

Make initrd Mirror image

mkinitramfs     2.6.32.5pengdl   -o    /boot/initrd.img-2.6.32.5pengdl

among 2.6.32.5pengdl It's the end of execution make modules_install after , stay /lib/modules Next, the newly generated folder

here /lib/modules and /boot The following is what follows ( It has 686 What's important is that the system has existed before , belt pengdl It's our new generation ,

One of the reasons is that .old Final document , Because it was executed twice make install, In fact, one execution is enough . Manual will *.old Delete ):

debian:/usr/src/kernels/linux-2.6.32.5# ls /lib/modules/

2.6.32-5-686 2.6.32.5pengdl

debian:/usr/src/kernels/linux-2.6.32.5# ls /boot/

config-2.6.32-5-686 System.map-2.6.32-5-686

config-2.6.32.5pengdl System.map-2.6.32.5pengdl

config-2.6.32.5pengdl.old System.map-2.6.32.5pengdl.old

grub vmlinuz-2.6.32-5-686

initrd.img-2.6.32-5-686 vmlinuz-2.6.32.5pengdl

initrd.img-2.6.32.5pengdl vmlinuz-2.6.32.5pengdl.old

debian:/usr/src/kernels/linux-2.6.32.5# 

Step four 、 to update grub

grub-mkconfig >/boot/grub/grub.cfg

Take a look at the newly generated grub.cfg The content of :

#

# DO NOT EDIT THIS FILE

#

# It is automatically generated by grub-mkconfig using templates

# from /etc/grub.d and settings from /etc/default/grub

#

 

### BEGIN /etc/grub.d/00_header ###

if [ -s $prefix/grubenv ]; then

 load_env

fi

set default="2"

if [ "${prev_saved_entry}" ]; then

 set saved_entry="${prev_saved_entry}"

 save_env saved_entry

 set prev_saved_entry=

 save_env prev_saved_entry

 set boot_once=true

fi

 

function savedefault {

 if [ -z "${boot_once}" ]; then

 saved_entry="${chosen}"

 save_env saved_entry

 fi

}

 

function load_video {

 insmod vbe

 insmod vga

 insmod video_bochs

 insmod video_cirrus

}

 

insmod part_msdos

insmod ext2

set root='(hd1,msdos5)'

search --no-floppy --fs-uuid --set 87115ddc-75d2-4f74-b8c4-e3796e6a244a

if loadfont /share/grub/unicode.pf2 ; then

 set gfxmode=640x480

 load_video

 insmod gfxterm

fi

terminal_output gfxterm

insmod part_msdos

insmod ext2

set root='(hd0,msdos1)'

search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

set locale_dir=($root)/boot/grub/locale

set lang=en

insmod gettext

set timeout=5

### END /etc/grub.d/00_header ###

 

### BEGIN /etc/grub.d/05_debian_theme ###

insmod part_msdos

insmod ext2

set root='(hd1,msdos5)'

search --no-floppy --fs-uuid --set 87115ddc-75d2-4f74-b8c4-e3796e6a244a

insmod png

if background_image /share/images/desktop-base/spacefun-grub.png; then

 set color_normal=light-gray/black

 set color_highlight=white/black

else

 set menu_color_normal=cyan/blue

 set menu_color_highlight=white/blue

fi

### END /etc/grub.d/05_debian_theme ###

 

### BEGIN /etc/grub.d/10_linux ###

menuentry 'Debian GNU/Linux, with Linux 2.6.32.5pengdl' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32.5pengdl ...'

 linux /boot/vmlinuz-2.6.32.5pengdl root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro quiet

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32.5pengdl

}

menuentry 'Debian GNU/Linux, with Linux 2.6.32.5pengdl (recovery mode)' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32.5pengdl ...'

 linux /boot/vmlinuz-2.6.32.5pengdl root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro single 

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32.5pengdl

}

menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-686' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32-5-686 ...'

 linux /boot/vmlinuz-2.6.32-5-686 root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro quiet

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32-5-686

}

menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-686 (recovery mode)' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32-5-686 ...'

 linux /boot/vmlinuz-2.6.32-5-686 root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro single 

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32-5-686

}

### END /etc/grub.d/10_linux ###

 

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

 

### BEGIN /etc/grub.d/30_os-prober ###

### END /etc/grub.d/30_os-prober ###

 

### BEGIN /etc/grub.d/40_custom ###

# This file provides an easy way to add custom menu entries. Simply type the

# menu entries you want to add after this comment. Be careful not to change

# the 'exec tail' line above.

### END /etc/grub.d/40_custom ###

 

### BEGIN /etc/grub.d/41_custom ###

if [ -f $prefix/custom.cfg ]; then

 source $prefix/custom.cfg;

fi

### END /etc/grub.d/41_custom ###

We've got our new kernel :

### BEGIN /etc/grub.d/10_linux ###

Found linux image: /boot/vmlinuz-2.6.32.5pengdl

Found initrd image: /boot/initrd.img-2.6.32.5pengdl

menuentry 'Debian GNU/Linux, with Linux 2.6.32.5pengdl' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32.5pengdl ...'

 linux /boot/vmlinuz-2.6.32.5pengdl root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro quiet

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32.5pengdl

}

menuentry 'Debian GNU/Linux, with Linux 2.6.32.5pengdl (recovery mode)' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32.5pengdl ...'

 linux /boot/vmlinuz-2.6.32.5pengdl root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro single 

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32.5pengdl

}

menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-686' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32-5-686 ...'

 linux /boot/vmlinuz-2.6.32-5-686 root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro quiet

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32-5-686

}

menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-686 (recovery mode)' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32-5-686 ...'

 linux /boot/vmlinuz-2.6.32-5-686 root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro single 

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32-5-686

}

### END /etc/grub.d/10_linux ###

If you follow the above configuration , Startup time ,Linux 2.6.32.5pengdl I'll put it first , If you don't press the up and down buttons manually to select , Then the kernel we just compiled will be started , How to make the system boot the old kernel by default ? There are several ways :

1、 Manually modify grub.conf, Swap the location of the old kernel and the new kernel :

### BEGIN /etc/grub.d/10_linux ###

menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-686' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32-5-686 ...'

 linux /boot/vmlinuz-2.6.32-5-686 root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro quiet

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32-5-686

}

menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-686 (recovery mode)' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32-5-686 ...'

 linux /boot/vmlinuz-2.6.32-5-686 root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro single 

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32-5-686

}

 

menuentry 'Debian GNU/Linux, with Linux 2.6.32.5pengdl' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32.5pengdl ...'

 linux /boot/vmlinuz-2.6.32.5pengdl root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro quiet

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32.5pengdl

}

menuentry 'Debian GNU/Linux, with Linux 2.6.32.5pengdl (recovery mode)' --class debian --class gnu-linux --class gnu --class os {

 insmod part_msdos

 insmod ext2

 set root='(hd0,msdos1)'

 search --no-floppy --fs-uuid --set 2c7658ba-7c5c-45f2-8117-d70fcadcdda6

 echo 'Loading Linux 2.6.32.5pengdl ...'

 linux /boot/vmlinuz-2.6.32.5pengdl root=UUID=2c7658ba-7c5c-45f2-8117-d70fcadcdda6 ro single 

 echo 'Loading initial ramdisk ...'

 initrd /boot/initrd.img-2.6.32.5pengdl

}

### END /etc/grub.d/10_linux ###

2、 perhaps , modify set default="0"  , take 0 Change it to 2. Change it right here , If you update it again grub.conf,default The value of is changed to 0, Among them in grub.conf The top part of gives the method :

#

# DO NOT EDIT THIS FILE

#

# It is automatically generated by grub-mkconfig using templates

# from /etc/grub.d and settings from /etc/default/grub

#

We should revise /etc/default/grub This file , take GRUB_DEFAULT=0 Change it to GRUB_DEFAULT=2, Then execute again

grub-mkconfig >/boot/grub/grub.cfg

Here's the Startup Test :( You can use the up and down arrows to select the kernel that has booting )

Be careful :

Because I use VirtualBox virtual machine , After updating the kernel , Need to be reinstalled VirtualBox Enhancement tool , For the installation method of the enhancement tool, see :

http://www.cnblogs.com/pengdonglin137/p/3366765.html#a8

When you install the enhancement tool , Will delete the enhancement tool installed last time .

End !!

compile Debian More articles on kernel source code

  1. Android System —- Write a simple driver and compile it into the kernel source code 【 turn 】

    Reprinted from : A great god Through a previous article , We get it  Android Medium Binder Mechanism and remote service invocation   This article mainly introduces Android The principle of the application in calling some system services , So let's continue to introduce ...

  2. How to compile separately Linux The driver in kernel source code is loadable module ?

    answer : Divided into two steps : 1. Configure a driver as a module ( Such as : CONFIG_RTC_XXX=m) 2. Specify the path and compile , Such as compiling drivers/rtc The drive in make SUBDIRS=drivers/rtc m ...

  3. 【 turn 】 compile Android System source code and kernel source code

    Original website :http://blog.csdn.net/jiangwei0910410003/article/details/37988637 I haven't written for a long time blog 了 , The reason why I didn't write , It's mainly about work , ...

  4. FW compile Android System source code and kernel source code

    compile Android System source code and kernel source code classification : Android2014-07-21 20:58 7287 Human reading   Comment on (28)  Collection   report I haven't written for a long time blog 了 , The reason why I didn't write , It's mainly about work , Find out ...

  5. Android Source code and kernel source code download , Compile and execute

    According to Luo Shengyang's opinion <Android System source situation analysis > A Book , Try downloading , Compile and execute Android Source code and kernel source code . But it could be the software source " Quilt wall " Or the reason for the version number update . During this period, I met many questions ...

  6. compile Android System source code and kernel source code

    [ date :2016-01-11] source :Linux Community   author :jiangwei [ typeface : Big   in   Small ]     Compile me before Android Record the process of system source code and kernel source code , Because this process really benefits a lot , see ...

  7. Reprint :Linux Have a craigslist : How to be in Debian or Ubuntu Install the complete kernel source code on

    http://linux.cn/article-5015-1.html problem : I need to work for my Debian or Ubuntu Download and install the complete tree structure kernel source code for compiling a custom kernel . So in Debian or Ubunt ...

  8. 【 turn 】 How to download and compile Android4.0 Kernel source code goldfish( Image & Text )

    Original website :http://blog.csdn.net/flydream0/article/details/7070392 About how to download Android4.0 Source code , Please check out another post in my blog ( It's also a graphic tutorial ...

  9. Linux Kernel analysis ( One )---linux System introduction | Introduction to kernel source code | Kernel configuration, compilation and installation

    original text :Linux Kernel analysis ( One )---linux System introduction | Introduction to kernel source code | Kernel configuration, compilation and installation Linux Kernel analysis ( One ) Starting from this blog post, I'll talk about linux Kernel for learning and Analysis , The whole process is bound to be very difficult , But I'll stick to it ...

Random recommendation

  1. Action mobile game real time PVP Frame synchronization scheme ( client )

    1. summary 1.1. be based on UDP A new frame synchronization scheme is proposed In terms of technology selection , The reason for choosing the frame synchronization scheme , stay Kevin An introduction to PVP The background implementation of frame synchronization has been described in detail , Here is a brief summary : High consistency . If the input of each frame is synchronized ...

  2. Robot Framework-DatabaseLibrary database (MySql)

    Robot Framework-Mac Version installed Robot Framework-Windows Version installed Robot Framework- Tool introduction and introduction to use Robot Framework-Databa ...

  3. log4j: Different classes use different logs

    Sometimes you need to use a separate log file in some functions , The following is a code example . public final static String LOGGER_NAME = "MyFunction"; priva ...

  4. 【 turn 】Entity Systems

    “Favour composition over inheritance” If you haven’t already read my previous post on the problems o ...

  5. First time to know Asp.Net Built in objects Server object

    Server object Server Object defines an object that is based on Web The classes associated with the server provide access to methods and properties on the server , Used to access resources on the server . Server Common properties of objects attribute   MarhineName Get server ...

  6. EasyUI - Background management system - increase , Delete , modify

    effect : html Code : <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ad ...

  7. LeetCode OJ 122. Best Time to Buy and Sell Stock II

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  8. Laboratory Building -1-Hello world!

    I'm new to the laboratory building , I decided to practice on it . Course 1 : print "Hello world" On the virtual desktop , Open the terminal Xfce, By running linux Instructions , newly build c file , Editing , Ed ...

  9. Record opencv The build process

    Ready to learn opencv, After consulting several web pages, I finally finished . Editor and opencv Select the latest version for all versions . The recording process is as follows 1. Download ready : 1)         Opencv Source code , Download address : https://sour ...

  10. Java One of the collection frameworks :ArrayList Source code analysis

    Copyright notice : This article is an original blog article , Reprint please indicate the source , Welcome to exchange and study ! ArrayList The bottom layer maintains a dynamic array , Every ArrayList Each instance has a capacity . This capacity refers to the size of the array used to store list elements . It's always at least equal to ...