E4rat
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.
There is an alternative implementation called e4rat-lite, which appears to be more active and more optimised than the original e4rat project. Look at the e4rat-lite section.
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. Its usage consists of three stages:
- e4rat-collect - assemble a list of all files loaded during a specified time after boot (default 120 seconds but this can be adjusted)
- e4rat-realloc - reallocate all the files in the list to one continuous space on the hard disk
- e4rat-preload - preload them all (using multiple CPU cores) for quick booting and loading of applications
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.
It is always better to be safe than sorry. Just make backup if you cannot afford to lose data on your partition.
Installation
Install e4ratAUR from the AUR.
- In order to build it, you must first rebuild audit from the ABS with
staticlibs
option explicitly enabled. Simply installing the default audit package will result in a build error. - Audit needs these options to be enabled in the kernel configuration (CONFIG_AUDIT) together with support for auditing system calls (CONFIG_AUDITSYSCALL) also see Kernels/Arch Build System. Probably you will need
audit=1
to add to your kernel parameters.
Getting it to work
Now for the nitty-gritty:
e4rat-collect
To have e4rat collect a list of files you will need to append init=/sbin/e4rat-collect
to your kernel parameters. For example:
kernel /vmlinuz-linux root=/dev/disk/by-label/ARCH init=/sbin/e4rat-collect ro 5
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 file .
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
Once e4rat-collect has finished to run, do:
# e4rat-realloc /var/lib/e4rat/startup.log
This can take a while depending on how many files you have in your startup.log file. Switching to rescue mode with (Systemd#Mapping between SysV runlevels and systemd targets) may allow for more inodes/blocks to be reallocated as some may not be free while in multiuser.target
e4rat-preload
Append permanently to your kernel parameters.
e4rat and init systems
e4rat-collect defaults to replacing itself with upon completion. With the default systemd
installation, this file is a symbolic link to /lib/systemd/systemd
. If you need to specify another process with PID 1, such as , you can change this in /etc/e4rat.conf
by setting the parameter:
init /usr/bin/busybox
This allows to launch both and in the same boot sequence.
e4rat-lite
An alternative to e4rat with some improvements made. It is also expected to circumvent some issues one may experience with the original e4rat package. It can be acquired from .
Using e4rat-lite
The commands for e4rat-lite work almost identically to e4rat. Look at the README of the project. The summary:
collect: - also default limit 120 seconds, you can also end the collection session using:
# e4rat-lite-collect -k
realloc: - the switch to runlevel 1 is recommended, if you use systemd run this beforehand:
# systemctl isolate rescue.target
preload:
startup.log:
configuration file: /etc/e4rat-lite.conf
- if you use systemd change init_file property to:
init_file=/usr/lib/systemd/systemd
Bootchart
Bootchart can be used to generate graphs of the system startup. This is useful to get visual representations of the CPU and Disk usages. While not required, a before and after comparison of the boot process can be obtained using Bootchart.
bootchart
This version of bootchart automatically stops logging as soon as a display manager comes up. The following overrides that and continues logging:
To continue logging adjust your 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 working together with e4rat edit 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 information that Bootchart2 provides.
It is easy to set up when to stop bootchart2 (contrary to bootchart) by editing its configuration file . The line
EXIT_PROC="kdm_greet xterm konsole gnome-terminal metacity mutter compiz ldm icewm-session enlightenment"
can be configured to stop Bootchart2 logging when the specified application launches. Alternatively it may be left empty for the logging to be stopped manually.
To generate the chart, run the command:
Troubleshooting
If things do not work you may want to try the following.
startup.log is not created
- Disable auditd service
- Check the following for any hints
# dmesg | grep e4rat
- Try to increase verbosity and loglevel to 31 in your
- Try using e4rat-lite instead of e4rat
e4rat erroneously reports an ext2 files system
Add to kernel parameters from your bootloader.
/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 to an accessible partition ( 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 verbose to 1 in /etc/e4rat.conf