Difference between revisions of "E4rat (简体中文)"

From ArchWiki
Jump to navigation Jump to search
Line 2: Line 2:
 
[[Category:Boot process (简体中文)]]
 
[[Category:Boot process (简体中文)]]
 
{{i18n|e4rat}}
 
{{i18n|e4rat}}
{{translateme}}
 
  
 
{{Article summary start}}
 
{{Article summary start}}
{{Article summary text|How to drastically reduce boot and log-into-X time for ext4 file systems using [http://e4rat.sourceforge.net/ the e4rat range of tools].}}
+
{{Article summary text|[http://e4rat.sourceforge.net/ e4rat]是一款强大的[[Ext4 (简体中文)|ext4]]文件系统优化工具,能显著加快系统启动。}}
{{Article summary heading|相关}}
+
{{Article summary heading|相关页面}}
{{Article summary wiki|Improve Boot Performance}}
+
{{Article summary wiki|Improve Boot Performance (简体中文)}}
 
{{Article summary wiki|Preload}}
 
{{Article summary wiki|Preload}}
 
{{Article summary wiki|Readahead}}
 
{{Article summary wiki|Readahead}}
{{Article summary wiki|Ext4}}
+
{{Article summary wiki|Ext4 (简体中文)}}
{{Article summary heading|论坛讨论相关}}
+
{{Article summary heading|论坛内容}}
{{Article summary link|Main discussion|https://bbs.archlinux.org/viewtopic.php?id=115976}}
+
{{Article summary link|讨论页面|https://bbs.archlinux.org/viewtopic.php?id=115976}}
{{Article summary link|Improved e4rat-preload|https://bbs.archlinux.org/viewtopic.php?id=117776}}
+
{{Article summary link|e4rat-preload 改进|https://bbs.archlinux.org/viewtopic.php?id=117776}}
 
{{Article summary end}}
 
{{Article summary end}}
  
e4rat(ext4 reduced access time'的简写)是一款将 Ext4 文件系统上文件块优化排序以加快系统和应用程序启动速度的程序。
+
e4rat,'Ext4 - Reducing Access Times'(减少ext4访问次数)之略,是一款优化[[Ext4 (简体中文)|ext4]]文件系统、加速系统启动的工具。该项目由 Andreas Rid 和 Gundolf Kiefer 发起。[http://e4rat.sourceforge.net/ e4rat工具系列]包含e4rat-collect、e4rat-realloc、e4rat-preload。
项目主持人:Andreas Rid 和Gundolf Kiefer
 
The [http://e4rat.sourceforge.net/ the e4rat range of tools] are comprised of e4rat-collect, e4rat-realloc and e4rat-preload.
 
  
目前版本为 0.2.1
+
目前最新版本是0.21。
  
==步骤==
+
==机制==
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:
+
如果你用[[Bootchart (简体中文)|bootchart]]监视开机过程,会发现CPU和磁盘均未全速运转。e4rat将改变这一状况,使系统启动时CPU和磁盘全速运转,从而加速启动过程。此优化包括三步:
* '''e4rat-collect''' - collect files for a specified time (default 120 seconds but this can be adjusted)
+
* '''e4rat-collect''' - 收集文件,在特定时间(默认120s,可调整)内收集文件信息
* '''e4rat-realloc''' - reallocate files
+
* '''e4rat-realloc''' - 文件再分配,在磁盘上整理文件
* '''e4rat-preload''' - preload them
+
* '''e4rat-preload''' - 预读取文件
  
 
===对谁有效?===
 
===对谁有效?===
  
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.
+
经证实,e4rat对一般用户——直接进入X图形界面——特别有效,但对于服务器用户——启动到命令行——效果不怎么明显。此外,此工具对SSD(固态磁盘)用户也没用,因为SSD基本没有读取延迟。
  
The following might have been valid for version 0.20. We are now at version 0.21 - please report findings for the latest version.
+
下面的内容对0.20版本有效。目前最新版本是0.21,如果内容不适用请报告。
  
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.
+
{{警告|在转换的ext4文件系统(比如从ext3升级到ext4)上使用目前版本(指0.20)的ext4非常危险,会严重损坏分区。其原因可能是转换并不完全,而e4rat也没有相关检测机制。使用e4rat前,你应当备份磁盘,并重新格式化分区为ext4,然后恢复文件。}}
  
 
==安装==
 
==安装==
The {{Pkg|e4rat}} package can be found in the [community] repository:
+
[community]仓库提供了{{Pkg|e4rat}}软件包:
 
  $ pacman -S e4rat
 
  $ pacman -S e4rat
  
==让其起作用==
+
==配置==
Now for the nitty-gritty:
+
现在进入正题。
 +
 
 
===e4rat-collect===
 
===e4rat-collect===
 
To have e4rat collect a list of files you will need to append the following to your linux line in your '''/boot/grub/menu.lst''' (grub legacy) or '''/boot/grub/grub.cfg''' (grub2) file:
 
To have e4rat collect a list of files you will need to append the following to your linux line in your '''/boot/grub/menu.lst''' (grub legacy) or '''/boot/grub/grub.cfg''' (grub2) file:
Line 86: Line 84:
 
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.
 
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==
  
<b>Note: 此部分尚开发中,欢迎提建议</b>
+
<b>Note: this hasn't worked for and is still in development - any suggestions welcome</b>
  
 
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.
Line 118: Line 116:
 
can be adjusted or left empty for logging to be stopped manually rather than at a predetermined programme start.
 
can be adjusted or left empty for logging to be stopped manually rather than at a predetermined programme start.
  
==常见问题==
+
==疑难解答==
  
If things do not work you may want to try the following.
+
如果出现问题,请参考以下内容。
  
===没有创建startup.log===
+
===startup.log 未创建===
  
*comment out auditd from your '''rc.conf'''
+
*在{{ic|/etc/rc.conf}}注释掉{{ic|auditd}}。
*check the following for any hints
+
*检查下列命令的输出:
 
  dmesg | grep e4rat
 
  dmesg | grep e4rat
*try to increase verbosity and loglevel to 31 in your '''e4rat.conf'''
+
*在{{ic|/etc/e4rat.conf}}设置{{ic|loglevel}}为{{ic|31}}获取详细调试信息。
  
===e4rat erroneously reports an ext2 files system===
+
===e4rat 错误地报告文件系统为 ext2===
  
*add the following to the kernel line in your '''grub.cfg''' or '''menu.lst'''
+
*添加如下内容到{{ic|/boot/grub/grub.cfg}}启动项的{{ic|linux}}行末尾,或{{ic|/boot/grub/menu.lst}}启动项的{{ic|kernel}}行末尾:
 
  rootfstype=ext4
 
  rootfstype=ext4
  
===无法对/var/lib/e4rat/startup.log进行操作===
+
===无法读取 startup.log===
  
*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:
+
*这说明你的{{ic|/var}}和根目录不在同一分区,因而开机时为挂载。可以修改{{ic|startup.log}}文件位置(比如{ic|/etc/startup.log}}),方法是修改{{ic|/etc/e4rat.conf}}:
<pre>startup_log_file /etc/e4rat/startup.log</pre>
+
startup_log_file /etc/e4rat/startup.log

Revision as of 15:17, 16 December 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary heading Template:Article summary link Template:Article summary link Template:Article summary end

e4rat,'Ext4 - Reducing Access Times'(减少ext4访问次数)之略,是一款优化ext4文件系统、加速系统启动的工具。该项目由 Andreas Rid 和 Gundolf Kiefer 发起。e4rat工具系列包含e4rat-collect、e4rat-realloc、e4rat-preload。

目前最新版本是0.21。

机制

如果你用bootchart监视开机过程,会发现CPU和磁盘均未全速运转。e4rat将改变这一状况,使系统启动时CPU和磁盘全速运转,从而加速启动过程。此优化包括三步:

  • e4rat-collect - 收集文件,在特定时间(默认120s,可调整)内收集文件信息
  • e4rat-realloc - 文件再分配,在磁盘上整理文件
  • e4rat-preload - 预读取文件

对谁有效?

经证实,e4rat对一般用户——直接进入X图形界面——特别有效,但对于服务器用户——启动到命令行——效果不怎么明显。此外,此工具对SSD(固态磁盘)用户也没用,因为SSD基本没有读取延迟。

下面的内容对0.20版本有效。目前最新版本是0.21,如果内容不适用请报告。

警告: 在转换的ext4文件系统(比如从ext3升级到ext4)上使用目前版本(指0.20)的ext4非常危险,会严重损坏分区。其原因可能是转换并不完全,而e4rat也没有相关检测机制。使用e4rat前,你应当备份磁盘,并重新格式化分区为ext4,然后恢复文件。

安装

[community]仓库提供了e4rat软件包:

$ pacman -S e4rat

配置

现在进入正题。

e4rat-collect

To have e4rat collect a list of files you will need to append the following to your linux 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

Alternative: e4rat-preload-lite

An alternative preload binairy has been developed by jlindgren, it shaves 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, and
  • 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) the following permanently to your kernel line in your /boot/grub/menu.lst (grub legacy) or /boot/grub/grub.cfg (grub2) file:

init=/usr/sbin/e4rat-preload-lite

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

To get bootchart2 working together with e4rat edit /sbin/bootchartd and replace the line init="/sbin/init" with "init="/sbin/e4rat-preload".

/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 rather than at a predetermined programme start.

疑难解答

如果出现问题,请参考以下内容。

startup.log 未创建

  • /etc/rc.conf注释掉auditd
  • 检查下列命令的输出:
dmesg | grep e4rat
  • /etc/e4rat.conf设置loglevel31获取详细调试信息。

e4rat 错误地报告文件系统为 ext2

  • 添加如下内容到/boot/grub/grub.cfg启动项的linux行末尾,或/boot/grub/menu.lst启动项的kernel行末尾:
rootfstype=ext4

无法读取 startup.log

  • 这说明你的/var和根目录不在同一分区,因而开机时为挂载。可以修改startup.log文件位置(比如{ic|/etc/startup.log}}),方法是修改/etc/e4rat.conf
startup_log_file /etc/e4rat/startup.log