After reading the book "Run Linux Kernel", I feel that the examples behind the memory management part are good.
I just want to try and experience the example (I have always felt like this)
nasri@ubuntu:/usr/local$ apt-cache search linux-source
linux-source - Linux kernel source with Ubuntu patches
linux-source-3.13.0 - Linux kernel source for version 3.13.0 with Ubuntu patches
nasri@ubuntu:/usr/local$ apt-get install linux-source-3.13.0
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
nasri@ubuntu:/usr/local$ sudo apt-get install linux-source-3.13.0
[sudo] password for nasri:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
kernel-package libqt3-dev
The following NEW packages will be installed:
linux-source-3.13.0
0 upgraded, 1 newly installed, 0 to remove and 51 not upgraded.
Need to get 97.5 MB of archives.
After this operation, 113 MB of additional disk space will be used.
.....
apt-cache search linux-source//获取当前内核源码版本
sudo apt-get install linux-source-3.13.0//获取内核源码
In fact, there is the kernel source code under /user/src
I am here on ubuntu system
There are 2 source codes under /user/src
nasri@ubuntu:/$ ls /usr/src/
linux-headers-4.4.0-142 linux-source-3.13.0
linux-headers-4.4.0-142-generic linux-source-3.13.0.tar.bz2
nasri@ubuntu:/$
linux-headers-4.4.0-142和linux-headers-4.4.0-142-generic
Which one are you currently using? Use the uname -a command to see if the generic one is used
nasri@ubuntu:/usr/src/linux-headers-4.4.0-142$ uname -a
Linux ubuntu 4.4.0-142-generic #168~14.04.1-Ubuntu SMP Sat Jan 19 11:26:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
nasri@ubuntu:/usr/src/linux-headers-4.4.0-142$
But we found that the one we were downloading was linux-source-3.13.0. What does this have to do with linux-headers?
I do not know. . . I now ask in the forum
I copy the compressed package under /user/src to my local work directory
cp /usr/src/linux-source-3.13.0_nasri/linux-source-3.13.0.tar.bz2 .
Unzip:
tar -xjvf linux-source-3.13.0.tar.bz2
Switch to this directory:
nasri@ubuntu:~/Work/linux-source-3.13.0$
Wait to compile the kernel and install the necessary software:
sudo apt-get install libncurses5-dev libssl-dev
sudo apt-get install build-essential openssl
sudo apt-get install zlibc minizip
sudo apt-get install libidn11-dev libidn11
This is the software I needed to compile the 4.16 kernel that I found online. I tried it here, but I couldn’t find minizip, so I won’t install it temporarily.
Wait until the compilation is time to solve the problem
Execute the following three commands in sequence:
sudo make mrproper
sudo make clean
sudo make menuconfig
Among them, mrproper is to clear all intermediate files generated during the compilation process, and clean is to clear the last compiled intermediate files. After the selected graphical interface appears in menuconfig, directly press the right arrow key to select exit to exit, and select save in the exit prompt , To achieve the default configuration of the kernel .
Excuting an order:
sudo make –j8
The kernel compilation begins, wait slowly.
sudo make zImage
This should be useless
make modules
make modules_install
make install
Also modify the startup file
nasri@ubuntu:~$ sudo vim /etc/default/grub
[sudo] password for nasri:
nasri@ubuntu:~$
nasri@ubuntu:~$
nasri@ubuntu:~$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-142-generic
Found initrd image: /boot/initrd.img-4.4.0-142-generic
Found linux image: /boot/vmlinuz-3.13.11-ckt39
Found initrd image: /boot/initrd.img-3.13.11-ckt39
Found linux image: /boot/vmlinuz-3.13.11-ckt39.old
Found initrd image: /boot/initrd.img-3.13.11-ckt39
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
nasri@ubuntu:~$ sudo reboot
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=1
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US"
Remove the second line here. After restarting, select the second one and then you can select the kernel version you need to use
Here 1 is the first level menu, 3 is the second level menu, "1(space)> (space) 3"
GRUB_DEFAULT="1 > 3"
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US"
Here is an introduction to explain this 1> 2 secondary menu https://www.cnblogs.com/open-skill/p/8295234.html
Restart and try
Successfully replaced the original kernel after restart
Use unmae -a to see that the kernel is already 3.13 kernel
Then change GRUB_TIMEOUT to 0
Or uncomment GRUB_HIDDEN_TIMEOUT=0
Well, the kernel compiled by myself replaces the original kernel.