from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites: www.linuxhowtos.org
toolsntoys.linuxhowtos.org



Last additions:
How to make X listen on port 6000

How to make X listen on port 6000

words:

34

views:

85472

userrating:

average rating: 1.2 (52 votes) (1=very good 6=terrible)


May, 25th 2007:
April, 26th 2007:
Apr, 10th. 2007:
Druckversion . pdf icon
You are here: Misc

Speeding up the boot process (next generation)

The idea is to preload the useful files into kernel buffer cache before they are needed. Since I/O can happen parallel to the other CPU intensive tasks during bootup, this leads to faster bootup and faster startup time for your chosen applications. Other projects use static lists to preload the files.

This tutorial uses an automated process of generating the "useful" prefetch database.

This is /etc/init.d/my-readahead.
Code:

#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {
        before syslog-ng
}

start() {
        ebegin "Starting readahead ROYALE"
        cat /etc/conf.d/* > /dev/null 2>&1 &
        cat /usr/lib/gconv/gconv-modules.cache > /dev/null 2>&1 &
        cat /usr/share/icons/gnome/icon-theme.cache > /dev/null 2>&1 &
        cat /usr/share/icons/hicolor/icon-theme.cache > /dev/null 2>&1 &
        cat `cat /etc/conf.d/sofile-list.load` > /dev/null 2>&1 &
        if [ -f /forcesampler ];then
                /usr/sbin/sample-init-process /etc/conf.d/sofile-list.load &
                rm -f /forcesampler
        fi 
        eend 0
}

stop() {
        eend 0
}

The executable shell script /usr/sbin/sample-init-process:
Code:

 #!/bin/bash
final_db="$1"

# total number of lists to keep in /etc/conf.d/
total_to_keep=4

# total number of samples to make in /forcesampler boot.
# It will take twice this amount of seconds to finish sampling.
total_samples_per_boot=200

# touch empty file if not there
[ ! -f "$final_db" ] && touch "$final_db"

let i=0
while [ "$i" -ne "$total_to_keep" ] ; do
        if [ ! -f "$final_db$i" ] ; then
                break;
        else
                j=$((i+1))
                if [ "$j" = "$total_to_keep" ] ;then
                        j=0
                fi
                if [ -f "$final_db$j" -a "$final_db$i" -nt "$final_db$j" ];then
                        i=$((j))
                        break;
                fi
        fi
        i=$((i+1))
done
if [ "$i" = "$total_to_keep" ] ;then
        i=0
fi

slot="$i"
cp "$final_db" "$final_db$i"

function collect_sample()
{
        lsof | awk '{if ($5=="REG") {if (match($9,".so") || match($9,".conf") \
        || match($9,"/bin/") || match($9,"ttf") || match($9,"libexec")) \
        print $9}}' | sort | uniq >> $1
}

collect_sample /tmp/init_sample1

i=0 
while [ "$i" -ne "$total_samples_per_boot" ] ; do
        collect_sample /tmp/init_sample2
        cat /tmp/init_sample1 /tmp/init_sample2 | sort | uniq > /tmp/init_sample3
        mv /tmp/init_sample3 /tmp/init_sample1
        sleep 1
        i=$((i+1))
done

cat /tmp/init_sample1 "$final_db$slot" | sort | uniq > "$final_db"

rm -f /tmp/init_sample[123]
And then do this:
Code:
chmod +x /usr/sbin/sample-init-process
rc-update add my-readahead default
touch /forcesampler

What you have done is asked my-readahead to create a sampler process which samples what files (fonts, binaries, libraries, configs) are in use, every second. It collects 200 samples (will be busy for at least 10 minutes after boot) and keeps updating the database with a list of useful files.

Once you boot after this the first time, you will probably see a slow down because its collecting samples for use on the next and subsequent boots. Use your system as you normally would. Open firefox, gaim, OO or whatever. Once the sampler script has finished ('ps -aef|grep sample-init-process' will tell you if its running), reboot. Now this and all subsequent boots will be much faster.

If it takes too long for the sample-init-process to finish, reduce the total_samples_per_boot variable in the sampler script to 100 and try again by touching /forcesampler.

In future, whenever you feel like updating the prefetch database, just 'touch /forcesampler' and database will be updated on next reboot.

based on http://forums.gentoo.org/viewtopic-t-478491.html, some script modifications done.

back



Support us on Content Nation

New Packages

- as rdf newsfeed
- as rss newsfeed
- as Atom newsfeed
2026-06-01
fastapi - 0.136.3
Ebuild name:

dev-python/fastapi-0.136.3

Description

High performance framework, easy to learn, fast to code, ready for produ

Added to portage

2026-06-01

gentoo-kernel-modprep - 7.0.10_p1
Ebuild name:

sys-kernel/gentoo-kernel-modprep-7.0.10_p1

Description

Minimal subset of gentoo-kernel-bin for building modules

Added to portage

2026-06-01

gentoolkit - 0.7.4
Ebuild name:

app-portage/gentoolkit-0.7.4

Description

Collection of administration scripts for Gentoo

Added to portage

2026-06-01

glances - 4.5.4
Ebuild name:

sys-process/glances-4.5.4

Description

CLI curses based monitoring tool

Added to portage

2026-06-01

gokrazy-rsync - 0.3.3
Ebuild name:

net-misc/gokrazy-rsync-0.3.3

Description

rsync in Go

Added to portage

2026-06-01

less - 702
Ebuild name:

sys-apps/less-702

Description

Excellent text file viewer

Added to portage

2026-06-01

libsearpc - 3.3.0-r5
Ebuild name:

net-libs/libsearpc-3.3.0-r5

Description

Simple C language RPC framework

Added to portage

2026-06-01

linux-sources - 3-r9
Ebuild name:

virtual/linux-sources-3-r9

Description

Virtual for Linux kernel sources

Added to portage

2026-06-01

modus-themes - 5.1.0
Ebuild name:

app-emacs/modus-themes-5.1.0

Description

Highly accessible themes for GNU Emacs

Added to portage

2026-06-01

modus-themes - 5.2.0
Ebuild name:

app-emacs/modus-themes-5.2.0

Description

Highly accessible themes for GNU Emacs

Added to portage

2026-06-01

portage - 3.0.79-r1
Ebuild name:

sys-apps/portage-3.0.79-r1

Description

The package management and distribution system for Gentoo

Added to portage

2026-06-01

pyaudio - 0.2.14-r1
Ebuild name:

dev-python/pyaudio-0.2.14-r1

Description

Python bindings for PortAudio

Added to portage

2026-06-01

qgis - 4.0.2
Ebuild name:

sci-geosciences/qgis-4.0.2

Description

User friendly Geographic Information System

Added to portage

2026-06-01

seafile - 9.0.18
Ebuild name:

net-misc/seafile-9.0.18

Description

File syncing and sharing software with file encryption and group sharing

Added to portage

2026-06-01

seafile-client - 9.0.18
Ebuild name:

net-misc/seafile-client-9.0.18

Description

Seafile desktop client

Added to portage

2026-06-01

valkey - 0
Ebuild name:

acct-group/valkey-0

Description

Valkey program group

Added to portage

2026-06-01

valkey - 0
Ebuild name:

acct-user/valkey-0

Description

Valkey program user

Added to portage

2026-06-01

valkey - 9.1.0
Ebuild name:

dev-db/valkey-9.1.0

Description

Persistent key-value store, fork of dev-db/redis

Added to portage

2026-06-01

zfs - 2.3.7
Ebuild name:

sys-fs/zfs-2.3.7

Description

Userland utilities for ZFS Linux kernel module

Added to portage

2026-06-01

zfs - 2.4.2
Ebuild name:

sys-fs/zfs-2.4.2

Description

Linux kernel module and userland utilities for ZFS

Added to portage

2026-06-01

zfs-kmod - 2.3.7
Ebuild name:

sys-fs/zfs-kmod-2.3.7

Description

Linux ZFS kernel module for sys-fs/zfs

Added to portage

2026-06-01

2026-05-31
ebuild-mode - 1.83
Ebuild name:

app-xemacs/ebuild-mode-1.83

Description

Emacs modes for editing ebuilds and other Gentoo specific files

Added to portage

2026-05-31

esptool - 5.2.0
Ebuild name:

dev-embedded/esptool-5.2.0

Description

Serial utility for flashing and interacting with Espressif ESP8266 and E

Added to portage

2026-05-31

gcc - 16.1.1_p20260530
Ebuild name:

sys-devel/gcc-16.1.1_p20260530

Description

The GNU Compiler Collection

Added to portage

2026-05-31

getuto - 2.0
Ebuild name:

app-portage/getuto-2.0

Description

Standalone Gentoo gpg trust anchor generation tool for binpkgs

Added to portage

2026-05-31

gnome-shell - 49.7
Ebuild name:

gnome-base/gnome-shell-49.7

Description

Provides core UI functions for the GNOME desktop

Added to portage

2026-05-31

gnome-user-docs - 49.7
Ebuild name:

gnome-extra/gnome-user-docs-49.7

Description

GNOME end user documentation

Added to portage

2026-05-31

grass - 8.5.0-r1
Ebuild name:

sci-geosciences/grass-8.5.0-r1

Description

Free GIS with raster and vector functionality, as well as 3D vizuali

Added to portage

2026-05-31

libadwaita - 1.8.6
Ebuild name:

gui-libs/libadwaita-1.8.6

Description

Building blocks for modern GNOME applications

Added to portage

2026-05-31

libcdada - 0.6.4
Ebuild name:

dev-libs/libcdada-0.6.4

Description

Basic data structures in C

Added to portage

2026-05-31

mit-krb5 - 1.22.2
Ebuild name:

app-crypt/mit-krb5-1.22.2

Description

MIT Kerberos V

Added to portage

2026-05-31

mit-krb5 - 1.22.2-r1
Ebuild name:

app-crypt/mit-krb5-1.22.2-r1

Description

MIT Kerberos V

Added to portage

2026-05-31

mit-krb5 - 1.22.2-r2
Ebuild name:

app-crypt/mit-krb5-1.22.2-r2

Description

MIT Kerberos V

Added to portage

2026-05-31

octave-kernel - 1.0.4
Ebuild name:

dev-python/octave-kernel-1.0.4

Description

Jupyter kernel for octave

Added to portage

2026-05-31

pdf-tools - 1.3.0-r1
Ebuild name:

app-emacs/pdf-tools-1.3.0-r1

Description

Emacs Lisp support library for PDF documents

Added to portage

2026-05-31

pycargoebuild - 0.15.2
Ebuild name:

app-portage/pycargoebuild-0.15.2

Description

A generator for Rust/Cargo ebuilds written in Python

Added to portage

2026-05-31

raspberrypi-utils - 0_p20260527
Ebuild name:

dev-embedded/raspberrypi-utils-0_p20260527

Description

Raspberry Pi userspace utilities

Added to portage

2026-05-31

roundcube - 1.6.16
Ebuild name:

mail-client/roundcube-1.6.16

Description

Browser-based multilingual IMAP client with an application-like user i

Added to portage

2026-05-31

serpent - 1.43
Ebuild name:

dev-python/serpent-1.43

Description

A simple serialization library based on ast.literal_eval

Added to portage

2026-05-31

service-identity - 26.1.0
Ebuild name:

dev-python/service-identity-26.1.0

Description

Service identity verification for pyOpenSSL

Added to portage

2026-05-31

shell-maker - 0.89.2-r1
Ebuild name:

app-emacs/shell-maker-0.89.2-r1

Description

Interaction mode for making comint shells for GNU Emacs

Added to portage

2026-05-31

shell-maker - 0.90.1-r1
Ebuild name:

app-emacs/shell-maker-0.90.1-r1

Description

Interaction mode for making comint shells for GNU Emacs

Added to portage

2026-05-31

shell-maker - 0.91.2-r1
Ebuild name:

app-emacs/shell-maker-0.91.2-r1

Description

Interaction mode for making comint shells for GNU Emacs

Added to portage

2026-05-31

starlette - 1.2.1
Ebuild name:

dev-python/starlette-1.2.1

Description

The little ASGI framework that shines

Added to portage

2026-05-31

typer - 0.26.4
Ebuild name:

dev-python/typer-0.26.4

Description

Build great CLIs. Easy to code. Based on Python type hints

Added to portage

2026-05-31

wine-staging - 11.10
Ebuild name:

app-emulation/wine-staging-11.10

Description

Free implementation of Windows(tm) on Unix, with Wine-Staging patc

Added to portage

2026-05-31

rdf newsfeed | rss newsfeed | Atom newsfeed
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
- Copyright and legal notices -
Time to create this page: 48.8 ms