How to compile and install Linux kernel in Ubuntu/Debian and RHEL/CentOS

##(deb)
$ sudo apt-get build-dep linux-image-$(uname -r)
or
$ sudo apt-get groupinstall "Development Tools"
$ sudo apt-get install ncurses-devel libncurses5-dev python-dev

##(el)
$ sudo yum-builddep kernel
or
$ sudo yum groupinstall "Development Tools"
$ sudo yum install ncurses-devel libncurses5-dev python-dev

## download sources
$ sudo wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.XX.X.tar.xz -O - | tar -C /usr/src -xJ

## configure kernel
$ cd /usr/src/linux-3.XX.X
$ sudo cp /boot/config-`uname -r` ./.config
# either generate new config 
$ sudo make menuconfig
# or just use current config
$ sudo sh -c 'yes "" | make oldconfig'

## compile, install and reboot
$ sudo make
$ sudo make modules_install install
$ sudo reboot

from How to upgrade the kernel on RHEL/CentOS, build kernel@centos and custom kernel@centos

## using EPEL repo
$ rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
$ rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm | elrepo-release-6-6.el6.elrepo.noarch.rpm | elrepo-release-5-5.el5.elrepo.noarch.rpm
$ sudo yum --enablerepo=elrepo-kernel install kernel-ml
$ sudo reboot

## using Ubuntu Mainline repo
$ export KURL=http://kernel.ubuntu.com/~kernel-ppa/mainline/daily/current/
$ wget -qO- $KURL | sed -n 's,.*\(linux-.*\(\(all\)\|\('`dpkg --print-architecture`'\)\).deb\).*,'$KURL'\1,p' | wget -i -
$ sudo dpkg -i linux-{headers,image}-*-generic_*.deb linux-headers*_all.deb
$ sudo reboot

# uninstalling upstream kernels
$ dpkg -l | grep "linux\-[a-z]*\-"
$ sudo apt-get purge linux-{image,headers}-3.XX.X.0-*
$ sudo update-grub

from kernel-ml@epel and mainline@ubuntu

$ sudo apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 build-essential udev

## download sources
$ sudo apt-get install linux-source-$(uname -r)
$ cd /usr/src
$ sudo tar xvfvj linux-source-xxxxxx.tar.bz2
$ sudo ln -s linux-source-xxxxxxx ./linux

## configure kernel
$ cd /usr/src/linux
$ sudo make clean && make mrproper
$ sudo cp /boot/config-`uname -r` ./.config
# either generate new config 
$ sudo make menuconfig
# or just use current config
$ sudo sh -c 'yes "" | make oldconfig'

## compile, install and reboot
$ sudo make-kpkg clean
$ sudo fakeroot make deb-pkg
$ sudo dpkg -i /usr/src/linux-image-xxxxxxx.deb

from Howto compile and install Linux kernel in debian from source

Advertisements

2 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s