📜 ⬆️ ⬇️

Building and installing a kernel under Debian

Here we will speak not only about the compilation of the Linux kernel, but about the compilation of the kernel and its assembly into a deb-package. Then this deb'om can be shared with friends, boast in front of a girlfriend / boyfriend, or simply reused if necessary.

To begin with, we put the fakeroot, kernel-package, libncurses5-dev packages:
  aptitude install fakeroot kernel-package libncurses5-dev 

All dependencies will be pulled up automatically ...
Then we take the necessary archive from kernel.org and merge it and unpack it into / usr / src (we take for example the kernel 2.6.31.4).
  $ cd / usr / src
 $ sudo -s
 # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.4.tar.bz2
 # tar xjf linux-2.6.31.4.tar.bz2
 # if [-d linux];  then rm linux;  fi;  ln -s linux-2.6.31.4 linux
 # cd linux 

There is one moment. Since we already have a working kernel in the installed system, if we don’t want to put all the checkboxes in the configuration of the new kernel from scratch, we take the ready config either from / boot or from / proc:
  # cp / boot / config - $ (uname -r) .config
 # zcat /proc/config.gz> .config 

As a result, we have a preliminary preparation to the configuration of our new kernel.

Now we configure the kernel for our specific goals, or add options for new modules, or ... In a word, creativity:
  # make menuconfig 

It will be interesting to note here that if we immediately exit the menu, we can see something like this:
  .config: 903: warning: symbol value 'm' invalid for RFKILL_INPUT
 .config: 2920: warning: symbol value 'm' invalid for DRAGONRISE_FF
 .config: 2937: warning: symbol value 'm' invalid for GREENASIA_FF
 .config: 2939: warning: symbol value 'm' invalid for THRUSTMASTER_FF
 .config: 2940: warning: symbol value 'm' invalid for ZEROPLUS_FF 

it makes sense to find these options when configuring a new kernel and see what is what to
Or, as suggested to me, use:
  # make oldconfig 

to compile a new version that will not touch all the matching options, and asks about the others that have changed.
By the way, if anyone is interested in configuring under Xs, he can do this:
  # make xconfig 

Important! Do not forget to say “Kernel module loader” in “Loadable module support”, as options are possible.
Well, that's it. Pimps pointed, buttons pushed, out of the windows came out, saved the new config, now proceed to build. First, let's do:
  # make-kpkg clean 

See something like this:
  exec make kpkg_version = 12.021 -f /usr/share/kernel-package/ruleset/minimal.mk clean
 ====== making target minimal_clean [new prereqs:] ======
 This is kernel package version 12.021.
 test!  -f .config ||  cp -pf .config config.precious
 test!  -e stamp-building ||  rm -f stamp-building
 test!  -f Makefile ||  \
            make ARCH = i386 distclean
 make [1]: Entering directory `/usr/src/linux-2.6.31.4 '
  CLEAN scripts / basic
  CLEAN scripts / kconfig
  CLEAN include / config
  CLEAN .config .config.old include / linux / autoconf.h
 make [1]: Leaving directory `/usr/src/linux-2.6.31.4 '
 test!  -f config.precious ||  mv -f config.precious .config
 rm -f modules / modversions.h modules / ksyms.ver scripts / cramfs / cramfsck scripts / cramfs / mkcramfs 

Well, now, in fact, collect the core:
  # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_image 

og.091015.00 - means only a revision of our assembly (fewer letters, but more digits, otherwise you will get an error at the very end of the assembly and you will have to repeat everything from the very beginning), but everything else could be anybody - as far as imagination is enough :)
After the previous command is executed normally, you can also give this “gentleman's set”:
  # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_headers
 # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_manual
 # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_doc
 # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_source 

After that, we will get a set of the following deb-packages:

they will be located in / usr / src.
All we have to do is install them via dpkg:
  # cd / usr / src
 # dpkg -i ./linux-image-2.6.31.4_og.091015.00_i386.deb 

etc.
The configuration for GRUB will have to be executed automatically, as well as the initrd will be assembled.
Final step:
  # reboot 

')

Source: https://habr.com/ru/post/82600/


All Articles