Ubuntu download the source code and compile

This article describes how to download Linux source code under Ubunt, and a simple compilation step.

1, download the linux source

First view corresponds to the corresponding version of Ubuntu source

$ sudo apt-cache search linux-source

View source version of Ubuntu related information

$ uname -a

Use command to download the source code corresponding to the user working directory and extract

$ sudo apt-get install linux-source-4.15.0

Mounted directly download the corresponding source code will be downloaded to the / usr / src directory, unzip the source to the user directory

$ cd /usr/src
$ sudo tar -xvjf linux-source-4.15.0.tar.bz2 -C /home/hly/study/

Because decompression time borrowed root privileges to decompress it, therefore, necessary to modify the permissions in the code files for the user

$ sudo chown hly:hly –R linux-source-4.15.0

Command line hly: hly user is given permission, before a group name, a user name after the parameter -R indicates that all files in the directory traversal

2, to compile the source code

First some kernel configuration

$ cd ~/studu/linux-source-4.15.0
$ make menuconfig

The following error occurred after the command to run, due to the lack of ncurses-devel

 

Depending on the error prompts to install ncurses-devel

$ sudo apt-get install ncurses-dev

Re-run the configuration command invokes the configuration menu, as shown below

 

After completing the above configuration, select <Load> .config button to save the file, and save

Run command to compile the kernel image

$ make bzImage

The following error message appears, follow the prompts to resolve

 

Solutions are as follows

$ sudo apt-get install libelf-dev
$ sudo apt-get install libssl-dev

Compile command input terminal returns proceed compilation, compiled as follows

 

After compiling the command completes, you will get uncompressed kernel image and the kernel vmlinux System.map symbol table files in the root directory of the Linux source code in arch / x86 / boot directory will be the kernel image bzImage.

Guess you like

Origin www.cnblogs.com/Cqlismy/p/11358657.html