≡ Menu

How to Compile and Install Linux Kernel v4.9.11 Source On a Debian / Ubuntu Linux

How do I download, compile and install the latest version of the Linux kernel on a Debian Linux v8.x or Ubuntu Linux LTS home server or my laptop? How do I build and install a custom Linux kernel on a Debian or Ubuntu Linux based system?

In order to create a custom kernel configuration file and build a custom kernel, the full Linux kernel source tree must first be downloaded and installed. The latest Linux kernel stable version is 4.9.11. In this tutorial, you will learn how to compile the Linux kernel version 4.9.11 on a Debian and Ubuntu Linux operating system and build .deb file.

Why build a custom kernel?

Compiling a custom Linux kernel has its advantages and disadvantages. To change the kernel’s behavior, one had to compile and then reboot into a new Linux. Most of the functionality in the Linux kernel contained in modules that can be dynamically loaded and unloaded from the kernel as necessary. Some benefits of a custom Linux kernel:

  1. Support a wide range of hardware including the latest hardware.
  2. Remove unwanted drivers from the kernel.
  3. Faster boot time due to small kernel size.
  4. Increased security due to additional or removed modules/drivers/features.
  5. You will learn about the kernel and advanced usage.
  6. Always run the cutting edge latest kernel.
  7. Lower memory usage.

Note: The following instructions were tested on both Debian Linux v8.x and Ubuntu Linux v14.04.4/16.04.2 LTS.


You need to install the following packages on a Debian or Ubuntu Linux to compiler the Linux kernel:

  • git : Fast, scalable, distributed revision control system. You can grab the latest source code using the git command.
  • fakeroot : Tool for simulating superuser privileges. Useful to build .deb files.
  • build-essential : Tools for building the Linux kernel such as GCC compiler and related tools on a Debian or Ubuntu Linux based system.
  • ncurses-dev : Developer’s libraries for ncurses. This is used by menuconfig while configuring the kernel options.
  • kernel-package : Utility for building Linux kernel related Debian packages.
  • xz-utils : XZ-format compression utilities to decompress the Linux kernel tar ball.
  • Disk space : 10 GB or more free disk space.
  • Time : Kernel compilation may take quite a while, depending on the power of your machine.

Install required packages

Open the terminal application. Type the following apt-get command to install the required packages for building the Linux kernel:
$ sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc
Sample outputs:

Fig.01: Install gcc and friends

Fig.01: Install gcc and friends

Finally, install the kernel-package package too:
$ sudo apt-get install kernel-package
$ sudo apt-get --no-install-recommends install kernel-package
Sample outputs:
Fig.02: Install utility for building Linux kernel

Fig.02: Install utility for building Linux kernel

Download the Linux kernel source code

Type the following wget command to grab both source code and pgp keys:
$ wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.11.tar.sign
$ wget wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.11.tar.xz

Sample outputs:

Fig.03: Use the wget to grab the latest source code from kernel.org

Fig.03: Use the wget to grab the latest source code from kernel.org

Use GnuPG to verify kernel signatures:
$ unxz linux-4.9.11.tar.xz
$ gpg --verify linux-4.9.11.tar.sign

Sample outputs:

gpg: assuming signed data in `linux-4.9.11.tar'
gpg: Signature made Monday 20 February 2017 04:28:37 AM IST using RSA key ID 00411886
gpg: Can't check signature: public key not found

Get the public key from the PGP keyserver in order to verify the signature i.e. RSA key ID 00411886 (from the above outputs):
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 00411886
Sample outputs:

gpg: requesting key 00411886 from hkp server keys.gnupg.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 00411886: public key "Linus Torvalds <torvalds@linux-foundation.org>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Now verify again:
$ gpg --verify linux-4.9.11.tar.sign
Sample outputs:

gpg: assuming signed data in `linux-4.9.11.tar'
gpg: Signature made Monday 20 February 2017 04:28:37 AM IST using RSA key ID 00411886
gpg: Good signature from "Linus Torvalds <torvalds@linux-foundation.org>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: ABAF 11C6 5A29 70B1 30AB  E3C4 79BE 3E43 0041 1886

If you do not “BAD signature” output from “gpg --verify” command, untar the Linux kernel tar ball using the tar command enter:
$ tar xvf linux-4.9.11.tar
$ ls
$ cd linux-4.9.11/
$ ls

Sample outputs


arch COPYING Documentation fs ipc kernel Makefile README scripts tools block CREDITS drivers include Kbuild lib mm REPORTING-BUGS security usr certs crypto firmware init Kconfig MAINTAINERS net samples sound virt

Configure the Linux kernel

First, copy your existing Linux kernel config file
$ cd linux-4.9.11
$ cp -v /boot/config-$(uname -r) .config

Sample outputs:

'/boot/config-4.4.0-62-generic' -> '.config'

To configure the kernel, run:
$ make menuconfig
Sample outputs:

Gallery 01: Click to enlarge

WARNING: It is easy to remove support for a device driver or option and end up with a broken kernel. For example, if the ext4 driver is removed from the kernel configuration file, a system may not boot. When in doubt, just leave support in the kernel.

Make sure you save the changes before exit from menuconfig.

Compile the Linux kernel

You need to clean the source tree and reset the kernel-package parameters, type:
$ make-kpkg clean
Sample outputs:

Fig.06: Run make-kpkg command

Fig.06: Run make-kpkg command

Now, you can compile the kernel, run:
$ fakeroot make-kpkg --initrd --revision=1.0.NAS kernel_image kernel_headers
To speed up the compile process pass the -j option (-j 16 means you are using all 16 cores to compile the Linux kernel):
$ fakeroot make-kpkg --initrd --revision=1.0.NAS kernel_image kernel_headers -j 16
Sample outputs:
Fig.07: Start compiling the kernel

Fig.07: Start compiling the kernel

The fakeroot runs a command called make-kpkg in an environment wherein it appears to have root privileges for file manipulation. This is useful for allowing users to create archives (tar, ar, .deb etc.) with files in them with root permissions/ownership. The make-kpkg command build Debian/Ubuntu kernel packages from Linux kernel sources and options are:

  • --initrd : Create an initrd image.
  • --revision=1.0.NAS : Set custom revision for your kernel such as 1.0.NAS or -1.0-custom-kernel etc.
  • kernel_image : This target produces a Debian package of the Linux kernel source image, and any modules configured in the kernel configuration file .config.
  • kernel_headers : This target produces a Debian package of the Linux kernel header image.

Please note that kernel compilation may take quite a while, depending on the power of your machine. On my shared 4 CORE CPU and 4GB ram it took 60 mins to build the Linux kernel. In the end you should see something as follows on screen:

test ! -e debian/control~ || rm -f debian/control~
dpkg-gencontrol -isp -DArchitecture=amd64 -plinux-headers-4.9.11 \
dpkg-gencontrol: warning: -isp is deprecated; it is without effect
create_md5sums_fn () { cd $1 ; find . -type f ! -regex './DEBIAN/.*' ! -regex './var/.*'      -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums ; if [ -z "DEBIAN/md5sums" ] ; then rm -f "DEBIAN/md5sums" ; fi ; } ; create_md5sums_fn                   /tmp/linux-4.9.11/debian/linux-headers-4.9.11
chown -R root:root                  /tmp/linux-4.9.11/debian/linux-headers-4.9.11
chmod -R og=rX                      /tmp/linux-4.9.11/debian/linux-headers-4.9.11
dpkg --build                        /tmp/linux-4.9.11/debian/linux-headers-4.9.11 ..
dpkg-deb: building package `linux-headers-4.9.11' in `../linux-headers-4.9.11_1.0.NAS_amd64.deb'.
cp -pf debian/control.dist          debian/control
make[2]: Leaving directory '/tmp/linux-4.9.11'
make[1]: Leaving directory '/tmp/linux-4.9.11'

Verify kernel deb files:

$ ls  ../*.deb
../linux-headers-4.9.11_1.0.NAS_amd64.deb  ../linux-image-4.9.11_1.0.NAS_amd64.deb 

Installing a custom kernel

Type the following dpkg command to install a custom kernel on your system:
$ cd ..
$ sudo dpkg -i linux-headers-4.9.11_1.0.NAS_amd64.deb
$ sudo dpkg -i linux-image-4.9.11_1.0.NAS_amd64.deb

Sample outputs:

Selecting previously unselected package linux-headers-4.9.11.
(Reading database ... 96175 files and directories currently installed.)
Preparing to unpack linux-headers-4.9.11_1.0.NAS_amd64.deb ...
Unpacking linux-headers-4.9.11 (1.0.NAS) ...
Setting up linux-headers-4.9.11 (1.0.NAS) ...
Examining /etc/kernel/header_postinst.d.
Selecting previously unselected package linux-image-4.9.11.
(Reading database ... 110487 files and directories currently installed.)
Preparing to unpack linux-image-4.9.11_1.0.NAS_amd64.deb ...
Unpacking linux-image-4.9.11 (1.0.NAS) ...
Setting up linux-image-4.9.11 (1.0.NAS) ...
 Hmm. There is a symbolic link /lib/modules/4.9.11/build
 However, I can not read it: No such file or directory
 Therefore, I am deleting /lib/modules/4.9.11/build
 Hmm. The package shipped with a symbolic link /lib/modules/4.9.11/source
 However, I can not read the target: No such file or directory
 Therefore, I am deleting /lib/modules/4.9.11/source
Running depmod.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.9.11 /boot/vmlinuz-4.9.11
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.9.11 /boot/vmlinuz-4.9.11
update-initramfs: Generating /boot/initrd.img-4.9.11
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.9.11 /boot/vmlinuz-4.9.11
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.9.11 /boot/vmlinuz-4.9.11
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.9.11 /boot/vmlinuz-4.9.11
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.11
Found initrd image: /boot/initrd.img-4.9.11
Found linux image: /boot/vmlinuz-4.4.0-62-generic
Found initrd image: /boot/initrd.img-4.4.0-62-generic
Found linux image: /boot/vmlinuz-4.4.0-21-generic
Found initrd image: /boot/initrd.img-4.4.0-21-generic

Reboot the box/server/laptop

Type the following command:
$ sudo reboot
$ sudo shutdown -r now

Verify that everything is working

Type the following command to verify your new kernel and everything is working fine:
$ uname -a
$ uname -r
$ uname -mrs
$ dmesg | more
$ dmesg | egrep -i --color 'error|critical|failed'

Sample outputs:

Linux ubuntu-box-1 4.9.11 #1 SMP Mon Feb 20 21:10:55 IST 2017 x86_64 x86_64 x86_64 GNU/Linux

And, there you have it, the Linux kernel version 4.9.11 installed and working correctly.

See also
Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 50 comments… add one }
  • AppleFanBoy September 13, 2015, 8:37 pm

    New kernels will automatically come with newer updates/distro, but the learning experience of compiling kernel is priceless.

  • Richard September 15, 2015, 4:07 am

    Thanks for the tutorial… Took a couple of hours to build on my machine. But it worked. Well sort of. I get missing or strange characters in text. Doesn’t matter if an icon label, in a terminal, LibreOffice, Firefox, etc. I went back to original kernel and all is well again. Using LUbuntu 3.19 kernel 64 bit.

  • kxmx September 16, 2015, 8:18 am

    Is there any difference between “raw” kernel and “ubuntu” kernel? Ubuntu compilated kernel 4.2 is marked like unstable, but kernel.org says 4.2 is stable. What does it mean?

    • Vivek Gite September 16, 2015, 8:45 am

      4.2 is stable. Ubuntu built packages are behind the schedule and most likely built when 4.2 was in beta. Also, some propitiatory NVIDIA/ATI & others driver may not work on the latest version 4.2. YMMV.

  • cage September 22, 2015, 9:24 am

    Hi Vivik,

    Thanks for the tutorial. I followed the same steps you mentioned but I found one file ( abi ) is missing on my macbook (parallels + ubuntu 14.04) , here is /boot folder. Do you know which step is wrong ?

    parallels@ubuntu:/boot$ ls -al
    total 115040
    drwxr-xr-x  3 root root     4096 Sep 22 16:42 .
    drwxr-xr-x 23 root root     4096 Sep 21 19:25 ..
    -rw-r--r--  1 root root  1158016 May  3  2014 abi-3.13.0-24-generic
    -rw-r--r--  1 root root  1162712 Aug 14  2014 abi-3.13.0-34-generic
    -rw-r--r--  1 root root  1165204 Aug 15 07:07 abi-3.13.0-63-generic
    -rw-r--r--  1 root root   165510 May  3  2014 config-3.13.0-24-generic
    -rw-r--r--  1 root root   165611 Aug 14  2014 config-3.13.0-34-generic
    -rw-r--r--  1 root root   165763 Aug 15 07:07 config-3.13.0-63-generic
    -rw-r--r--  1 root root   182704 Sep 22 16:35 config-4.2.0-hell-kernel
    -rw-r--r--  1 root root   182704 Sep 22 15:23 config-4.2.0-hell-kernel.old
    drwxr-xr-x  5 root root     4096 Sep 22 16:42 grub
    -rw-r--r--  1 root root 19096859 Aug 18  2014 initrd.img-3.13.0-24-generic
    -rw-r--r--  1 root root 19145542 Sep  8 10:29 initrd.img-3.13.0-34-generic
    -rw-r--r--  1 root root 19219306 Sep 18 00:24 initrd.img-3.13.0-63-generic
    -rw-r--r--  1 root root 18069958 Sep 22 16:42 initrd.img-4.2.0-hell-kernel
    -rw-r--r--  1 root root   176500 Mar 12  2014 memtest86+.bin
    -rw-r--r--  1 root root   178176 Mar 12  2014 memtest86+.elf
    -rw-r--r--  1 root root   178680 Mar 12  2014 memtest86+_multiboot.bin
    -rw-------  1 root root  3372643 May  3  2014 System.map-3.13.0-24-generic
    -rw-------  1 root root  3381262 Aug 14  2014 System.map-3.13.0-34-generic
    -rw-------  1 root root  3392068 Aug 15 07:07 System.map-3.13.0-63-generic
    -rw-r--r--  1 root root  3663717 Sep 22 16:35 System.map-4.2.0-hell-kernel
    -rw-------  1 root root  5776416 May  3  2014 vmlinuz-3.13.0-24-generic
    -rw-------  1 root root  5797728 Aug 14  2014 vmlinuz-3.13.0-34-generic
    -rw-------  1 root root  5821152 Aug 15 07:07 vmlinuz-3.13.0-63-generic
    -rw-r--r--  1 root root  6118160 Sep 22 16:35 vmlinuz-4.2.0-hell-kernel
  • Walt September 23, 2015, 2:49 pm

    If you want to only compile the loaded modules with the current kernel use ‘make localmodconfig’. This will make the compile time shorter and include all of the currently loaded modules of you current kernel.

  • M October 8, 2015, 1:11 pm

    Great information.


  • Luigi November 12, 2015, 10:09 am

    What does this——> ubuntu@mate:~$ dmesg | egrep -i –color ‘error|critical|failed’
    [ 4.718735] systemd[1]: Failed to insert module ‘kdbus’: Function not implemented
    [ 9.308305] EXT4-fs (sdc1): re-mounted. Opts: errors=remount-ro
    [ 22.411061] vboxdrv: module verification failed: signature and/or required key missing – tainting kernel <——————mean?

  • Andy December 31, 2015, 4:00 pm

    Try adding -j for a significant speed increase:
    fakeroot make-kpkg --initrd --revision=1.0.NAS -j 16

    This sped up the process to about 10 minutes on my 8 core system. By default only a single core is used.

  • frank paulsen January 11, 2016, 12:04 pm

    newer kernels directly support “make deb-pkg” instead of using”make-kpkg”

  • wayno January 12, 2016, 10:58 am

    great tute, though with the unpacking “Installing custom kernel” .deb part, had to do image first then headers.. naturally.. thanx…

  • Green January 17, 2016, 11:50 am

    I have problem after :
    “fakeroot make-kpkg –initrd –revision=1.0.NAS kernel_image kernel_headers”

    it’s showing:
    “scripts/sign-file.c:23:30: fatal error: openssl/opensslv.h: No such file or directory
    compilation terminated.
    scripts/Makefile.host:91: recipe for target ‘scripts/sign-file’ failed
    make[2]: *** [scripts/sign-file] Error 1
    Makefile:545: recipe for target ‘scripts’ failed
    make[1]: *** [scripts] Error 2
    make[1]: Leaving directory ‘/home/x/linux-4.4’
    debian/ruleset/targets/common.mk:295: recipe for target ‘debian/stamp/build/kernel’ failed
    make: *** [debian/stamp/build/kernel] Error 2”

    What I’m doing wrong?

    Thanks for help

    • Vivek Gite January 17, 2016, 12:13 pm

      Did you installed build-essential package? openssl.h means you need to install libssl-dev? Try

      sudo apt-get install libssl-dev build-essential ncurses-dev xz-utils kernel-package

      Edited by Vivek Gite. Reason: typo.

      • Green January 17, 2016, 1:03 pm

        Reading package lists… Done
        Building dependency tree
        Reading state information… Done
        E: Unable to locate package curses-dev

        • Vivek Gite January 17, 2016, 2:20 pm

          My bad. It should be ncurses-dev .

          • Green January 18, 2016, 9:34 am

            Thanks for help

            After I type :
            ls ../*.deb

            it’ showing on red :

            sudo dpkg -i linux-headers-4.4.0_1.0.NAS_amd64.deb:
            dpkg: error processing archive linux-headers-4.4.0_1.0.NAS_amd64.deb (–install):
            cannot access archive: No such file or directory
            Errors were encountered while processing:

            • Vivek Gite January 18, 2016, 7:19 pm

              cd to .. and try:
              sudo dpkg -i linux-headers-4.4.0_1.0.NAS_amd64.deb
              sudo dpkg -i linux-image-4.4.0_1.0.NAS_amd64.deb

              sudo dpkg -i ../linux-headers-4.4.0_1.0.NAS_amd64.deb
              sudo dpkg -i ../linux-image-4.4.0_1.0.NAS_amd64.deb

              • Green January 19, 2016, 9:34 am

                I have enough :) I tried to run ubuntu on Yoga 900 – Wifi / touchscreen and track-pad doesn’t work.
                I manage to run Wifi but with rest I have huge problem (nothing works).

                Anyway BIG BIG thanks for help and all replies.

              • lange June 30, 2016, 12:14 am

                you need to compile the linux-image, and after the linux-header

              • Bassem March 2, 2017, 12:06 am

                I got the same error with kernel 4.10.1 , is there any way to fix that
                run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.10.1 /home/bassem/linux-4.10.1/debian/linux-image-4.10.1//boot/vmlinuz-4.10.1
                /etc/kernel/postinst.d/apt-auto-removal: 84: /etc/kernel/postinst.d/apt-auto-removal: cannot create /etc/apt/apt.conf.d//01autoremove-kernels.dpkg-new: Permission denied
                run-parts: /etc/kernel/postinst.d/apt-auto-removal exited with return code 2
                make[3]: *** [install] Error 1
                make[2]: *** [install] Error 2
                make[2]: Leaving directory `/home/bassem/linux-4.10.1′
                make[1]: *** [debian/stamp/install/linux-image-4.10.1] Error 2
                make[1]: Leaving directory `/home/bassem/linux-4.10.1′
                make: *** [kernel_image] Error 2

      • Mikel March 21, 2016, 12:35 pm

        Thaks so much Vivek Gite, worked for me!

  • Alex January 18, 2016, 4:22 pm

    Your article needs updating. All of the required packages do not exist in the cache. If someone comes to this site hoping for a guide to properly compiling and installing a new Linux kernel – not having the packages prior to coming here – they will spend quite some time trying to track down a fistful of packages that no longer exist, have been updated and/or replaced.

    Please fix this ASAP. Thanks. :)

    • Vivek Gite January 18, 2016, 6:26 pm

      Can you provide your Linux distro name and other info like what packages are missing? I tested this on Debian 8 and Ubuntu Linux 14.04.3 LTS only. Everything worked perfectly.

      • Alex January 18, 2016, 8:09 pm

        Debian 8.1

        Checked /etc/apt/sources.list all required sources are in place. Searching apt-cache returns no entries for any of the listed packages.

  • Jur January 19, 2016, 8:59 am

    user@PLUS:~$ dmesg | egrep -i --color 'error|critical|failed'
    [ 7.474368] systemd[1]: Cannot add dependency job for unit display-manager.service, ignoring: Unit display-manager.service failed to load: No such file or directory.
    [ 7.474377] systemd[1]: Cannot add dependency job for unit display-manager.service, ignoring: Unit display-manager.service failed to load: No such file or directory.
    [ 10.513727] EXT4-fs (sda7): re-mounted. Opts: errors=remount-ro

  • IT GUY January 19, 2016, 11:20 am

    Much easier way to compile your kernel:


    • TheRiddick July 2, 2016, 2:38 pm

      Thanks for the thought but your install script causes dkms errors due to elaborate versioning. I get some extremely long build and version numbers which makes it useless. You need to allow for the user to enter EXPLICIT kernel versions and not do some crazy automate based on date/time etc……

    • TheRiddick July 2, 2016, 2:40 pm

      I would suggest a prompt that shows the user WHAT you will be calling the kernel version and deb files, and allow the user to modify it at this point.

  • alimp5 January 28, 2016, 1:02 pm


  • Luigi February 7, 2016, 4:36 am

    After I select Linux kernel config options and drivers to build and I click on save and then exit, it says to “make” in the terminal but your tutorial says that I should “make-kpkg clean” so which one should I do first after I save and exit the menuconfig?

    • Luigi February 7, 2016, 4:40 am

      End of the configuration.
      *** Execute ‘make’ to start the build or try ‘make help’. is what it says so what should I do next?

  • nir February 18, 2016, 9:02 pm

    this is my output anyone can help me?

    root@debian:/home/habernir/linux-4.1.18# dpkg -i linux-headers-4.1.18_1.0.NAS_amd64.deb
    (Reading database … 214910 files and directories currently installed.)
    Preparing to unpack linux-headers-4.1.18_1.0.NAS_amd64.deb …
    Unpacking linux-headers-4.1.18 (1.0.NAS) over (1.0.NAS) …
    Setting up linux-headers-4.1.18 (1.0.NAS) …
    Examining /etc/kernel/header_postinst.d.
    run-parts: executing /etc/kernel/header_postinst.d/dkms 4.1.18 /boot/vmlinuz-4.1.18
    Error! Your kernel headers for kernel 4.1.18 cannot be found.
    Please install the linux-headers-4.1.18 package,
    or use the –kernelsourcedir option to tell DKMS where it’s located

    • nir February 18, 2016, 9:16 pm

      amd debian 8.3 was installed in uefi

  • Mohan March 15, 2016, 3:50 am

    Hi I am trying to build linux-socfpga-3.10-ltsi kernel from rocketboards and facing the following error. Please help:
    make[4]: *** No rule to make target `drivers/acpi/acpica/uteval.o’, needed by `drivers/acpi/acpica/acpi.o’. Stop.
    make[3]: *** [drivers/acpi/acpica] Error 2
    make[2]: *** [drivers/acpi] Error 2
    make[1]: *** [drivers] Error 2
    make[1]: Leaving directory `/home/mohanubuntu/Mohan/linux-socfpga-socfpga-3.10-ltsi’
    make: *** [debian/stamp/build/kernel] Error 2

  • Dawei Li March 15, 2016, 4:22 am

    I ran into error when executing the following command:
    $ fakeroot make-kpkg –initrd –revision=1.0.NAS kernel_image kernel_headers -j 4

    Can anyone help me? The last lines of the following are the error information.

    objcopy –add-gnu-debuglink=/home/daweili/linux-4.4.4/debian/linux-image-4.4.4/usr/lib/debug/lib/modules/4.4.4/kernel/virt/lib/irqbypass.ko /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/kernel/virt/lib/irqbypass.ko
    rm -rf /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/usr/lib/debug
    test ! -f tools/lguest/lguest || \
    install -p -o root -g root -m 644 tools/lguest/lguest /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/lguest
    test ! -f /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/lguest || \
    chmod 755 /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/lguest
    test ! -e /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/source || \
    mv /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/source ./debian/source-link
    test ! -e /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/build || \
    mv /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/build ./debian/build-link
    test ! -e ./debian/source-link || \
    mv ./debian/source-link /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/source
    test ! -e ./debian/build-link || \
    mv ./debian/build-link /home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/modules/4.4.4/build
    /sbin/depmod -q -FSystem.map -b /home/daweili/linux-4.4.4/debian/linux-image-4.4.4 4.4.4;
    test ! -f scripts/package/builddeb.kpkg-dist || mv -f scripts/package/builddeb.kpkg-dist scripts/package/builddeb
    test ! -f scripts/package/Makefile.kpkg-dist || mv -f scripts/package/Makefile.kpkg-dist scripts/package/Makefile
    /usr/bin/make INSTALL_MOD_PATH=/home/daweili/linux-4.4.4/debian/linux-image-4.4.4 \
    INSTALL_FW_PATH=/home/daweili/linux-4.4.4/debian/linux-image-4.4.4/lib/firmware/4.4.4 \
    INSTALL_PATH=/home/daweili/linux-4.4.4/debian/linux-image-4.4.4//boot install
    make[2]: Entering directory `/home/daweili/linux-4.4.4′
    scripts/kconfig/conf –silentoldconfig Kconfig
    make[2]: Leaving directory `/home/daweili/linux-4.4.4′
    make[2]: Entering directory `/home/daweili/linux-4.4.4′
    sh ./arch/x86/boot/install.sh 4.4.4 arch/x86/boot/bzImage \
    System.map “/home/daweili/linux-4.4.4/debian/linux-image-4.4.4//boot”
    run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.4 /home/daweili/linux-4.4.4/debian/linux-image-4.4.4//boot/vmlinuz-4.4.4
    /etc/kernel/postinst.d/apt-auto-removal: 84: /etc/kernel/postinst.d/apt-auto-removal: cannot create /etc/apt/apt.conf.d//01autoremove-kernels.dpkg-new: Permission denied
    run-parts: /etc/kernel/postinst.d/apt-auto-removal exited with return code 2
    make[3]: *** [install] Error 1
    make[2]: *** [install] Error 2
    make[2]: Leaving directory `/home/daweili/linux-4.4.4′
    make[1]: *** [debian/stamp/install/linux-image-4.4.4] Error 2
    make[1]: Leaving directory `/home/daweili/linux-4.4.4′
    make: *** [kernel_image] Error 2

  • Mikel March 21, 2016, 12:54 pm

    Hi, is it normal to get Warnings like this during compilation?
    e.g. ” drivers/isdn/hardware/eicon/capifunc.c:1094:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=] “

  • rick March 27, 2016, 2:53 pm

    This worked for me. A further question: the needed hardware config selections / modules were not compiled into the kernel, so I did this a second time with a different revision, enabling the relevant options in menuconfig, but grub (nor uname, proc/release) does not show different revisions, only the kernel version, so not sure which I am using… is there a way to tell? The hardware (touchpad) does not work- it is not identified by the system either. Is it possible to compile it separately as a module?

    Anyway, the guide worked as described, even if it did not accomplish what I wanted, so thanks for that.

  • FEDERICO March 29, 2016, 9:48 am


    Great article, but i am having problems with this

    Verify kernel deb files:

    No debs files are there

    fede@fede-Lenovo-YOGA-900-13ISK:~/linux-4.5$ ls ../*.deb
    ls: cannot access ../*.deb: No such file or directory

  • FEDERICO March 29, 2016, 9:51 am

    oval: cannot create /etc/apt/apt.conf.d//01autoremove-kernels.dpkg-new: Permission denied
    run-parts: /etc/kernel/postinst.d/apt-auto-removal exited with return code 2
    make[3]: *** [install] Error 1
    make[2]: *** [install] Error 2
    make[2]: Leaving directory `/home/fede/linux-4.5′
    make[1]: *** [debian/stamp/install/linux-image-4.5.0] Error 2
    make[1]: Leaving directory `/home/fede/linux-4.5′
    make: *** [kernel_image] Error 2

  • SeaDog April 1, 2016, 12:50 pm

    I use Asus ux305 on the which I installed Ubuntu 15.10 with default kernetl 4.2. This kernel not supports Intel M Core the same did not work my TouchPad. Thanks to this guide I installed kernel 4.5 and all works fine. Thanks alot.

    • CodeSlayer April 27, 2016, 6:06 am

      It worked on my ASUS UX305 which is also having Intel Core M processor, and it worked perfectly

  • degomos April 29, 2016, 2:53 am

    Hi i have debian installed on my asus zenbook ux32vd, and i have this error and failure do you know how to fix this:
    [ 1.470054] ata1.00: READ LOG DMA EXT failed, trying unqueued
    [ 1.470115] ata1.00: failed to get NCQ Send/Recv Log Emask 0x1
    [ 1.471198] ata1.00: failed to get NCQ Send/Recv Log Emask 0x1
    [ 11.204433] ata2: COMRESET failed (errno=-16)
    [ 21.260609] ata2: COMRESET failed (errno=-16)
    [ 56.293242] ata2: COMRESET failed (errno=-16)
    [ 61.309330] ata2: COMRESET failed (errno=-16)
    [ 61.309411] ata2: reset failed, giving up
    [ 61.662470] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro
    [ 61.715798] Error: Driver ‘pcspkr’ is already registered, aborting…
    [ 64.039613] acpi_call: Cannot get handle: Error: AE_NOT_FOUND
    [ 64.050550] acpi_call: Cannot get handle: Error: AE_NOT_FOUND

  • james April 30, 2016, 10:24 am

    which I need to select in Fig.05, which is rightest for install kernel. you not clear, I don’t understand anything.

  • Fahad June 4, 2016, 11:35 am

    Amazing guide, used this to compile a perfect kernel 4.6.1. Bookmarked!!!!

  • Akash July 3, 2016, 11:57 am

    Thanks much for this very informative article.
    I have been using the following 5 commands to build the 4.x kernel with a particular
    .config file taken from http://kernel.ubuntu.com/~kernel-ppa/mainline/
    Steps on Development machine
    Copy the config file inside the kernel source directory as .config
    yes ” | make oldconfig
    make -j4 deb-pkg LOCALVERSION=-my_kernel
    Steps on target machine
    sudo dpkg -i linux-headers-x.xx…_amd64.deb
    sudo dpkg -i linux-image-x.xx…_amd64.deb

    After this even if I have to do a minor modification in kernel source (like add some new printk statements) then also I had to repeat the above steps which takes lot of time (as everything is done from scratch, nothing is reused from previous compilation)
    How can I expedite the subsequent compilation of kernel ?
    On debian package installation, I see the following files inside the /boot directory on the target machine

    Can I just replace the vmlinuz*KERNEL-VERSION* file with that of modified kernel & reboot ?
    Please can somebody kindly tell me a shortcut.

    For modules, I can use a shortcut, like for example for i915 module, I follow these 2 steps.
    make DRM_MODULES=”i915″ -j4
    cp drivers/gpu/drm/i915/i915.ko to /lib/modules/VERSION/kernel/drivers/gpu/drm/i915/ on the target.

  • tito September 2, 2016, 3:24 pm

    It worked for me!
    debian 3.16 -> debian 4.5 Wow

  • Vedant Yadav December 14, 2016, 10:48 am

    after this cmd:
    fakeroot make-kpkg --initrd --revision=1.0.NAS kernel_image kernel_headers -j 16

    /etc/kernel/postinst.d/apt-auto-removal: 84: /etc/kernel/postinst.d/apt-auto-removal: cannot create /etc/apt/apt.conf.d//01autoremove-kernels.dpkg-new: Permission denied
    run-parts: /etc/kernel/postinst.d/apt-auto-removal exited with return code 2
    make[3]: *** [install] Error 1
    make[2]: *** [install] Error 2
    make[2]: Leaving directory `/home/tron/Desktop/kernel/linux-stable'
    make[1]: *** [debian/stamp/install/linux-image-4.8.8+] Error 2
    make[1]: Leaving directory `/home/tron/Desktop/kernel/linux-stable'
    make: *** [kernel_image] Error 2

  • Carlos February 8, 2017, 4:47 pm

    Thanks, i used Debian 8.7 with kernel 4.9.7.

  • Alex Müller March 5, 2017, 6:15 pm

    I compiled the kernel like you said, but couldn’t install it. Could you please help?

    user@notebook:~/k$ sudo dpkg -i linux-headers-4.9.13_1.0.amdgpu_amd64.deb
    Selecting previously unselected package linux-headers-4.9.13.
    (Reading database … 282292 files and directories currently installed.)
    Preparing to unpack linux-headers-4.9.13_1.0.amdgpu_amd64.deb …
    Unpacking linux-headers-4.9.13 (1.0.amdgpu) …
    Setting up linux-headers-4.9.13 (1.0.amdgpu) …
    Examining /etc/kernel/header_postinst.d.
    run-parts: executing /etc/kernel/header_postinst.d/dkms 4.9.13 /boot/vmlinuz-4.9.13
    Error! echo
    Your kernel headers for kernel 4.9.13 cannot be found at
    /lib/modules/4.9.13/build or /lib/modules/4.9.13/source.

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , ,