Category: Kernel

Speed up your GNU/Linux machine with Preload and Prelink

This is simply my memo how to install the PreLink and Preload packages in order to speed up the operating system (actually Xubuntu 12.10).

Preload is an “adaptive readahead daemon” that runs in the background of your system, and observes what programs you use most often, caching them in order to speed up application load time. By using Preload, you can put unused RAM to good work, and improve the overall performance of your desktop system. The original project website is here.

Install it easily with:

sudo apt-get install preload

Once installed, Preload will start, and no further action is necessary, refer to the original documentation for configuration options.

To check up what resources Preload is using:

sudo tail -f /var/log/preload.log

To get more information about the specific files that Preload is caching:

sudo less /var/lib/preload/preload.state

Prelink is a similar application but has its focus on the required libraries loaded into RAM, in order to load them faster than from a hard drive. Wikipedia explains how it works better here.

Install it by typing:

apt-get install prelink
Enable prelinking by editing this file:
sudo gedit /etc/default/prelink
change the value of “PRELINKING” from “unknown” to “yes
Start it immediately:
sudo /etc/cron.daily/prelink
and close the terminal. Since now the prelink daemon will fetch informations about used libraries. What actually is cached can be shown by running:
prelink -p
while the configuration is stored here:
/etc/prelink.conf
Running Prelink and Preload I have visibly now a faster desktop environment. For instance, in XFCE 4.10 launching the file manager Nautilus, it took few seconds every time and if the harddisk was busy even more. Now Nautilus appears immediately under every circumstances. I will install these applications to all my GNU/Linux machines.

Removing previous kernels from Xubuntu

I found an useful script to remove the old kernels for Ubuntu/Xubuntu here , then I just have added a pop up menu to confirm the clean up before proceeding using Zenity. Tested with Xubuntu 12.04.

 

#!/bin/bash

###############################################################################
###### Title:     Script to remove the previous kernels on Xubuntu
###### Date:      26 September 2012
###### Version:   1.0.00
###### Author:    Cesare Riva
###### Note(s):
###### Credits:   http://www.tolaris.com/2012/07/19/removing-old-kernels-from-ubuntu/
###############################################################################
#
# 1.0.00        26 September     2012    First release
#
###############################################################################

TITLE="Kernel Clean Up Script"
VERSION="1.0.00"

ZENITY="$(which zenity)"

KERNEL_HIGHEST=$(dpkg -l 'linux-image-[0-9.]*-[0-9]*-[a-zA-Z0-9]*' | grep ^ii | awk '{print $2}' | sort -V | tail -n 1 | sed 's/^linux-image-\([0-9.]*-[0-9]*\)-.*$/\1/')
KERNEL_CURRENT=$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")
KERNEL_PACKAGES=$(dpkg -l 'linux-*-[0-9-]*' | grep ^ii | awk '{print $2}' | sed "/$KERNEL_CURRENT/d;/$KERNEL_HIGHEST/d" )
KERNEL_PREVIOUS=$(dpkg -l 'linux-*-[0-9-]*' | grep ^ii | awk '{print $2}' | sed "/$KERNEL_CURRENT/d;/$KERNEL_HIGHEST/d;s/^linux-image-\([0-9.]*-[0-9]*\)-.*$/\1/;/headers/d" )

KERNEL_INFO="highest kernel=$KERNEL_HIGHEST\ncurrent kernel=$KERNEL_CURRENT\n"

#echo "KERNEL_HIGHEST=$KERNEL_HIGHEST"
#echo "KERNEL_CURRENT=$KERNEL_CURRENT"
#echo "KERNEL_PACKAGE=$KERNEL_PACKAGES"
#echo "KERNEL_PREVIOUS=$KERNEL_PREVIOUS"

if [ -z $ZENITY ]
then
    echo -e "\nzenity is not installed!"
    echo -e "Type: \"sudo apt-get install zenity\"\n"
    exit 1
fi

if [ -z "$KERNEL_PREVIOUS" ]; then
    zenity --title="$TITLE v$VERSION" --info --text "$KERNEL_INFO\nThere are no kernels to remove"    
else
    zenity --list --title="$TITLE v$VERSION" --height=300 --hide-header \
            --text="$KERNEL_INFO\nDo you confirm to remove these kernels?" \
            --column="kernel version" $KERNEL_PREVIOUS

    if [ "$?" -eq 0 ]; then
        CMD="sudo apt-get purge --yes $KERNEL_PACKAGES"
        #echo "CMD=$CMD"
        $CMD
    else
        echo "Clean up skipped!"
    fi
fi

WordPress Themes