Improving your Framework Desktop or any other machine

In yesterday thread Framework Desktop:- amdgpu unable to locate a BIOS ROM the community helped me to fix a really bad issue. So, now I feel like giving something back to the community.

If you feel the following stuff it’s unwarranted advice or too much trouble, then skip this post and go on with your life.

If, on the other hand you’re willing to suffer a bit of a short term pain (which is actually not as bad as they say!) for a big long term gain, then keep reading.

All this comes up from James comment of what most distros do.

Essentially, most distros cater to the necessities of all, so they work on the majority, if not all, machines. All that is fine and make a lot of people happy.

Distributions’ kernels are made to boot on every possible machine, so they are compiled for a generic CPU. That does not take advantage of the instruction set of the specific CPU in your machine. That’s why kernel 6.16 added this.

But distros don’t do that and also, they include in the kernel as modules the drivers for most everything. Because by doing otherwise, they won’t boot on every possible machine under the sun.

If you want to make your life a little bit better, then tailor your distro to your specific machine. That means, among other things, compiling your own custom kernel.

It’s a process that can take a few hours at first, but in the end you get a lean, fast kernel made just for your machine, instead of the bloated kernel that your distribution gives you. Plus, once done, you can reuse that configuration for future kernel releases.

To do that, follow this steps:

  1. Find out what is the process to build a custom kernel for your distro. At some point, that involves installing the kernel sources, which go into /usr/src.
  2. Copy /proc/config.gz from your running system somewhere on your disc and gunzip it.
  3. lspci -nnk will tell you the drivers/modules that the distribution kernel uses for your machine. You are essentially concerned about the graphics driver (Framework Desktop’s is amdgpu), network driver (FD is Realtek RTL8126) and wireless driver (FD is Mediatek MT7925). YMMV, for example your machine could have a another AMD/ATI driver or a NVIDIA/nouveau driver. Make note of all these modules.
  4. Go to the specific kernel source in /usr/src that you downloaded in (1).
  5. make distclean or make mrproper
  6. copy your unzipped config as /usr/src/kernel-x.x.x/.config
  7. make oldconfig. Answer N or Y to any new options as you feel like.
  8. make menuconfig
  9. Make sure your disc driver is static not module, that means [*]. FD’s is NVME, your machine could have NVME or SATA.
  10. Start with your graphics adapter. For that go to Device Drivers, Graphics support, Direct Rendering Manager and from everything there only keep your driver as module, turning off all the other drivers.
  11. Do not touch/change anything else. Exit menuconfig and build the kernel per instructions you found out in (1).
  12. Make the necessary changes to add your new kernel to GRUB’s the boot list and reboot your machine into the new kernel.
  13. If everything goes well (it should), you’re running your new custom kernel.
  14. Repeat (10) to (12) for your network (Device Drivers, Network Device Support, Ethernet driver support) and wireless drivers (Device Drivers, Network Device Support, Wireless LAN).
  15. After each successfull step, make a backup copy of your .config, just in case.
  16. Now you have a lean kernel containing only the necessary modules for your machine and disabling hundreds of unneeded drivers.
  17. If you feel like it, you can try removing other things from Device Drivers, like Multimedia, Sound or other stuff you don’t need (that means they don’t come up in lspci -nnk).
  18. As a final touch, after everything is working, run make menuconfig, go to Processor type and features and turn on Build and optimize for local/native CPU. Exit, rebuild, reboot.
  19. With that done, if your machine has an AMD CPU, disable all Intel and other CPUs options. If it has an Intel CPU, disable all AMD options and so on. Exit, rebuild, reboot.

At the end of all this, you end up with the lean and fast kernel specifically made for your machine.

Make sure you save a copy of your last functioning .config so you can reuse it in future kernel releases. You just copy it to a clean new kernel source and run make oldconfig.

All this does not only make your kernel leaner and faster, but also eliminates any possible security issues that may come up in the drivers that you disabled.

That’s it! If you managed to go through all this, enjoy your faster machine.

2 Likes