Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Optimization skills of Linux start-up time

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "Linux startup time optimization skills", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Linux startup time optimization skills" it!

A glitch or shutdown of a telecommunications equipment, even if only for a few seconds, can cause damage to countless Internet users. Therefore, for many time-stringent devices and telecommunications equipment, it is very important to add fast-start functions to their devices to help them get back to work quickly. Let's understand the Linux startup process from figure 1. Quick startup or quick restart plays a vital role in a variety of situations. In order to maintain the high availability and better performance of all services, the rapid startup of embedded devices is very important. Imagine a telecommunications device running a Linux operating system that does not enable quick startup, and all systems, services, and users that depend on this particular embedded device may be affected. It is very important for these devices to maintain the high availability of their services, for which rapid startup and restart play a vital role.

Figure 1: startup process

Monitoring tools and startup process

Before making changes to the machine, users should pay attention to many factors. This includes the current startup speed of the computer, as well as services, processes, or applications that consume resources and increase startup time.

Startup diagram

To monitor the startup speed and the various services started during startup, the user can install using the following command:

Sudo apt-get install pybootchartgui

Each time you start, the startup diagram will save a png file in the log, so that the user can view the png file to understand the system startup process and services. To do this, use the following command:

Cd / var/log/bootchart

The user may need an application to view the png file. Feh is an X11 image viewer for console users. Unlike most other image viewers, it does not have a sophisticated graphical user interface, but it is only used to display pictures. Feh can be used to view png files. You can install it using the following command:

Sudo apt-get install feh

You can use feh xxxx.png to view png files.

Figure 2: startup diagram

Figure 2 shows a bootstrap png file being viewed.

Systemd-analyze

However, boot diagrams are no longer required for Ubuntu versions later than 15.10. To get short information about startup speed, use the following command:

Systemd-analyze

Output of figure 3:systemd-analyze

Figure 3 shows the output of the command systemd-analyze.

The command systemd-analyze blame is used to print a list of all running units based on the time it takes to initialize. This information is useful and can be used to optimize startup time. Systemd-analyze blame does not show services with a service type of simple (Type=simple) because systemd believes that these services should be started immediately; therefore, the delay in initialization cannot be measured.

Output of figure 4:systemd-analyze blame

Figure 4 shows the output of systemd-analyze blame.

The following command prints a tree chain of time-critical service units:

Command systemd-analyze critical-chain

Figure 5 shows the output of the command systemd-analyze critical-chain.

Output of figure 5:systemd-analyze critical-chain

Steps to reduce startup time

Here are some steps that can reduce startup time.

BUM (Startup Manager)

BUM is a run-level configuration editor that allows initialization services to be configured when the system starts or restarts. It displays a list of each service that can be started at startup. Users can turn on and off individual services. BUM has a very clear graphical user interface and is very easy to use.

In Ubuntu 14.04, BUM can be installed using the following command:

Sudo apt-get install bum

To install it in versions later than 15.10, download the package from the link http://apt.ubuntu.com/p/bum.

Starting with basic services, disable services related to scanners and printers. If you don't use Bluetooth and other unwanted devices and services, you can also disable some of them. I strongly recommend that you learn the basics of services before disabling them, as this may affect your computer or operating system. Figure 6 shows the graphical user interface of BUM.

Figure 6:BUM

Edit the rc file

To edit the rc file, you need to change to the rc directory. This can be done using the following command:

Cd / etc/init.d

However, access to init.d requires root privileges, which basically contains start / stop scripts that control (start, stop, reload, start) daemons while the system is running or during startup.

The rc file in the init.d directory is called the run control run control script. During startup, init executes the rc script and plays its role. To improve startup speed, we can change the rc file. Open the rc file using any file editor (when you are in the init.d directory).

For example, you can change CONCURRENCY=none to CONCURRENCY= shell by typing vim rc. The latter allows some startup scripts to be executed at the same time rather than sequentially.

In the latest version of the kernel, this value should be changed to CONCURRENCY=make kernel le.

Figures 7 and 8 show a comparison of startup times before and after editing the rc file. It can be noticed that the startup speed has improved. The startup time before editing the rc file is 50.98 seconds, while the startup time after making changes to the rc file is 23.85 seconds.

However, the above-mentioned method of change does not work on operating systems after Ubuntu 15.10, because operating systems with the latest kernel use systemd files instead of init.d files.

Figure 7: startup speed before making changes to the rc file

Figure 8: startup speed after making changes to the rc file

E4rat

E4rat represents e4 to reduce access time reduced access time (only in the case of ext4 file systems). It is a project developed by Andreas Rid and Gundolf Kiefer. E4rat is an application that uses defragmentation to help get started quickly. It also speeds up the startup of the application. E4rat uses the reallocation of physical files to eliminate seek time and rotation delays, thus achieving higher disk transfer speeds.

E4rat is available as a .deb package, which you can download from its official website, http://e4rat.sourceforge.net/.

The ureadahead package installed by Ubuntu by default conflicts with e4rat. Therefore, you must install these packages using the following command:

Sudo dpkg purge ureadahead ubuntu-minimal

Now use the following command to install the dependency of e4rat:

Sudo apt-get install libblkid1 e2fslibs

Open the downloaded .deb file and install it. Now you need to collect startup data properly to make e4rat work.

Follow the steps given below to make e4rat run correctly and increase startup speed.

Access the Grub menu during startup. This can be done by holding down the shift button while the system is booting.

Select the option (kernel version) that is typically used for startup and press e.

Find the line that starts with linux / boot/vmlinuz and add the following code at the end of the line (press the space bar after the last letter of the sentence): init=/sbin/e4rat-collect or try-quiet splash vt.handsoff = 7 init=/sbin/e4rat-collect.

Now, press Ctrl+x to continue starting. This allows e4rat to collect data after startup. Work on this machine and open and close the application in the next two minutes.

Access the log file by going to the e4rat folder and using the following command: cd / var/log/e4rat.

If you don't find any log files, repeat the above process. Once the log file is ready, access the Grub menu again and press e for your options.

Type single at the end of the same line you edited before. This gives you access to the command line. If another menu appears, select return to normal Startup (Resume normal boot). If you don't know why you can't get to the command prompt, press Ctrl+Alt+F1.

After you see the login prompt, enter your login information.

Now enter the following command: sudo e4rat-realloc / var/lib/e4rat/startup.log. This process takes some time, depending on the disk speed of the machine.

Now restart your machine with the following command: sudo shutdown-r now.

Now we need to configure Grub to run e4rat at each startup.

Access the grub file using any editor. For example, gksu gedit / etc/default/grub.

Find the line that begins with GRUB CMDLINE LINUX DEFAULT= and add the following line between quotation marks and before any options: init=/sbin/e4rat-preload 18.

It should look like this: GRUB CMDLINE LINUX DEFAULT = init=/sbin/e4rat- preload quiet splash.

Save and close the Grub menu and update the Grub with sudo update-grub.

Restart the system and you will notice a significant change in startup speed.

Figures 9 and 10 show the difference in startup time before and after installing e4rat. The improvement of start-up speed can be noticed. It takes 22.32 seconds to start before using e4rat, but 9.065 seconds to start after using e4rat.

Figure 9: startup speed before using e4rat

Figure 10: startup speed after using e4rat

Some adjustments that are easy to make

Good startup speed can also be achieved with small adjustments, two of which are listed below.

SSD

Using solid-state devices instead of regular hard drives or other storage devices will certainly improve boot speed. SSD also helps speed up file transfer and running applications.

Disable the graphical user interface

Graphical user interfaces, desktop graphics, and window animations take up a lot of resources. Disabling the graphical user interface is another good way to get good startup speed.

At this point, I believe that everyone on the "Linux startup time optimization skills" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report