Ubuntu 16.04, Kernel Compile on default setting

By | December 20, 2016

Ubuntu 16.04 was released on April 26th.

In fact, the version of Ubuntu in Linux kernel compile does not really matter, but in Ubuntu 16.04, I have a Linux kernel compile that I have written.

If you want to conclude, you can only refer to the last part.


Linux kernel compile on Ubuntu 16.04

For reference, Ubuntu 16.04 used in build was just after downloading and installing iso from Ubuntu.com, and there was no package installed differently.

I will compile the kernel with the same configuration as the Ubuntu 16.04 I am currently using, and then modify only what I want. So, first of all, it is the purpose of this article to apply and build the configuration of the currently running Kernel.

1. Change Package List setting to secure kernel source of Ubuntu 16.04

The kernel source code is also available from kernel.org, but due to some changes for Ubuntu 16.04, the so-called vanila kernel code will not be downloaded and will be downloaded from the package server. By default, the package server settings are not downloaded and you need to change the configuration so that you can receive the source code.

1-1) Run Ubuntu Software from the left ICON menu.

1-2) After execution, select Software & Updates from the top menu to display the setting screen.

1-3) Select the “Source code” item which is unchecked in the setting screen. If checked, a – shaped check will be made.

1-4) If you select it, the package list will be changed, so you will get a popup prompting you to update it.

2. Ubuntu 16.04 Linux Kernel Source Code Download

If you update the Package Server List as above, the Kernel Source Code will now also be available for download via the apt-get command.

# apt-get source linux-image – $ (uname -r)

If you execute the above command, you will see ` uname -r` as the current version, and download the version of Kernel Source Code directly below the directory where you executed the command.

Integrity (?) Checking routines may show errors, but in practice there is no problem at build time and it does not seem to have a big meaning.
You can see that the directory linux-4.4.0 is created under the current directory as shown below.

3. Copy and apply the configuration of the currently running kernel and run make-kpkg, which compiles the kernel. The copy was successful, but make-kpkg does not work because it is not installed.

~/linux-4.4.0 # cp /boot/config-4.4.0-21-generic .config

4. Use apt-get to install the kernel-package that contains the make-kpkg command. Since there is no make-kpkg, the statement to install kernel-package is impressive.

# apt-get install kernel-package

I tried to install only kernel-package, but I want to install all by pressing “Y” rather than dependencies.

During the installation, the window to select is displayed.

5. After the installation, I ran make-kpkg and it runs normally. The detailed command for make-kpkg used here is as follows.

# make-kpkg -j2 –initrd –append-to-version = –test-kernel kernel_image

-jN means the number of cpu at compile time, where 2 is cpu and -j2.

–append-to-version = – test-kernel means the name to be appended to the kernel name. After the change, we added the name –test-kernel to check for normal change.

kernel_image is the output of the kernel image as a package that can be installed and installed by using the command. If you run it, proceed as follows.

6. It is necessary to install libssl-dev to stop the kernel while it is compiled and generate a fatal error.


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


# apt-get install libssl-dev

7. Even if the errors related to ssl are crossed, VBox related errors will occur next. The files under the ubuntu directory are assumed to be included only in the ubuntu kernel. This problem is caused by not finding the header file correctly.


cc1: fatal error: ./ubuntu/vbox/vboxguest/include/VBox/VBoxGuestMangling.h: No such file or directory
compilation terminated.
scripts / Makefile.build: 258: recipe for target ‘ubuntu / vbox / vboxguest / VBoxGuest-linux.o’ failed


~/linux-4.4.0# cd ubuntu/vbox

~/linux-4.4.0/ubuntu/vbox# ln -s ../include ./r0drv/include

~/linux-4.4.0/ubuntu/vbox# ln -s ../include ./vboxsf/include

~/linux-4.4.0/ubuntu/vbox# ln -s ../include ./vboxguest/include

~/linux-4.4.0/ubuntu/vbox# ln -s ../include ./vboxvideo/include

Although the error occurred in vboxguest, it happens somewhere else, so you can create a symbolic link for r0drv, vboxsf, and vboxvideo in advance.

8. If you hang up all the symbolic links and run the kernel build command again, another error occurs.

Once again, you can fix it by hanging a symbolic link.


make [4]: *** No rule to make target ‘ubuntu / vbox / vboxguest / vboxguest / r0drv / alloc-r0drv.o’, needed by ‘ubuntu / vbox / vboxguest / vboxguest.o’. Stop.


~/linux-4.4.0# cd ubuntu/vbox/vboxguest

~/linux-4.4.0/ubuntu/vbox/vboxguest# ln -s ../r0drv/

9. After catching the above error, Kernel Compile is completed as below.

10. If you move to the upper directory by cd .., you can see that the kernel image deb package is created with the following name.

linux-image-4.4.13 – test-kernel_4.4.13 – test-kernel-10.00.Custom_amd64.deb

It seems that the kernel image package I built is correct. One strange thing is that the directory name of the source code is 4.4.0, and the build result is 4.4.13. I looked into it more and changed the version in the diff file downloaded with the kernel source.



In fact, I understand that the following command to download the source code is to download the same kernel source code by checking the kernel version (uname -r) of the current system. (You can do it again.)

# apt-get source linux-image-$(uname -r)

First, since we built the kernel with the same configuration, booting the kernel is as follows.

11. Install it with the following command.

# dpkg -i linux-image-4.4.13-test-kernel_4.4.13-test-kernel-10.00-Custom_amd64.deb

It does not mean that the kernel is installed. If you try uname -a, you can see that the old one still applies. A reboot is required for the new kernel to be applied.

12. After rebooting, the following changes are made.

–test-kernel is checked in the kernel version name.

Kernel configuration changes

This is the only way to build with the default configuration, and this time I want to change kernel defconfig to create a different kernel from the existing configuration.

1. To change kernel configuration, execute the following command.

# make menuconfig

2. But an error occurs.


scripts / kconfig / lxdialog / dialog.h: 38: 20: fatal error: curses.h: no such file or directory
compilation terminated.
scripts / Makefile.host: 108: recipe for target ‘scripts / kconfig / mconf.o’ failed


# apt-get install libncurses5-dev


3. Now, when you run make menuconfig, you will be able to modify kernel defconfig normally. You can check here and proceed with the builds as described above.

Ubuntu kernel compile summary

1. Change the Package List setting to secure the kernel source of Ubuntu 16.04 in Ubuntu Software

2. Copy existing settings

~/linux-4.4.0# cp /boot/config-4.4.0-21-generic .config

3. Install package for kernel compile

# apt-get install kernel-package

# apt-get install libssl-dev

# apt-get install libncurses5-dev

4. Create a broken symbolic link in the Ubuntu kernel code

~/linux-4.4.0/ubuntu/vbox# ln -s ../include ./r0drv/include

~/linux-4.4.0/ubuntu/vbox# ln -s ../include ./vboxsf/include

~/linux-4.4.0/ubuntu/vbox# ln -s ../include ./vboxguest/include

~/linux-4.4.0/ubuntu/vbox# ln -s ../include ./vboxvideo/include

~/linux-4.4.0/ubuntu/vbox/vboxguest# ln -s ../r0drv/

5. Create kernel image package with make-kpkg

# make-kpkg -j2 –initrd –append-to-version = –test-kernel kernel_image

6. Install the generated package

# dpkg -i linux-image-4.4.13 -test-kernel_4.4.13 -test-kernel-10.00-Custom_amd64.deb

7. Reboot
In fact, the average user does not have much to do with Linux, and even if you use Linux, you will not have to do kernel compile unless you are a kernel developer. In Linux, unlike Windows, it is better to understand that only the kernel can compile and use the kernel.
8. Kernel module build

# make -C $ (pwd) M = $ (pwd) / net / wireless modules

2 thoughts on “Ubuntu 16.04, Kernel Compile on default setting

Leave a Reply

Your email address will not be published. Required fields are marked *