Difference between revisions of "Improving performance/Boot process"

From ArchWiki
Jump to: navigation, search
m (/etc/rc.conf: rw)
(minor formatting improvements; added templates; added a lot of wiki links; added a Warning box under the /etc/mkinitcpio.conf section)
Line 3: Line 3:
  
 
{{Article summary start}}
 
{{Article summary start}}
{{Article summary text|This article attempts to aggregate methods on how to improve the boot performance of a system.}}
+
{{Article summary text|This article attempts to aggregate methods on how to improve the boot performance of an Arch Linux system.}}
 
{{Article summary end}}
 
{{Article summary end}}
  
 
==Preface==
 
==Preface==
Improving the boot performance of a system can provide reduced boot wait times and a means to learn more about how certain system files and scripts interact with one another. This article attempts to aggregate methods on how to improve the boot performance of a system.
+
Improving the boot performance of a system can provide reduced boot wait times and a means to learn more about how certain system files and scripts interact with one another. This article attempts to aggregate methods on how to improve the boot performance of an Arch Linux system.
  
 
==Modifying boot files==
 
==Modifying boot files==
Line 13: Line 13:
  
 
====Asynchronous startup====
 
====Asynchronous startup====
{{Note|Using this means there are no guarantees that daemons are all started before X. This can cause problems if your setup expects dbus to be running (ck-launch-session, gnome, kde, etc.).}}
+
{{Note|Using this means there are no guarantees that daemons are all started before [[Xorg|X]]. This can cause problems if your setup expects [[D-Bus]] to be running (ck-launch-session, [[GNOME]], [[KDE]], etc.).}}
 
The initscripts can be started [[Wiktionary:asynchronous|asynchronously]] instead of running in a strict order.
 
The initscripts can be started [[Wiktionary:asynchronous|asynchronously]] instead of running in a strict order.
  
<pre>
+
# use once instead of wait
# use once instead of wait
+
rc::sysinit:/etc/rc.sysinit
rc::sysinit:/etc/rc.sysinit
+
rs:S1:wait:/etc/rc.single
rs:S1:wait:/etc/rc.single
+
rm:2345:once:/etc/rc.multi
rm:2345:once:/etc/rc.multi
+
rh:06:once:/etc/rc.shutdown
rh:06:once:/etc/rc.shutdown
+
su:S:once:/sbin/sulogin -p
su:S:once:/sbin/sulogin -p
+
</pre>
+
  
 
====TTY terminal management====
 
====TTY terminal management====
  
''agetty'' is Arch Linux's default terminal manager. By default it will generate six terminals, which can be access by typing {{Codeline|Ctrl+Alt+F[1-6]}}. To increase performance you can comment out unused terminals. It is important to not comment the first two terminals (i.e. {{Codeline|tty1}} and {{Codeline|tty2}}).
+
''agetty'' is Arch Linux's default terminal manager. By default it will generate six terminals, which can be accessed by typing {{Keypress|Ctrl+Alt+F[1-6]}}. To increase performance you can comment out unused terminals. It is important to '''not''' comment out the first two terminals (i.e. {{ic|tty1}} and {{ic|tty2}}).
{{file|/etc/inittab|
+
{{hc|/etc/inittab|<nowiki>
 
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
 
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
 
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
 
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
Line 35: Line 33:
 
#c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
 
#c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
 
#c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
 
#c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
}}
+
</nowiki>}}
  
Additionally, consider using a lighter terminal manager such as {{Package Official|fgetty}}, which consists of the minimal tty manager, {{Package AUR|mingetty}}, that has been stripped of printfs and compiled against {{Package Official|dietlibc}}.
+
Additionally, consider using a lighter terminal manager such as {{Pkg|fgetty}}, which consists of the minimal tty manager, {{AUR|mingetty}}, that has been stripped of printfs and compiled against {{Pkg|dietlibc}}.
  
{{Note|''fgetty'' currently doesn't support sha512 password hashing by default; a patched {{AUR|fgetty-pam}} is available in the AUR. (see [[SHA password hashes]])}}
+
{{Note|{{Pkg|fgetty}} currently does not support SHA-512 password hashing by default; a patched {{AUR|fgetty-pam}} is available in the [[Arch User Repository|AUR]]. See [[SHA password hashes]] for more information.}}
  
# pacman -S fgetty
+
You can [[pacman|install]] {{Pkg|fgetty}} from the [[Official Repositories|official repositories]].
  
Then replace {{Codeline|agetty}} with {{Codeline|fgetty}} on the following lines:
+
Then replace {{ic|agetty}} with {{ic|fgetty}} on the following lines:
{{file|/etc/inittab|
+
{{hc|/etc/inittab|<nowiki>
 
  c1:2345:respawn:/sbin/fgetty tty1 linux
 
  c1:2345:respawn:/sbin/fgetty tty1 linux
 
  c2:2345:respawn:/sbin/fgetty tty2 linux
 
  c2:2345:respawn:/sbin/fgetty tty2 linux
}}
+
</nowiki>}}
  
 
===/boot/grub/menu.lst===
 
===/boot/grub/menu.lst===
This file lets you modify the kernel command line at boot. A couple ways to speed up boot time using this file to modify the kernel commandline is to remove framebuffer entries, and set the kernel loglevel to a low level of logging with '''quiet'''. For more kernel parameters and {{Filename|/boot/grub/menu.lst}} examples check out the page on [[GRUB]]. Remove existing {{Codeline|1=vga=}} [[Wikipedia:Framebuffer|framebuffer]] resolution entries and '''logo.nologo''', parameters to the desired kernel:
+
This file lets you modify the kernel command line at boot. A couple of ways to speed up boot time using this file to modify the kernel command line is to remove framebuffer entries and to set the kernel to use a low level of logging with {{ic|quiet}}. For more kernel parameters and {{ic|/boot/grub/menu.lst}} examples check out the page on [[GRUB]]. Remove existing {{ic|1=vga=}} [[Wikipedia:Framebuffer|framebuffer]] resolution entries and {{ic|logo.nologo}}, parameters to the desired kernel:
 
  kernel /vmlinuz-linux root=/dev/disk/by-uuid/UUID ro logo.nologo quiet
 
  kernel /vmlinuz-linux root=/dev/disk/by-uuid/UUID ro logo.nologo quiet
  
 
===/etc/mkinitcpio.conf===
 
===/etc/mkinitcpio.conf===
  
Delete the HOOKS you do not need, and consider using just base (sometimes udev is needed too) along with the MODULES you need for your root device (and keyboard, instead of usbinput).
+
Delete the HOOKS you do not need, and consider using just base (sometimes [[udev]] is needed too) along with the [[Kernel modules|MODULES]] you need for your root device (and keyboard, instead of usbinput).
  
Read more in the [[mkinitcpio|mkinitcpio article]].
+
{{Warning|Read more about what hooks are required in the [[mkinitcpio]] article. Removing required hooks can render your system unusable!}}
  
 
===/etc/rc.conf===
 
===/etc/rc.conf===
In the network section, make sure you only load the network interface you need. Manually configuring your network is also faster than using dhcp. Then find and remove all DAEMONS you do not need.
+
In the network section, make sure you only load the network interface you need. Manually configuring your network with a static IP address is also faster than using DHCP.
 +
 
 +
Then find and remove all DAEMONS that you do not need.
 
  DAEMONS=(alsa network gdm)
 
  DAEMONS=(alsa network gdm)
  
Next, move your Login manager (in this case 'gdm') to the front, and background all DAEMONS.
+
Next, move your login manager (in this case {{Pkg|gdm}}) to the front, and background all DAEMONS.
 
  DAEMONS=(@gdm @alsa @network)
 
  DAEMONS=(@gdm @alsa @network)
  
Line 69: Line 69:
 
  DAEMONS=(syslog-ng @acpid arptables iptables network pdnsd @alsa @dbus @mpd @crond @sensors @ntpd @dropboxd)
 
  DAEMONS=(syslog-ng @acpid arptables iptables network pdnsd @alsa @dbus @mpd @crond @sensors @ntpd @dropboxd)
  
You should try to background as many DAEMONS as possible, making sure to start dependent DAEMONS after what they require (in the above example, pdnsd depends on network, ntpd and dropboxd depend on pdnsd and network, because 127.0.0.1 is the dns server). You can still background daemons that are required by other things (dbus is required by the Xorg), but they need enough time to start (it can take some experimentation to get it all to work well).
+
You should try to background as many DAEMONS as possible, making sure to start dependent DAEMONS after what they require (in the above example, {{ic|pdnsd}} depends on {{ic|network}}, {{ic|ntpd}} and {{ic|dropboxd}} depend on {{ic|pdnsd}} and {{ic|network}}, because 127.0.0.1 is the DNS server). You can still background daemons that are required by other things ({{ic|dbus}} is required by [[Xorg]]), but they need enough time to start (it can take some experimentation to get it all to work well).
  
 
=== /etc/rc.sysinit ===
 
=== /etc/rc.sysinit ===
This script is responsible for the majority of output you see during boot, meaning this is a system-critical configuration file which looks up other files like ''rc.conf'' and loads modules, sets up mounts, handles errors, and basically tries to be your best friend.
+
This script is responsible for the majority of output you see during boot, meaning this is a system-critical configuration file which looks up other files like {{ic|/etc/[[rc.conf]]}} and loads modules, sets up mounts, handles errors, and basically tries to be your best friend.
  
There are certain lines here which you may not need. Removing or commenting them out may save you a few seconds at most. Do this at your own risk. For example, if you do not have RAID, LVM or encryption, then you would not need any lines concerning that.
+
There are certain lines here which you may not need. Removing or commenting them out may save you a few seconds at most. Do this at your own risk. For example, if you do not have [[RAID]], [[LVM]] or encryption, then you would not need any lines concerning that.
  
It's also possible to add some ampersands (&) to make it more asynchronous, but be careful - lots of things are expected to be finished during later parts of the script.
+
It is also possible to add some ampersands ({{ic|&}}) to make it more asynchronous, but be careful - lots of things are expected to be finished during later parts of the script.
  
 
== Compiling a Custom Kernel ==
 
== Compiling a Custom Kernel ==
  
 
To decrease boot time, a stripped kernel is a must.
 
To decrease boot time, a stripped kernel is a must.
[[Kernel_Compilation_From_Source | Read more about compiling a kernel. ]]
+
[[Kernel Compilation|Read more about compiling a kernel.]]
  
 
== Additional Resources ==
 
== Additional Resources ==
Line 87: Line 87:
 
* [[e4rat]]
 
* [[e4rat]]
 
* [[udev]]
 
* [[udev]]
* [[Daemons]]
+
* [[Daemon]]
 
* [[rc.conf]]
 
* [[rc.conf]]
 
* [[mkinitcpio]]
 
* [[mkinitcpio]]

Revision as of 00:49, 1 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 end

Preface

Improving the boot performance of a system can provide reduced boot wait times and a means to learn more about how certain system files and scripts interact with one another. This article attempts to aggregate methods on how to improve the boot performance of an Arch Linux system.

Modifying boot files

/etc/inittab

Asynchronous startup

Note: Using this means there are no guarantees that daemons are all started before X. This can cause problems if your setup expects D-Bus to be running (ck-launch-session, GNOME, KDE, etc.).

The initscripts can be started asynchronously instead of running in a strict order.

# use once instead of wait
rc::sysinit:/etc/rc.sysinit
rs:S1:wait:/etc/rc.single
rm:2345:once:/etc/rc.multi
rh:06:once:/etc/rc.shutdown
su:S:once:/sbin/sulogin -p

TTY terminal management

agetty is Arch Linux's default terminal manager. By default it will generate six terminals, which can be accessed by typing Template:Keypress. To increase performance you can comment out unused terminals. It is important to not comment out the first two terminals (i.e. tty1 and tty2).

/etc/inittab
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
#c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
#c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
#c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
#c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux

Additionally, consider using a lighter terminal manager such as fgetty, which consists of the minimal tty manager, mingettyAUR, that has been stripped of printfs and compiled against dietlibc.

Note: fgetty currently does not support SHA-512 password hashing by default; a patched fgetty-pamAUR is available in the AUR. See SHA password hashes for more information.

You can install fgetty from the official repositories.

Then replace agetty with fgetty on the following lines:

/etc/inittab
 c1:2345:respawn:/sbin/fgetty tty1 linux
 c2:2345:respawn:/sbin/fgetty tty2 linux

/boot/grub/menu.lst

This file lets you modify the kernel command line at boot. A couple of ways to speed up boot time using this file to modify the kernel command line is to remove framebuffer entries and to set the kernel to use a low level of logging with quiet. For more kernel parameters and /boot/grub/menu.lst examples check out the page on GRUB. Remove existing vga= framebuffer resolution entries and logo.nologo, parameters to the desired kernel:

kernel /vmlinuz-linux root=/dev/disk/by-uuid/UUID ro logo.nologo quiet

/etc/mkinitcpio.conf

Delete the HOOKS you do not need, and consider using just base (sometimes udev is needed too) along with the MODULES you need for your root device (and keyboard, instead of usbinput).

Warning: Read more about what hooks are required in the mkinitcpio article. Removing required hooks can render your system unusable!

/etc/rc.conf

In the network section, make sure you only load the network interface you need. Manually configuring your network with a static IP address is also faster than using DHCP.

Then find and remove all DAEMONS that you do not need.

DAEMONS=(alsa network gdm)

Next, move your login manager (in this case gdm) to the front, and background all DAEMONS.

DAEMONS=(@gdm @alsa @network)

Another thing you could do about daemons is finding the best, or rather, "sweetest" arrangement.

DAEMONS=(syslog-ng @acpid arptables iptables network pdnsd @alsa @dbus @mpd @crond @sensors @ntpd @dropboxd)

You should try to background as many DAEMONS as possible, making sure to start dependent DAEMONS after what they require (in the above example, pdnsd depends on network, ntpd and dropboxd depend on pdnsd and network, because 127.0.0.1 is the DNS server). You can still background daemons that are required by other things (dbus is required by Xorg), but they need enough time to start (it can take some experimentation to get it all to work well).

/etc/rc.sysinit

This script is responsible for the majority of output you see during boot, meaning this is a system-critical configuration file which looks up other files like /etc/rc.conf and loads modules, sets up mounts, handles errors, and basically tries to be your best friend.

There are certain lines here which you may not need. Removing or commenting them out may save you a few seconds at most. Do this at your own risk. For example, if you do not have RAID, LVM or encryption, then you would not need any lines concerning that.

It is also possible to add some ampersands (&) to make it more asynchronous, but be careful - lots of things are expected to be finished during later parts of the script.

Compiling a Custom Kernel

To decrease boot time, a stripped kernel is a must. Read more about compiling a kernel.

Additional Resources