Difference between revisions of "E4rat"
Kynikos.bot (talk | contribs) (Template:i18n is deprecated, use interlanguage links, see Help talk:I18n#"Dummy" interlanguage links and deprecation of Template:i18n) |
Lahwaacz.bot (talk | contribs) (update link(s) (avoid redirect)) |
||
(24 intermediate revisions by 15 users not shown) | |||
Line 3: | Line 3: | ||
[[ru:E4rat]] | [[ru:E4rat]] | ||
[[zh-CN:E4rat]] | [[zh-CN:E4rat]] | ||
− | {{ | + | {{Related articles start}} |
− | {{ | + | {{Related|Improve boot performance}} |
− | {{ | + | {{Related|Preload}} |
− | + | {{Related|Ureadahead}} | |
− | + | {{Related|Ext4}} | |
− | {{ | + | {{Related articles end}} |
− | |||
− | {{ | ||
− | {{ | ||
− | |||
− | |||
− | |||
− | e4rat stands for e4 'reduced access time' (ext4 file system only) and is a project by Andreas Rid and Gundolf Kiefer. The [http://e4rat.sourceforge.net/ e4rat range of tools] are comprised of e4rat-collect, e4rat-realloc and e4rat-preload. | + | [http://e4rat.sourceforge.net/ e4rat] stands for e4 'reduced access time' (ext4 file system only) and is a project by Andreas Rid and Gundolf Kiefer. The [http://e4rat.sourceforge.net/ e4rat range of tools] are comprised of e4rat-collect, e4rat-realloc and e4rat-preload. |
− | Current version is 0.2. | + | Current version is 0.2.3 |
+ | |||
+ | == 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: | 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-collect''' - collect files for a specified time (default 120 seconds but this can be adjusted) | ||
Line 26: | Line 21: | ||
* '''e4rat-preload''' - preload them | * '''e4rat-preload''' - preload them | ||
− | ===Who benefits, who does not=== | + | === 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. | 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. | ||
Line 34: | Line 29: | ||
It is always better to be safe than sorry. Just make backup if you cannot afford to lose data on your partition. | It is always better to be safe than sorry. Just make backup if you cannot afford to lose data on your partition. | ||
− | ==Installation== | + | == Installation == |
− | + | ||
+ | Install {{AUR|e4rat}} from the [[AUR]]. | ||
+ | |||
+ | == Getting it to work == | ||
− | |||
Now for the nitty-gritty: | Now for the nitty-gritty: | ||
− | |||
− | |||
− | {{ | + | === e4rat-collect === |
+ | |||
+ | To have e4rat collect a list of files you will need to append {{ic|1=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. | 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 | + | 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 {{ic|/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 {{ic|/var/lib/e4rat/startup.log}}. |
− | + | Do not forget to remove the e4rat-collect command from your [[Boot Loader#Configuration files|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 | 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 {{ic|e4rat-realloc}} utility however, switching to rescue mode in systemd with {{ic|systemctl rescue}} may allow for more inodes/blocks to be reallocated as some may not be free while in multiuser.target}} | ||
Log in as root and run: | 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. | This can take a while depending on how many files you have in your startup.log file. | ||
− | + | {{Note|It may be worthwhile to repeat the reallocation step multiple times before exiting or rebooting in order to further reduce the fragmentation count. Simply re-run the command a few times to see if this is possible on the your setup. If so you'll see the count number reduced after a few runs. This is perfectly safe and shouldn't cause any issues with booting.}} | |
− | |||
− | + | === e4rat-preload === | |
− | {{ | + | Append {{ic|1=init=/sbin/e4rat-preload}} permanently to your [[kernel parameters]]. |
+ | |||
+ | === Alternative: e4rat-preload-lite === | ||
− | |||
An alternative preload binary has been developed by [https://bbs.archlinux.org/viewtopic.php?id=117776&p=1 jlindgren], it saves a few extra seconds from your boot time. | An alternative preload binary has been developed by [https://bbs.archlinux.org/viewtopic.php?id=117776&p=1 jlindgren], it saves a few extra seconds from your boot time. | ||
The savings come from | The savings come from | ||
* using pure C with no external library dependencies, which drops the number of linked .so files from 22 to 3 | * using pure C with no external library dependencies, which drops the number of linked .so files from 22 to 3 | ||
− | Note | + | {{Note|Current [0.2.3] version of e4rat-preload is linked against 5 .so libraries, including libc, libm, libpthread ! So there is not much of a difference here.}} |
* preloading only the first 100 files (both inodes and file contents) before starting /sbin/init, then continuing to load the remaining files in parallel with the normal boot sequence. | * preloading only the first 100 files (both inodes and file contents) before starting /sbin/init, then continuing to load the remaining files in parallel with the normal boot sequence. | ||
You can install {{AUR|e4rat-preload-lite}} from the [[AUR]]. | You can install {{AUR|e4rat-preload-lite}} from the [[AUR]]. | ||
− | Append (or replace) | + | Append (or replace) {{ic|1=init=/usr/sbin/e4rat-preload-lite}} permanently to your [[kernel parameters]]. Reboot and enjoy. |
− | + | == e4rat and init systems == | |
− | + | e4rat-collect defaults to replacing itself with {{ic|/sbin/init}} upon completion. If you need to specify another process with PID 1, such as '''/usr/lib/systemd/systemd''', you can change this in {{ic|/etc/e4rat.conf}} by setting the ''init'' parameter: | |
+ | init /usr/lib/systemd/systemd | ||
− | + | This allows to launch both e4rat-preload and bootchart in the same boot sequence. | |
− | e4rat- | ||
− | ==Bootchart== | + | == Bootchart == |
− | + | {{Warning|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. | 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=== | + | === bootchart 0.9-9 === |
− | This version automatically stops logging as soon as [[ | + | This version of [[bootchart]] automatically stops logging as soon as a [[display manager]] comes up. Supposedly the following overrides that and continues logging but it does not work for me: |
− | To continue logging adjust your | + | To continue logging adjust your {{ic|/etc/bootchartd.conf}} as follows: |
− | + | AUTO_STOP_LOGGER="no" | |
To stop it manually type: | To stop it manually type: | ||
− | + | # bootchartd stop | |
To run both e4rat-preload and bootchart append the following to your grub kernel line: | To run both e4rat-preload and bootchart append the following to your grub kernel line: | ||
− | + | init=/sbin/bootchartd bootchart_init=/sbin/e4rat-preload | |
− | ===bootchart2=== | + | === bootchart2 === |
− | To get | + | To get [[bootchart]]2 working together with e4rat edit {{ic|/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 {{ic|/etc/bootchartd.conf}}. Simply adjust the line |
EXIT_PROC="kdm_greet xterm konsole gnome-terminal metacity mutter compiz ldm icewm-session enlightenment" | EXIT_PROC="kdm_greet xterm konsole gnome-terminal metacity mutter compiz ldm icewm-session enlightenment" | ||
− | + | with any program you want Bootchart2 stop logging when it launches, or rather left it empty for logging to be stopped manually. | |
− | ==Troubleshooting== | + | == Troubleshooting == |
If things do not work you may want to try the following. | If things do not work you may want to try the following. | ||
− | ===startup.log is not created=== | + | === startup.log is not created === |
− | * | + | * Disable auditd service |
− | * | + | * Check the following for any hints |
dmesg | grep e4rat | dmesg | grep e4rat | ||
− | * | + | * Try to increase verbosity and loglevel to 31 in your {{ic|e4rat.conf}} |
===e4rat erroneously reports an ext2 files system=== | ===e4rat erroneously reports an ext2 files system=== | ||
− | + | Add {{ic|1=rootfstype=ext4}} to [[kernel parameters]] from your bootloader. | |
− | + | ||
+ | === /var/lib/e4rat/startup.log is not accessible === | ||
+ | |||
+ | This suggests that you have {{ic|/var}} on a separate partition which is not yet mounted during boot. You need move your {{ic|startup.log}} to an accessible partition ({{ic|/etc/e4rat/}} is just fine) and adjust your {{ic|/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 {{ic|/etc/e4rat.conf}} | ||
− | == | + | == See also == |
− | * | + | * [https://bbs.archlinux.org/viewtopic.php?id=115976 Main discussion on the forum] |
− | + | * [https://bbs.archlinux.org/viewtopic.php?id=117776 Improved e4rat-preload - forum thread] |
Revision as of 22:36, 21 February 2014
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.
Current version is 0.2.3
Contents
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.
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.
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 /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
e4rat-realloc
utility however, switching to rescue mode in systemd with systemctl rescue
may allow for more inodes/blocks to be reallocated as some may not be free while in multiuser.targetLog 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-preload
Append init=/sbin/e4rat-preload
permanently to your kernel parameters.
Alternative: e4rat-preload-lite
An alternative preload binary has been developed by jlindgren, it saves a few extra seconds from your boot time.
The savings come from
- using pure C with no external library dependencies, which drops the number of linked .so files from 22 to 3
- preloading only the first 100 files (both inodes and file contents) before starting /sbin/init, then continuing to load the remaining files in parallel with the normal boot sequence.
You can install e4rat-preload-liteAUR from the AUR.
Append (or replace) init=/usr/sbin/e4rat-preload-lite
permanently to your kernel parameters. Reboot and enjoy.
e4rat and init systems
e4rat-collect defaults to replacing itself with /sbin/init
upon completion. If you need to specify another process with PID 1, such as /usr/lib/systemd/systemd, you can change this in /etc/e4rat.conf
by setting the init parameter:
init /usr/lib/systemd/systemd
This allows to launch both e4rat-preload and bootchart in the same boot sequence.
Bootchart
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 a 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
EXIT_PROC="kdm_greet xterm konsole gnome-terminal metacity mutter compiz ldm icewm-session enlightenment"
with any program you want Bootchart2 stop logging when it launches, or rather left it empty for logging to be stopped manually.
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
e4rat.conf
e4rat erroneously reports an ext2 files system
Add rootfstype=ext4
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 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 verbose to 1 in /etc/e4rat.conf