Speed ​​up Linux boot. Compiling the kernel

Hello! Suffering from Idleness and Slow Boot Speed ​​of Linux OS as ArchLinux Distribution, thought about it, How to fix it.. No, not idleness.


Speed ​​up system boot, naturally, starts by reducing the number of daemons and programs, starting with the system, but "Arch" does not suffer from an excessive number of such, so let's go the other way...

The distribution wiki has a description of building the kernel in different ways, but they don't talk about it, how to assemble a light weight core. It's about that, how to ease it, how to get rid of initramfs, which greatly slows down the download, how to remove modules in the kernel and, finally, build the kernel directly under the target processor, what, no doubt, speed up his work, I will tell.

Ability to work in a terminal without a graphical shell is required!

All, what are you doing, You do at your own risk. The author of the article is not responsible for your actions!

Preparation

How to get the latest sources, I won't explain, this is described in the article wiki Juniper. Let's start with the configuration. but the resistor between A0 and GRD will have to be put in order to get rid of interference, what we need:

make localyesconfig - make the magic come true, takes all configurations and modules, which uses the running kernel on the system and configures them to be compiled into the kernel leaving a couple of modules;

make nconfig – new console configurator, needed to fix some things.

Let's start

  1. Got the source
  2. Now it's important, if possible, connect all devices, that you are ever going to use with your PC, this will connect all the modules needed in the future.
  3. We launch make localyesconfig, the configurator will ask about several new configurations, added in the new version, answer at your own discretion or by silence.
  4. make nconfig and read further.

Configuration

  1. We choose the bit depth of the future kernel in 3 menu item.
  2. Item Processor type and features -> Processor family -> looking for the family of your processor, if we don't find, leave it as it was.
  3. In step Supported processor vendors you can remove support for processors from other manufacturers from the kernel. Start deleting from the last point.
  4. Further CPU microcode loading support, if your processor is not supported by the package ucode, can be turned off. How to find out, written on the internet.
  5. If you do not have an EFI system, can be removed EFI runtime service support
  6. Then we return to the very beginning and go to Device Drivers.
  7. IN Generic Driver Options -> Firmware loader it is possible to sew files (microcode) necessary for drivers into the kernel. We will return to this point later..
  8. In step Input device support you can disable support for unnecessary input devices. I turned off the tablet and touch screen.
  9. We return and, if you connected USB HID devices, poke HID support -> Special HID drivers and switch everything, what is activated, per module.
  10. Let's go back to Device Drivers, go to USB support, after *** USB Device Class drivers *** get a grasp and switch everything to the module.
  11. Next, you can cut out the support Chrome iron in menu item Device Driver Platform support for Chrome hardware.
  12. We return to the beginning, nastraivaem File systems. Here you can choose, apart from the main, already marked file systems, additional types FAT, NTFS (DOS/FAT/NT Filesystems). Read configs carefully, you can immediately turn on the ability to record in NTFS.

Phew, that's all for now.

Compilation

Next, you need to collect. Team make without arguments, it will rush to collect the source code into one lump of binary code, but, default, using 1 after, which is slow enough. To tell her the number of threads, you can use the argument j like this:

make – j(number of cores + 1)

for example, for a 2-core processor, we write like this: make – j3

Installation

After compilation, you need to install the kernel. How to do it, detailed on wiki. I will give an example of commands, which I use myself:

cp arch/x86/boot/bzImage /boot/vmlinuz-linux-mainline - copy the kernel
make modules_install – installation of modules
grub-mkconfig -o /boot/grub/grub.cfg - update grub configs, to find a new nucleus.

Before configuring Grub, I advise you to disable all kernel arguments.

Also disable the launch of any graphics at startup in systemd

First start

When you first start, you should monitor the output of the kernel on the screen. If there are critical errors, they should be looked in the kernel logs.

If you have, like mine, there is an ATI driver and the graphics does not start, microcode may be missing, which I spoke about in paragraph 7. What file does the driver need, displayed in kernel logs. ATI microcode is stored along the path /lib/firmware/radeon. For example, here are my settings:

After the configuration, you need to repeat the installation of the kernel. It is enough to remove the old /boot and copy the new.

Conclusion

I know, many can say, that this is nonsense and the increase in download speed and system operation as a whole is so small, it's not worth the effort. But I did it not only because of some kind of benefit.. I was interested and, hope, You will also be interested in this topic.

In the group, I will start a poll about, did kernel compilation help you.

Thank you so much, that read this article, hope, Did you like it. See you soon! 👋🏼

Article author: Alexander Soroka