Posted: . At: 12:06 PM. This was 8 years ago. Post ID: 9844
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to build a 4.8.4 Linux kernel on Ubuntu 16.10.


To build the latest 4.8.4 Linux kernel on Ubuntu 16.10, you will only need the ncurses-dev and build-essential packages installed. Then we are ready to install a new Linux kernel.

Download the latest Linux kernel tarball.

jason$ wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.8.4.tar.xz

And then unpack the Linux tarball that we have downloaded.

jason$ tar -xvf linux-4.8.4.tar.xz

Now to check the Linux source tree is free of unwanted cruft.

jason$ cd linux-4.8.4/
 
jason$ make mrproper

Now I copy the existing configuration from the running kernel to the source tree.

jason$ cp /boot/config-4.4.0-45-generic .config

Now run make menuconfig to configure the new Linux kernel.

Kernel 4.8.4 configuration.
Kernel 4.8.4 configuration.
jason$ make menuconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/mconf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf  Kconfig
.config:1631:warning: symbol value 'm' invalid for RXKAD
.config:3589:warning: symbol value 'm' invalid for SERIAL_8250_FINTEK
.config:7537:warning: symbol value 'm' invalid for EXT4_ENCRYPTION
configuration written to .config
 
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

Now start the compilation. This could take quite a while, depending upon the options chosen during the configuration phase.

jason$ make && make modules

Then, once the long compilation process has completed successfully, install the modules first.

jason$ sudo make modules_install
[sudo] password for jason:

Then install the actual kernel image and related files to /boot.

jason$ sudo make install
sh ./arch/x86/boot/install.sh 4.8.4 arch/x86/boot/bzImage \
	System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.8.4 /boot/vmlinuz-4.8.4
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.8.4 /boot/vmlinuz-4.8.4
update-initramfs: Generating /boot/initrd.img-4.8.4
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.8.4 /boot/vmlinuz-4.8.4
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.8.4 /boot/vmlinuz-4.8.4
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.8.4 /boot/vmlinuz-4.8.4
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.8.4 /boot/vmlinuz-4.8.4
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.8.4
Found initrd image: /boot/initrd.img-4.8.4
Found linux image: /boot/vmlinuz-4.4.0-45-generic
Found initrd image: /boot/initrd.img-4.4.0-45-generic
Found linux image: /boot/vmlinuz-4.4.0-43-generic
Found initrd image: /boot/initrd.img-4.4.0-43-generic
Found linux image: /boot/vmlinuz-4.4.0-42-generic
Found initrd image: /boot/initrd.img-4.4.0-42-generic
Found linux image: /boot/vmlinuz-4.4.0-38-generic
Found initrd image: /boot/initrd.img-4.4.0-38-generic
Found linux image: /boot/vmlinuz-4.4.0-36-generic
Found initrd image: /boot/initrd.img-4.4.0-36-generic
Found linux image: /boot/vmlinuz-4.3.3-gnu
Found initrd image: /boot/initrd.img-4.3.3-gnu
Found linux image: /boot/vmlinuz-4.3.0-6-lowlatency
Found initrd image: /boot/initrd.img-4.3.0-6-lowlatency
Found linux image: /boot/vmlinuz-4.3.0-6-generic
Found initrd image: /boot/initrd.img-4.3.0-6-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
done

Then clean and prepare the source tree to put it in /usr/src.

jason$ sudo make clean prepare
  CLEAN   .
  CLEAN   arch/x86/entry/vdso
  CLEAN   arch/x86/kernel/cpu
  CLEAN   arch/x86/kernel
  CLEAN   arch/x86/purgatory
  CLEAN   arch/x86/realmode/rm
  CLEAN   arch/x86/lib
  CLEAN   certs
  CLEAN   crypto/asymmetric_keys
  CLEAN   crypto
  CLEAN   drivers/firmware/efi/libstub
  CLEAN   drivers/gpu/drm/radeon
  CLEAN   drivers/net/wan
  CLEAN   drivers/scsi/aic7xxx
  CLEAN   drivers/tty/vt
  CLEAN   firmware
  CLEAN   kernel/debug/kdb
  CLEAN   lib/raid6
  CLEAN   lib
  CLEAN   security/apparmor
  CLEAN   security/selinux
  CLEAN   security/tomoyo
  CLEAN   usr
  CLEAN   arch/x86/boot/compressed
  CLEAN   arch/x86/boot
  CLEAN   arch/x86/tools
  CLEAN   .tmp_versions
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/bin2c
  HOSTCC  arch/x86/tools/relocs_32.o
  HOSTCC  arch/x86/tools/relocs_64.o
  HOSTCC  arch/x86/tools/relocs_common.o
  HOSTLD  arch/x86/tools/relocs
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      arch/x86/purgatory/purgatory.o
  AS      arch/x86/purgatory/stack.o
  AS      arch/x86/purgatory/setup-x86_64.o
  CC      arch/x86/purgatory/sha256.o
  AS      arch/x86/purgatory/entry64.o
  CC      arch/x86/purgatory/string.o
  LD      arch/x86/purgatory/purgatory.ro
  BIN2C   arch/x86/purgatory/kexec-purgatory.c
  CHK     include/generated/timeconst.h
  CC      kernel/bounds.s
  CHK     include/generated/bounds.h
  GEN     scripts/gdb/linux/constants.py
  CC      arch/x86/kernel/asm-offsets.s
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh

Now, after moving the source tree to /usr/src, we must update the symlinks under /lib/modules/4.8.4/ to reflect the new location of the Linux source.

jason$ ls -hula /lib/modules/4.8.4/
total 4.4M
drwxr-xr-x  3 root root 4.0K Oct 27 12:01 .
drwxr-xr-x  8 root root 4.0K Oct 27 12:00 ..
lrwxrwxrwx  1 root root   20 Oct 27 12:00 build -> /usr/src/linux-4.8.4
drwxr-xr-x 12 root root 4.0K Oct 27 11:47 kernel
-rw-r--r--  1 root root 1.1M Oct 27 11:47 modules.alias
-rw-r--r--  1 root root 1.1M Oct 27 11:48 modules.alias.bin
-rw-r--r--  1 root root 7.0K Oct 27 11:47 modules.builtin
-rw-r--r--  1 root root 8.8K Oct 27 11:48 modules.builtin.bin
-rw-r--r--  1 root root 459K Oct 27 11:47 modules.dep
-rw-r--r--  1 root root 658K Oct 27 11:48 modules.dep.bin
-rw-r--r--  1 root root  285 Oct 27 11:47 modules.devname
-rw-r--r--  1 root root 176K Oct 27 11:47 modules.order
-rw-r--r--  1 root root  114 Oct 27 11:48 modules.softdep
-rw-r--r--  1 root root 440K Oct 27 11:47 modules.symbols
-rw-r--r--  1 root root 545K Oct 27 11:48 modules.symbols.bin
lrwxrwxrwx  1 root root   20 Oct 27 12:01 source -> /usr/src/linux-4.8.4

This way, we will be able to compile drivers against the Linux kernel when it is running.

Now our new 4.8.4 Linux kernel is installed and the machine is ready to reboot into the newly installed kernel. That was not too hard after all.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.