Linux Startup speed-up

Source: Internet
Author: User
Linux Startup speed-up method-Linux Enterprise Application-Linux server application information. The following is a detailed description. Crazyboy1 writes 'linux is a very good operating system, but the long start time is one of the shortcomings of this system. Can I use some settings to shorten the Linux Startup time? Of course. This article will show you how to shorten the startup time without sacrificing the availability of the Linux system. To achieve this goal, you need to understand the various services of the system and their subordination, so that they can be started at the same time as allowed, thus greatly saving the system startup time.

Preparations

If you want to use the method described in this article to set the Linux system, you must first be familiar with the setting language of the Linux system. Setting the system startup process is a dangerous action, which may cause the system to fail to start. Once this happens, you 'd better restart the system and select single user mode to restore and restart the system. Of course, the most important thing is to back up important data before setting.

Next, we recommend that you test the modification before modifying the local system. If you only have one computer, we recommend that you use the user mode Linux system (UML) for testing. UML is a kernel patch that translates the Linux kernel into binary so that users can run the Linux system as they do with common software. In the event of an accident, only UML is lost, while the original system is safe and sound.

Linux Startup sequence and runlevel

Linux system startup involves multiple steps. Here we will introduce the system startup steps after the kernel is loaded. You can run the/sbin/runlevel command to view the current runlevel of the system. Runlevel is a number used in Linux to distinguish between advanced startup settings. These numbers are very common, and most of them have clear meanings. Taking Red Hat Linux as an example, its runlevel mainly includes the following types (see table 1 ):

How does init initialize the system?

Init can use an ASC Ⅱ setup file to learn how to change the runlevel of the system. In general, this setting file can guide init to execute the/etc/rc. d/rc command to obtain runlevel information.

System Service

The various system services required by the user are started by the rc command program. The potential services of the system are complicated. Most Linux systems generally only provide sshd (SecureShell Service), syslog (System Log tool), and lpd (Print Service) functions.

You can find all services in the/etc/rc. d/directory. If you open this directory, you will find that many services are just a shell program, which only directs other programs to complete the work. Some may ask, how does the rc program know which programs should be run at each runlevel? The answer is that under the/etc/rc. d/directory, there are some directories that correspond to their own runlevel. Their names are rc *. d/. For example, runlevel 5 is/etc/rc. d/rc5.d /. Each rc *. d/directory contains two symbolic links that can be connected to a specified service program in the/etc/init. d/directory.

Transformation

Service initiation and Termination

If you decide to start the Linux system and enter the graphic mode (runlevel 5), when init directs the rc command to run the program and informs it of the runlevel level, the rc Instruction Program will be directed to/etc/rc. d/rc5.d. The rc command program execution link can be divided into two parts. First, it will execute all the links whose names start with "K" and pass the "stop" parameter to them, and stop all services that these links point. After these services are stopped, the rc command program will execute all the links with names starting with "S" and pass the "start" parameter to them to start the services that these links point.

In addition, the rc command program can determine the execution sequence of the link based on the two decimal numbers of The Link name. Execute the Link first with a small number.

The following is an example to help you better understand the situation. When the user starts the system to enter runlevel 5, the first link to be executed is K05saslauthd, because it is prefixed with "K, and the last two decimal numbers must be smaller than other links starting with "K. The first start link to be executed is S05kudzu. The last execution is S99local. Below is the link to the program in runlevel 5.

# Cd/etc/rc. d/rc5.d

# Ls-al

Total 8

Drwxr-xr-x 2 root 4096 Jul 1509:29.

Drwxr-xr-x 10 root 4096 Jun 21 ..

Lrwxrwxrwx 1 root 19 Jan 1 2000 K05saslauthd-> ../init. d/saslauthd

Lrwxrwxrwx 1 root 20 Feb 1 2003 K15postgresql->.../init. d/postgresql

Lrwxrwxrwx 1 root 13 Jan 1 2000 K20nfs-> ../init. d/nfs

Lrwxrwxrwx 1 root 14 Jan 1 2000 K24irda->.../init. d/irda

Lrwxrwxrwx 1 root 17 Jan 1 2000 K35winbind-> ../init. d/winbind

Lrwxrwxrwx 1 root 15 Jan 1 2000 K50snmpd-> ../init. d/snmpd

......

Lrwxrwxrwx 1 root 18 Feb 8 11: 15 K92iptables-> ../init. d/iptables

Lrwxrwxrwx 1 root 19 Feb 1 2003 K95firstboot-> ../init. d/firstboot

Lrwxrwxrwx 1 root 15 Jan 1 2000 S05kudzu-> ../init. d/kudzu

Lrwxrwxrwx 1 root 14 Jun 21 08:55 S09isdn-> ../init. d/isdn

Lrwxrwxrwx 1 root 17 Jan 1 2000 S10network-> ../init. d/network

Lrwxrwxrwx 1 root 16 Jan 1 2000 S12syslog-> ../init. d/syslog

Lrwxrwxrwx 1 root 17 Jan 1 2000 S13portmap->.../init. d/portmap

Lrwxrwxrwx 1 root 17 Jan 1 2000 S14nfslock-> ../init. d/nfslock

Lrwxrwxrwx 1 root 18 Jan 1 2000 S17keytable-> ../init. d/keytable

Lrwxrwxrwx 1 root 16 Jan 1 2000 S20random-> ../init. d/random

Lrwxrwxrwx 1 root 16 Jun 21 08:52 S24pcmcia->.../init. d/pcmcia

Lrwxrwxrwx 1 root 15 Jan 1 2000 S25netfs-> ../init. d/netfs

Lrwxrwxrwx 1 root 14 Jan 1 2000 S26apmd-> ../init. d/apmd

Lrwxrwxrwx 1 root 16 Jan 1 2000 S28autofs-> ../init. d/autofs

Lrwxrwxrwx 1 root 14 Jan 1 2000 S55sshd-> ../init. d/sshd

Lrwxrwxrwx 1 root 20 Jan 1 2000 S56rawdevices-> ../init. d/rawdevices

Lrwxrwxrwx 1 root 16 Jan 1 2000 S56xinetd-> ../init. d/xinetd

Lrwxrwxrwx 1 root 14 Feb 1 2003 S58ntpd-> ../init. d/ntpd

Lrwxrwxrwx 1 root 13 Jun 21 :42 S60afs->.../init. d/afs

......

Lrwxrwxrwx 1 root 18 Jan 1 2000 S80sendmail-> ../init. d/sendmail

Lrwxrwxrwx 1 root 13 Jan 1 2000 S85gpm-> ../init. d/gpm

Lrwxrwxrwx 1 root 15 Mar 22 08:24 S85httpd-> ../init. d/httpd

......

Lrwxrwxrwx 1 root 14 Jul 15 09:29 S98wine-> ../init. d/wine

Lrwxrwxrwx 1 root 13 Feb 8 :26 S99db2-> ../init. d/db2

Lrwxrwxrwx 1 root 11 Jun 21 08:52 S99local->.../rc. local

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.