Centos 7.1 get kernel source code

Source: Internet
Author: User
Tags rpmbuild

Centos 7.1 get kernel source code

In centos 7.1, the default kernel source code path is/usr/src/uname -rBut it does not contain the source code. It only contains Kconfig and Makefile.

View system kernel version
Uname-r // view the system kernel cat/etc/redhat-release // operating system version

Output result kernel version: 3.10.0-229. el7.x86 _ 64 operating system version: CentOS Linux release 7.1.1503 (Core)

Download the corresponding version of the kernel source code package

Download address http://vault.centos.org/find the corresponding system version, enter for example: 7.1.1503 in the Web http://vault.centos.org/7.1.1503/updates/Source/SPackages/ download the corresponding version kernel source package: kernel-3.10.0-229.20.1.el7.src.rpm

Environment Configuration

1. First install (upgrade) Some Dependent packages

 sudo yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed pesign xmltosudo yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-develsudo yum install ncurses-devel newt-devel numactl-devel pciutils-devel python-devel zlib-devel bison

2. Create a directory tree for source code compilation.

mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

3 install to the compilation directory in the directory where the kernel-3.10.0-229.20.1.el7.src.rpm is located

rpm -i kernel-3.10.0-229.20.1.el7.src.rpm 2>&1 | grep -v existcd ~/rpmbuild/SPECSrpmbuild -bp --target=$(uname -m) kernel.spec

The final kernel source code should be in the directory below

~/rpmbuild/BUILD/kernel-*/linux-*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.