E4rat

Aus wiki.archlinux.de

e4rat steht für e4 "reduced access time" und ist ein Projekt von Andreas Rid und Gundolf Kiefer. Die Software setzt sich aus drei Teilen zusammen: e4rat-collect, e4rat-realloc und e4rat-preload.

Derzeit ist die Version 0.2.1 aktuell.

Arbeitsweise

Betrachtet man einen gewöhnlichen Bootvorgang, dann stellt man fest, dass weder der Prozessor noch die Festplatte währendessen vollkommen ausgelastet sind. e4rat sorgt für eine hohe Auslastung der Festplatte und der CPU während des Systemstarts und reduziert somit die Startzeit immens. Dabei müssen drei Schritte durchlaufen werden:

  • e4rat-collect - Erstellt eine Liste der beim Start benötigten Dateien in einem festgelegtem Zeitraum (Standartwert sind 120 Sekunden. Dieser kann aber angepasst werden)
  • e4rat-realloc - Umsortieren der gelisteten Daten direkt auf dem Datenträger
  • e4rat-preload - Vorheriges Laden der Dateien

Wem es etwas nützt, und wem nicht

Beim booten in den X-Server auf typischen Einzeluser-Systemen hat sich e4rat schon oft als sehr effizient erwiesen. Handelt es sich jedoch beim Rechner um einen Server, welcher nur in die Kommandozeile bootet, wird sich der Speedgewinn sehr in Grenzen halten. Weiterhin profitieren auch SSDs nicht sehr stark vom Umsortieren der Daten, da die Latenzen bei SSDs in der Regel unabhängig von der Position der Dateien auf dem Datenträger sind.

Achtung: Die Version 0.20 zerstörte noch komplette Dateisysteme, welche zu ext4-Systemen umgewandelt worden waren. Es wird generell geraten vor Installation und Verwendung der Tools ein Backup der auf der Partition befindlichen Dateien zu erstellen!

Who benefits, who doesn't

e4rat has proven to be extremely effective for typical single user set-ups which boot straight into X, perhaps even with a number of programs open. If you have a server set-up and boot only into the CLI your boot time decrease may not be as drastic. SSD drives do not benefit because there are no moving parts and thus (almost) no disk latency.

The following might have been valid for version 0.20. We are now at version 0.21 - please report findings for the latest version.

Caveat emptor: the current version of e4rat (0.20) will severely damage any partition that has been converted to ext4. This is likely because existing files are not converted to use extents, and e4rat has no built-in mechanism to detect this condition. Before using e4rat you should backup the affected partitions, reformat them as ext4 and then restore the backups. Given the current status and the nature of the program, it's a smart move to backup the system before attempting reallocation anyway.

Installation

e4rat is available in the AUR: Vorlage:Package AUR

Getting it to work

Now for the nitty-gritty:

e4rat-collect

To have e4rat collect a list of files you will need to append the following to your kernel line in your /boot/grub/menu.lst (grub legacy) or /boot/grub/grub.cfg (grub2) file:

init=/sbin/e4rat-collect

This will only have to be done once so you may prefer to append this command on the grub command line itself.

Upon booting e4rat-collect will watch your system for a default of 120 seconds. So if you boot, log into X, open your favourite browser and email client all within 2 minutes, every one of those activities is logged. To change the default of 120 seconds edit /etc/e4rat.conf. To manually stop e4rat-collect type:

e4rat-collect -k

or

pkill e4rat-collect

Upon successful boot and after having waited the allotted time you should see the following file: /var/lib/e4rat/startup.log

Do not forget to remove the e4rat-collect command from your menu.lst or grub.cfg file (not necessary if you inserted it on the grub command line).

e4rat-realloc

For the reallocation process change to init 1

sudo init 1

Log in as root and run:

e4rat-realloc  /var/lib/e4rat/startup.log

This can take a while depending on how many files you have your startup.log file.

e4rat-preload

Append the following permanently to your kernel line in your /boot/grub/menu.lst (grub legacy) or /boot/grub/grub.cfg (grub2) file:

init=/sbin/e4rat-preload

Reboot and enjoy.

e4rat with different init system

e4rat-collect defaults to replacing itself with /sbin/init upon completion. If you need to specify another PID 1, such as /bin/systemd, you can change this in /etc/e4rat.conf by setting the init parameter and uncommenting the line.

Bootchart

Note: this hasn't worked for and is still in development - any suggestions welcome

You will see a noticeable improvement but nothing can beat a nice Bootchart. Have it run before and after e4rat installation and gawk at the difference.

bootchart 0.9-9

This version automatically stops logging as soon as ?dm comes up. Supposedly the following overrides that and continues logging but it doesn't work for me:

To continue logging adjust your /etc/bootchartd.conf as follows:

AUTO_STOP_LOGGER="no"

To stop it manually type:

~# bootchartd stop

To run both e4rat-preload and bootchart append the following to your grub kernel line:

init=/sbin/bootchartd bootchart_init=/sbin/e4rat-preload

bootchart2

The /etc/bootchartd.conf of bootchart2 is set up differently and the line

EXIT_PROC="kdm_greet xterm konsole gnome-terminal metacity mutter compiz ldm icewm-session enlightenment"

can be adjusted or left empty for logging to be stopped manually.

While the above works, I have not managed to get bootchart2 to play along with e4rat-preload on the kernel line.

Tips and Tricks

If things don't work you may want to try the following.

startup.log is not created

  • comment out auditd from your rc.conf
  • check the following for any hints
dmesg | grep e4rat
  • try to increase verbosity and loglevel to 31 in your e4rat.conf

e4rat erroneously reports an ext2 files system

  • add the following to the kernel line in your grub.cfg or menu.lst
rootfstype=ext4