e4rat stands for e4 'reduced access time' (ext4 file system only) and is a project by Andreas Rid and Gundolf Kiefer. The e4rat range of tools are comprised of e4rat-collect, e4rat-realloc and e4rat-preload.

Process

If you look at a classical bootchart you will notice that neither disk nor CPU are utilized fully during the boot process. e4rat changes this to make full use of both disk and CPU during boot process and thus reduce boot time drastically. It consists of three stages:

e4rat-collect - collect files for a specified time (default 120 seconds but this can be adjusted)

e4rat-realloc - reallocate files

e4rat-preload - preload them

Who benefits, who does not

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. Users of SSD drives do not benefit because there are no moving parts and thus (almost) no disk latency - Ureadahead might be worth looking at.

Note: (to ureadahead users) The official e4rat manual states that ureadahead conflicts with e4rat. This may be true for Ubuntu but using e4rat in conjunction with ureadahead does work on Arch Linux, although it does not speed up the boot process any further.

It is always better to be safe than sorry. Just make backup if you cannot afford to lose data on your partition.

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 boot loader configuration 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

Note: Users who have switched to a pure systemd setup do not have to change runlevels. Simply login as root once e4rat-collect has finished to run the e4rat-realloc utility.

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 in your startup.log file.

e4rat with different init system, e.g. systemd

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.
So in spite of

; init /sbin/init

you would have:

init /bin/systemd

This allows to launch both e4rat-preload and bootchart in the same boot sequence.

Bootchart

Note: this has not 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 of bootchart automatically stops logging as soon as Display Manager comes up. Supposedly the following overrides that and continues logging but it does not 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

To get bootchart2 working together with e4rat edit /sbin/bootchartd and replace the line where it says

init="/sbin/init"

with

init="/sbin/e4rat-preload"

This will allow you to measure your boot time with the fine informations that Bootchart2 provides.

It's easy to set up when to stop bootchart2 (on opposite to bootchat) by editing its configuration file /etc/bootchartd.conf. Simply adjust the line

e4rat erroneously reports an ext2 files system

/var/lib/e4rat/startup.log is not accessible

this suggests that you have /var on a separate partition which is not yet mounted during boot. You need move your startup.log to an accessible partition (/etc/e4rat/ is just fine) and adjust your /etc/e4rat.conf to reflect this change:

startup_log_file /etc/e4rat/startup.log

Remove annoying message that mess up boot message

If you are annoyed by the e4rat-preload message during boot, decrease loglevel to 1 in /etc/e4rat.conf