Linux "eight" - the boot process and service control

First, the structure of this chapter

Boot process

Start fault exclusion

Service Control and switching the operating level

Optimization of the startup process

Second, the boot process:

1, the boot code in the first sector of a disk. *** The first sector is damaged, the system will not boot.

2, the boot process overview

image.png

3, init process

    By the linux kernel load and run / sbin / init program

    The system is the first process

    PID (process mark) is always No. 1

Third, the exclusion of start fault:

1, repair MBR sector failure

   a, cause of the malfunction:

        Viruses, and other damage caused by ***

        Incorrect partitioning, disk read and write misuse

   b, Symptom:

       To find a boot program, start interrupt

       Unable to load the operating system, turned black

   c, Solutions:

       You should make a backup of work ahead

       In CD-ROM boot into emergency mode

       Restore from a backup file

The first step: mbr boot sector on the first disk backup to other non-local disks. Now first of all other disks to create a new folder mkdir / data for backup mbr boot sector.

image.png

Input dd if = / dev / sda of = / data / sda.mbr.bak bs = 512 count = 1

image.png

cover

2, repair the GRUB boot failure:

     a, cause of the malfunction:

       GRUB boot loader in the MBR is destroyed

       grub.conf file is missing, the boot configuration error

     b, Symptom:

       System boot stagnation, display "grub>" prompt

     c, Solutions

       Try to manually enter the boot command

       Enter emergency mode, rewritten or restored from a backup grub.conf

       Grub program to rebuild MBR sector

3, forget the root password

     a, cause of the malfunction:

         Forget the root password

     b, Symptom:

        You can not require root privileges management operations

        If there is no other available accounts, will not login

     c, Solutions

        Enter emergency mode, reset your password

Fourth, the system services control and switching the operating level

1, system services control:

   Common ways:

   systemctl control type service name

   Control Type

  start: Start

  stop: Stops

  restart: Restart

  reload: reload

  status: check the service status

2, run level of the system

   a, run-level view:

      :( runlevel command can only view switching operation level of the current run level)

      systemctl tool :( can view the default run level)

   b, temporary switch to run level

      init command: (init command parameter is the corresponding run level number)

      systemctl tools: (systemctl command parameter is the specific target)

Systemd unit type

Unit Type extension name Explanation
service .service Describe a system service
socket .socket A description of inter-process communication socket
device .device Describes a core recognition device file
mount .mount Describe a file system mount point
Automount .automount
Description Automatic a mount point of the file system
Swap .swap Describes a switching device memory or swap file
psth .path Describe a file system file or directory
timer .timer Describes a timer (for the scheduled tasks to achieve similar cron)
snapshot .snapshot To save the state of a systemd
scope .scope
Use systemd external bus interface creation process programmatically
Slice .slice Describes a set of management processes through the living Cgroup levels of the organization
Target .target Describe a group of cells systemd

So run level corresponding to the target Systemd

Run Level systemd的target Explanation
0 target Off, when using this level will host closed 
1 rescue.target Single-user mode, no password is required to log verification system, used for system maintenance
2 multi-user.target User-defined / run-level domain-specific default equal to 3
3 multi-user.target Full multi-user mode interface characters, most of the server host is running at this level
4
multi-user.taget User-defined / run-level domain-specific default equal to 3
5 graphical.target Multi-user mode graphical interface provides a graphical desktop environment
6 reboot.target Reboot, reboot the host will use this level


Fifth, to start the optimization process

1, system service management tools

    a, ntsysv tool (pseudo terminal, boot from the start)

       Intercommunication a visualization window

       You can run on an ASCII terminal.

       Facilitating the centralized management of multiple services

    b, systemctl tools (better)

       Intercommunication not provided, visualization window

       Single service management more efficient

2, start and control system services

    a, ntsysv system service management tools

        ntsysv

        ntsysv --level level list

    b, see the system start-up and control services

        View the status of system services start

        systemctl is-enabled service name

        Start setting the system state services

        systemctl enable / disable service name

        enable: next boot from the start disable: next time you turn not from Kai

Guess you like

Origin blog.51cto.com/14475876/2432479