Prelink (or how to make KDE boot in 3 seconds)

pre-link is a program whose utility is to make programs open faster. Although the explanation of how it does it would deserve a full article, we can say in a rough way that it tells the binary where to look first for the dynamic libraries it needs to load.

Thus, let's imagine that we have a binary that depends on the QtCore library, once we have executed prelink on it, it will first search in the space designated by prelink, and in the event that it does not find it (an update, for example) it will search for it in the traditional way.

Prelink works on any POSIX compliant system, like GNU / linux or the BSDs.

How to apply prelink

Optimizing the system with prelink is quite simple, we can optimize a binary using (as root):

prelink binario

But to optimize the entire system we must perform:

prelink -amvR

You will see something like this:

pre-link

pre-link

Here is a detailed explanation of the meaning of the parameters:

  • a: equals –all, makes it apply to the whole system
  • m: equivalent to –conserve-memory, the explanation of how it works is complex, but saves space
  • v: equivalent to –verbose, it allows us to know which are the pre-linked libraries
  • A: Equivalent to –random, increase security by making a value random. I do not know the details of its operation
The terminal is Yakuake, in case anyone is interested.

To un-pre-link (unlink) a binary

prelink  -u

The whole system:

prelink -au

Many distributions like Ubuntu offer a cron that periodically pre-links all system binaries if prelink is installed
Prelink can cause problems in several proprietary binaries, so they are usually skipped by default. Anyway, make sure your /etc/prelink.conf file contains these lines:
# Skype -b / usr / lib32 / skype / skype -b / usr / lib / skype / skype # Flash Player Plugin -b /usr/lib/mozilla/plugins/libflashplayer.so # NVIDIA -b / usr / lib / libGL .so * -b /usr/lib32/libGL.so* -b //usr/lib/libOpenCL.so* -b //usr/lib32/libOpenCL.so* -b / usr / lib32 / vdpau / -b / usr / lib / vdpau / -b /usr/lib/xorg/modules/drivers/nvidia_drv.so -b /usr/lib/xorg/modules/extensions/libglx.so* -b / usr / lib / libnvidia- * - b / usr / lib32 / libnvidia- * # Catalyst -b / usr / lib / libati * -b / usr / lib / fglrx * -b / usr / lib / libAMDXvBA * -b /usr/lib/libGL.so* - b / usr / lib / libfglrx * -b /usr/lib/xorg/modules/dri/fglrx_dri.so -b /usr/lib/xorg/modules/drivers/fglrx_drv.so -b / usr / lib / xorg / modules / extensions / fglrx / -b /usr/lib/xorg/modules/linux/libfglrxdrm.so -b /usr/lib/xorg/modules/extensions/libglx.so

Optimize KDE

What is promised is debt. If you had already pre-linked your system you probably didn't notice any difference in KDE loading times. This is so because KDE serves as a utility called kdeinit to load all the necessary libraries. To avoid using this tool we must let KDE know that it is pre-linked. To do this we must (as root) create a variable file:

nano /etc/profile.d/kde-prelink.sh

In which we paste the following line

export KDE_IS_PRELINKED=1

And we give it the proper permissions (we don't want any naughty to add rm-rf /)

chmod 755 /etc/profile.d/kde-prelink.sh

And if you don't believe me, here is a video of KDE booting up on my system:

[specifications] System details:

  • HDD at 7200 RPM
  • Gentoo
  • XFS
  • Ksplash disabled (cause of video black screen
[/specs]

Cron and prelink

If you use a system like Archlinux, in which updates are very frequent, it might be interesting to add a cron that runs prelink every day.

Thus, we open the cron file with nano (as root):

nano /etc/cron.daily/prelink

And we paste the following:

#! / Bin / bash
[[-x / usr / bin / prelink]] &&
/ usr / bin / prelink -amR &> / dev / null

Then we give it the appropriate permissions (I already mentioned that nobody wants someone to add malicious code):
chmod 755 /etc/cron.daily/prelink

A good habit when reading an article is to research what exactly the script does. A good habit when writing it is to explain what it is for. Here the breakdown

  1. The first line is used to tell the system what a bash script is and the location of the interpreter.
  2. The second one makes bash execute a subshell in debug mode, I don't know why, but it is recommended, it can be eliminated without risk. The && means that when the command finishes, run the following.
  3. Execute prelink with some parameters already explained, the &> / dev / null redirects any output to / dev / null, that is, it discards it

Links of interest


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Ivan Barra said

    With the "strike" you gave to [ENTER], the little dwarfs that the pc has got scared and started working at double the speed of before, you say use PRELINK, but your system is based on terror ... hahaha!

    Greetings and Excellent post

    Thanks for sharing.

    1.    roader said

      Umm, with the noise it makes I wouldn't be surprised if there was a mine on my XD computer.

    2.    dhunter said

      Epic the joke, it is true that he was eager to enter, hehe.

  2.   Sheosi said

    I would like to comment that a while ago I benchmarked this, and I could see that the differences were almost nil (use as tests I think and sink the firefox and nautilus bits).
    If there are interested I will publish the file (I did not publish it at the time for laziness).

    1.    roader said

      Umm, not all files can be seen to improve, but at the very least the system tends to boot faster.

  3.   day said

    There was a time when I used the e4rat and it improved the startup for a few seconds, because it is a hdd it starts too fast from what I see, currently I have a small ssd with kaos and in xfs and when I saw the startup time I could not believe it.
    http://i.imgur.com/ds6WqIT.png

    1.    Joao said

      I demand to know the desktop theme you are using and the icon set (in good vibes)

      1.    roader said

        I'd swear the theme is helium.

      2.    day said

        The plasma theme and icons are called Dynamo and the Next thin window.
        http://sta.sh/02ful04ags1
        http://hombremaledicto.deviantart.com/art/Dynamo-Plasma-beta-473014317
        http://kde-look.org/content/show.php?content=164722

        Sorry to the author of the song for the off 🙂

    2.    jose-rod said

      What is that app launcher called? 🙂

      1.    roader said

        I think it is one called simple qml launcher.

      2.    day said

        As roader says, it is the QML

      3.    jose-rod said

        Thanks

  4.   eliotime3000 said

    Very good tip, although KDE runs wonders on Arch and Slackware (I've tried them and they really look amazing).

  5.   Azureus said

    Great thank you very much. I tried it on my Arch, I made a general prelink and I must say that the improvement is quite good and I feel very comfortable hehe

  6.   ianpocks said

    I don't know if it's me…. but I don't notice any difference and with systemd-analyze it still takes longer to start ...

    1.    roader said

      Well, there must be some problem in your OS, you know, prelink -au and everything is solved.

  7.   Bla bla bla said

    As far as I know (from my own experience), at least in Gentoo you don't need to create a new file to pass the value of the KDE_IS_PRELINKED variable. Just uncomment the line KDE_IS_PRELINKED = 1 in /etc/env.d/43kdepaths (I'm not sure if that's the exact path, since I don't have my machine at the moment).

    Every time KDE is completely compiled, you have to review that file, because some of the packages it installs will overwrite the file I mentioned.

    1.    roader said

      And it probably is in many distributions. but doing it the way I have done it I guarantee that this configuration is not changed.

  8.   static said

    Excellent post, Congratulations

    I suggest you create a tutorial to install Gentoo

    1.    roader said

      I'll keep it in mind . Thank you

  9.   Cristianhcd said

    very good utility, although it does not serve me, because I have: disgusting to KDE

  10.   Javier said

    Will dolphin speed up? It has always seemed slow to start

    1.    roader said

      It should, I don't know, I always use it by default. I use gentoo, portage, if it detects that prelink is installed, it automatically prelinks the binaries, so, no idea.

  11.   pepo said

    Interesting, thanks!

    PD- Library = Library, not library 😉
    Well, the desktop is called Plasma Desktop, not KDE. Ok, I stop xD

    1.    roader said

      In computer jargon it is an accepted failure, after all, languages ​​are pragmatic, especially in translations.
      https://es.wikipedia.org/wiki/Librería_(desambiguación)

  12.   dtulf said

    good. I was about to test it in ArchLinux KDE (base, not the complete DE) and it gives me "Error saving '/etc/cron.daily/ Error saving' /etc/cron.daily/prelink ': Prelink file or directory does not exist' : The file or directory does not exist ». I don't have "cron" installed and on the wiki [1] they talk about cronie, fcron and other variants. What do I need to install or do to complete the tutorial?

    [1] https://wiki.archlinux.org/index.php/cron#Installation