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:
- Support a wide range of hardware including the latest hardware.
- Remove unwanted drivers from the kernel.
- Faster boot time due to small kernel size.
- Increased security due to additional or removed modules/drivers/features.
- You will learn about the kernel and advanced usage.
- Always run the cutting edge latest kernel.
- 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.
Prerequisites
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:
Finally, install the kernel-package package too:
$ sudo apt-get install kernel-package
OR
$ sudo apt-get --no-install-recommends install kernel-package
Sample outputs:
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:
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
linux-4.9.11/ linux-4.9.11/.cocciconfig linux-4.9.11/.get_maintainer.ignore linux-4.9.11/.gitattributes linux-4.9.11/.gitignore linux-4.9.11/.mailmap linux-4.9.11/COPYING linux-4.9.11/CREDITS linux-4.9.11/Documentation/ linux-4.9.11/Documentation/.gitignore linux-4.9.11/Documentation/00-INDEX linux-4.9.11/Documentation/ABI/ linux-4.9.11/Documentation/ABI/README linux-4.9.11/Documentation/ABI/obsolete/ linux-4.9.11/Documentation/ABI/obsolete/proc-sys-vm-nr_pdflush_threads linux-4.9.11/Documentation/ABI/obsolete/sysfs-block-zram linux-4.9.11/Documentation/ABI/obsolete/sysfs-bus-usb linux-4.9.11/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-arvo linux-4.9.11/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-isku linux-4.9.11/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus .... .. ... linux-4.9.11/virt/kvm/kvm_main.c linux-4.9.11/virt/kvm/vfio.c linux-4.9.11/virt/kvm/vfio.h linux-4.9.11/virt/lib/ linux-4.9.11/virt/lib/Kconfig linux-4.9.11/virt/lib/Makefile linux-4.9.11/virt/lib/irqbypass.c
linux-4.9.11
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:
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:
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:
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 \
-P/tmp/linux-4.9.11/debian/linux-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 ... Done. 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 done |
Reboot the box/server/laptop
Type the following command:
$ sudo reboot
OR
$ 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
- The Linux kernel project site.
- Man pages – apt-get(8),make-kpkg(1),fakeroot(1)
- How to Compile and Install Linux Kernel From Source Code
- How to install mainline Linux kernel on Ubuntu Linux





52 comment
New kernels will automatically come with newer updates/distro, but the learning experience of compiling kernel is priceless.
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.
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?
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.
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 ?
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.
Great information.
Thanks!
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?
Try adding -j for a significant speed increase:
i.e.
fakeroot make-kpkg --initrd --revision=1.0.NAS -j 16This sped up the process to about 10 minutes on my 8 core system. By default only a single core is used.
newer kernels directly support “make deb-pkg” instead of using”make-kpkg”
great tute, though with the unpacking “Installing custom kernel” .deb part, had to do image first then headers.. naturally.. thanx…
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
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-packageEdited by Vivek Gite. Reason: typo.
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package curses-dev
My bad. It should be ncurses-dev .
Thanks for help
After I type :
ls ../*.deb
it’ showing on red :
../linux-headers-4.4.0_1.0.NAS_amd64.deb
../linux-image-4.4.0_1.0.NAS_amd64.deb
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:
linux-headers-4.4.0_1.0.NAS_amd64.deb
cd to .. and try:
sudo dpkg -i linux-headers-4.4.0_1.0.NAS_amd64.debsudo dpkg -i linux-image-4.4.0_1.0.NAS_amd64.deb
OR
sudo dpkg -i ../linux-headers-4.4.0_1.0.NAS_amd64.debsudo dpkg -i ../linux-image-4.4.0_1.0.NAS_amd64.deb
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.
you need to compile the linux-image, and after the linux-header
I got the same error with kernel 4.10.1 , is there any way to fix that
/boot”
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
Thaks so much Vivek Gite, worked for me!
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. :)
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.
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.
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
user@PLUS:~$
Much easier way to compile your kernel:
linux-kernel-utilities
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……
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.
tnx a lot:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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?
End of the configuration.
*** Execute ‘make’ to start the build or try ‘make help’. is what it says so what should I do next?
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
root@debian:/home/habernir/linux-4.1.18#
amd debian 8.3 was installed in uefi
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
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;
restore_upstream_debianization
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
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=] “
Yes.
Hi,
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.
Hello
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
fede@fede-Lenovo-YOGA-900-13ISK:~/linux-4.5$
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
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.
It worked on my ASUS UX305 which is also having Intel Core M processor, and it worked perfectly
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
which I need to select in Fig.05, which is rightest for install kernel. you not clear, I don’t understand anything.
Amazing guide, used this to compile a perfect kernel 4.6.1. Bookmarked!!!!
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
/boot/vmlinuz*KERNEL-VERSION*
/boot/initrd*KERNEL-VERSION*
/boot/System-map*KERNEL-VERSION*
/boot/config-*KERNEL-VERSION*
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.
It worked for me!
debian 3.16 -> debian 4.5 Wow
after this cmd:
fakeroot make-kpkg --initrd --revision=1.0.NAS kernel_image kernel_headers -j 16Error:
/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 deniedrun-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
Hello!
Thanks, i used Debian 8.7 with kernel 4.9.7.
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.debSelecting 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.
Great guide, but you are missing a step after importing an old .config file:
“make oldconfig”
Hi,
About the method #1…
According to [1] and [2], in order to get a kernel as newer as possible in a most convenient way, you should install “linux-signed-generic-lts-XXX” (e.g., “linux-signed-generic-lts-xenial”) or unsigned version “linux-generic-lts-XXX” (e.g., “linux-generic-lts-xenial”) for Ubuntu before LTS 16.04, even prefer to install the newer “linux-signed-generic-hwe-16.04” or even more bleeding edge “linux-signed-generic-hwe-16.04-edge” for Ubuntu LTS 16.04 and newer; instead of specifying a version of linux kernel image package which won’t be automatically updated via “apt update/upgrade”. In this way, it will keep your kernel up to date as possible.
Some example commands to find out the proper kernel package name in Ubuntu:
$ apt-cache search linux-signed-generic-ltslinux-signed-generic-lts-utopic - Complete Signed Generic Linux kernel and headers (dummy transitional package)
linux-signed-generic-lts-vivid - Complete Signed Generic Linux kernel and headers (dummy transitional package)
linux-signed-generic-lts-wily - Complete Signed Generic Linux kernel and headers (dummy transitional package)
linux-signed-generic-lts-xenial - Complete Signed Generic Linux kernel and headers (dummy transitional package)
$ apt-cache search linux-generic-lts
linux-generic-lts-utopic - Complete Generic Linux kernel and headers (dummy transitional package)
linux-generic-lts-vivid - Complete Generic Linux kernel and headers (dummy transitional package)
linux-generic-lts-wily - Complete Generic Linux kernel and headers (dummy transitional package)
linux-generic-lts-xenial - Complete Generic Linux kernel and headers (dummy transitional package)
$ apt-cache search linux-signed-generic-hwelinux-signed-generic-hwe-16.04 - Complete Signed Generic Linux kernel and headers
linux-signed-generic-hwe-16.04-edge - Complete Signed Generic Linux kernel and headers
$ apt-cache search linux-generic-hwelinux-generic-hwe-16.04 - Complete Generic Linux kernel and headers
linux-generic-hwe-16.04-edge - Complete Generic Linux kernel and headers
References:
[1] https://wiki.ubuntu.com/Kernel/LTSEnablementStack
[2] https://wiki.ubuntu.com/Kernel/RollingLTSEnablementStack