Ubuntu Compile and Install Linux Kernel

本文详细介绍从获取Linux内核源代码到定制配置、编译、安装全过程。涵盖下载源码、依赖安装、配置选择、编译技巧及模块与内核安装步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. Get Linux kernel source code from www.kernel.org

I choose linux-4.14.150.tar.gz to download the tarball
screen capture of www.kernel.org

  1. decompress the tarball
 tar -xvf linux-4.14.150.tar.xz
  1. Install build dependency tools
sudo apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev
  1. Linux kernel default configuration
    Linux kernel default configuration is named as
    xxx_defconfig under arch/ folder,
cd  linux-4.14.150/arch
find -name *defconfig | grep x86 -i

you will see following search results

./x86/configs/x86_64_defconfig
./x86/configs/i386_defconfig
./um/configs/x86_64_defconfig

the x86_64_defconfig only contains the basic features, if to support multiple device drivers, it is better to use the current kernel configuration on ubuntu system

  1. Customize kernel configuration
cd  linux-4.14.150
cp /boot/config-4.8.0+ .config
make menuconfig

using exist ubuntu 4.8.0 config, then make menuconfig to customize specific kernel configuration you want
screen cap for make menuconfig

  1. Compile Linux Kernel
cd  linux-4.14.150
make

or to speed up compiling use “make -j4”, here i use “make” to easy track the first scene if any bug happens during compiling
screen cap make startedif finished compiling Linux kernel, following messages will be shown in your terminal

screen cap for finish kernel compilation

  1. Install Linux kernel modules
sudo make modules_install

在这里插入图片描述

  1. Install Linux kernel
sudo make install

you will see following messages shown in the terminal for boot menu entry generation

sh ./arch/x86/boot/install.sh 4.14.150 arch/x86/boot/bzImage \
	System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.14.150 /boot/vmlinuz-4.14.150
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.14.150 /boot/vmlinuz-4.14.150
update-initramfs: Generating /boot/initrd.img-4.14.150
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.14.150 /boot/vmlinuz-4.14.150
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.14.150 /boot/vmlinuz-4.14.150
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.14.150 /boot/vmlinuz-4.14.150
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-27-generic
Found initrd image: /boot/initrd.img-5.0.0-27-generic
Found linux image: /boot/vmlinuz-5.0.0-23-generic
Found initrd image: /boot/initrd.img-5.0.0-23-generic
Found linux image: /boot/vmlinuz-4.14.150
Found initrd image: /boot/initrd.img-4.14.150
Found linux image: /boot/vmlinuz-4.8.0+
Found initrd image: /boot/initrd.img-4.8.0+
Adding boot menu entry for EFI firmware configuration
done
  1. reboot ubuntu and choose the boot entry for 4.14.150
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值