Date created: Wednesday, August 22, 2012 6:27:34 PM. Last modified: Thursday, June 20, 2024 9:20:20 AM
Kernel Compile
Ubuntu 22:
List installed kernels:
apt list --installed | grep linux-image
Ubuntu 18:
# Kernel compile
sudo apt-get install build-essential pkg-config git libncurses5-dev flex bison libssl-dev libelf-dev
git clone https://github.com/torvalds/linux.git
cd linux/
# The easiest way to compile a Kernel with the correct config is the copy the current config:
cp -v /boot/config-$(uname -r) .config
# Or credit a new one / edit the copy using the menu editor:
make menuconfig
make -j 4
sudo make modules_install install
sudo update-grub2
sudo reboot
# Compile kernel samples/tools, e.g. the bpf samples
sudo apt-get install clang llvm
make -C samples/bpf clean
make headers_install
make M=samples/bpf
# Show automatically installed kernels:
apt-mark showauto 'linux-image-.*'
# Show manually installed kernels:
apt-mark showmanual 'linux-image-.*'
# Remove old auto-installed kernels:
sudo apt-get autoremove --purge
# One can mark a manually installed Kernel as auto-installed, to have it removed by the previous command:
sudo apt-mark auto linux-image-5.3.0-24-generic
CentOS7:
sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
sudo rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
sudo yum --enablerepo=elrepo-kernel info kernel-ml.x86_64
sudo yum --enablerepo=elrepo-kernel install kernel-ml.x86_64
sudo vi /etc/default/grub
# Replace
GRUB_DEFAULT=saved
# With
GRUB_DEFAULT="CentOS Linux (4.13.11-1.el7.elrepo.x86_64) 7 (Core)"
# Where that is the menu item text in /etc/grub2-efi.cfg for the new Kernel version
sudo grub2-editenv list
sudo grub2-editenv /boot/grub2/grubenv unset saved_entry
sudo grub2-editenv list
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Ubuntu 16:
sudo apt-get source linux-image-$(uname -r)
sudo apt-get build-dep linux-image-$(uname -r)
# This is required for the debug symbols if using debugging such as with SystemTap
sudo apt-get install pkg-config-dbgsym
# Optionally to compile a kernel module without any optimisation for use with SystemTap, edit the module Makefile.
# Example with Kernel 4.4.0.72, edit net/packet/Makefile to compile af_packet without optimisations.
# Add the following to the Makefile:
ccflags-af_packet.o += -O0
# Use this if built before to start a clean build
fakeroot debian/rules clean
# Build with skipdbg=false to use SystemTap (this took about 2 hours and 18G of disk space!)
fakeroot debian/rules binary-headers binary-generic binary-perarch skipdbg=false
# Install all the .deb files generated and the single .ddeb file
cd ../
sudo dpkg -i linux*4.8.0-17.19*.deb
sudo dpkg -i *.ddeb
Ubuntu 14:
sudo apt-get update
sudo apt-get install dpkg-dev debhelper gawk git
sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)
sudo apt-get source linux-image-$(uname -r)
cd linux-3.13.0/
sudo fakeroot debian/rules clean
# skipdgb=false is here to build a debug build (to support Systemtap) = it took about 2.5 hours and 11G of disk space!
sudo AUTOBUILD=1 fakeroot debian/rules binary-generic skipdbg=false
sudo dpkg -i ../linux-image-3.13.0-116-generic-dbgsym_3.13.0-116.163_i386.ddeb
Debian 5:
sudo apt-get update
sudo apt-get install dpkg-dev debhelper gawk git
sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)
sudo apt-get source linux-image-$(uname -r)
cd linux-3.13.0/
sudo fakeroot debian/rules clean
# skipdgb=false is here to build a debug build (to support Systemtap) = it took about 2.5 hours and 11G of disk space!
sudo AUTOBUILD=1 fakeroot debian/rules binary-generic skipdbg=false
sudo dpkg -i ../linux-image-3.13.0-116-generic-dbgsym_3.13.0-116.163_i386.ddeb
sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)
Previous page: IPMI/BMC Config via ipmitool
Next page: Last Login