Improve boot performance (简体中文)

From ArchWiki
Revision as of 04:58, 24 November 2012 by Fengchao (Talk | contribs) (自己编译内核: Move in from systemd)

Jump to: navigation, search
Summary help replacing me
本文介绍了数种加速系统启动的方法。
相关阅读
Arch Boot Process (简体中文)
Udev (简体中文)
Daemon (简体中文)
mkinitcpio
Maximizing Performance
Systemd
翻译状态: 本文是英文页面 Improve_Boot_Performance翻译,最后翻译时间:2012-11-04,点击这里可以查看翻译后英文页面的改动。

本文将为读者提供数种加速系统启动的方法。通过学习实践这些方法,读者不仅能改善系统性能,还能学习系统启动脚本的知识。

查找瓶颈

systemd-analyze命令可以显示启动时各个部分的时间,包括一个 svg 图表,显示 units 等待它们依赖所花费的时间。详情参阅man systemd-analyze

自己编译内核

自己编译内核、关闭不需要的功能,恐怕是加速系统启动的最有效方法了。 更多信息参见:Kernel_Compilation_From_Source

Early start for services

One central feature of systemd is D-Bus and socket activation. This causes services to be started when they are first accessed and is generally a good thing. However, if you know that a service (like UPower) will always be started during boot, then the overall boot time might be reduced by starting it as early as possible. This can be achieved (if the service file is set up for it, which in most cases it is) by issuing:

# systemctl enable upower

This will cause systemd to start UPower as soon as possible, without causing races with the socket or D-Bus activation.

Staggered spin-up

有些硬件使用staggered spin-up,操作系统一个一个访问硬盘,以减少耗电。这会降低启动速度,大部分用户都不需要开启。检查是否开启:

$ dmesg | grep SSS

如果没有查到,表示未启动。如果有显示,可以将libahci.ignore_sss=1 加入 kernel line 进行禁用。

避免重复挂载

mkinitcpio提供了 fsck 钩子,将启动加载配置中的 root 从 ro 修改为 rw 并删除 /etc/fstab 中的 root 挂载,可以避免重复挂载。挂载参数可以通过rootflags=[mount options...]设置。

删除 /etc/fstab 中的 API 文件系统,systemd 会自动挂载它们。下面命令可以获得这些 API 文件系统的列表:

$ pacman -Ql systemd | grep '\.mount$'

/home等其他文件系统可以通过自定义挂载单元进行挂载。

参阅