CN112000382B - Linux system starting method and device and readable storage medium - Google Patents

Linux system starting method and device and readable storage medium Download PDF

Info

Publication number
CN112000382B
CN112000382B CN202010867734.5A CN202010867734A CN112000382B CN 112000382 B CN112000382 B CN 112000382B CN 202010867734 A CN202010867734 A CN 202010867734A CN 112000382 B CN112000382 B CN 112000382B
Authority
CN
China
Prior art keywords
kernel
program
target
linux system
parameters
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010867734.5A
Other languages
Chinese (zh)
Other versions
CN112000382A (en
Inventor
黄观宇
毕浩然
谢正明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nsfocus Technologies Inc
Nsfocus Technologies Group Co Ltd
Original Assignee
Nsfocus Technologies Inc
Nsfocus Technologies Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nsfocus Technologies Inc, Nsfocus Technologies Group Co Ltd filed Critical Nsfocus Technologies Inc
Priority to CN202010867734.5A priority Critical patent/CN112000382B/en
Publication of CN112000382A publication Critical patent/CN112000382A/en
Application granted granted Critical
Publication of CN112000382B publication Critical patent/CN112000382B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4406Loading of operating system

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a method and a device for starting a Linux system and a readable storage medium. In the electronic equipment provided with the Linux system, the kernel program of the Linux system is started through the bootstrap program after the electronic equipment is started, the kernel program reads the target kernel parameter which is pre-configured and corresponds to the electronic equipment from the appointed position in the target file which is required to be loaded when the Linux system is started, after the kernel program successfully reads the target kernel parameter, the Linux system can be started according to the content of the loaded target kernel parameter and the target file which is restored after the kernel parameter is stripped, a method for how to configure the kernel parameter in the third-party bootstrap program is not required to be learned, the learning cost of system users and system developers is reduced, the Linux system can be matched with different hardware equipment, and the Linux system can be successfully started on different hardware equipment.

Description

Linux system starting method and device and readable storage medium
Technical Field
The present application relates to the field of network security technologies, and in particular, to a method and apparatus for starting a Linux system, and a readable storage medium.
Background
The Linux system is a stable and safe operating system and is widely applied to electronic equipment, and in the prior art, a kernel program needs to load a kernel parameter cmdline in the starting process of the Linux system to finish starting, wherein the kernel parameter cmdline is an essential parameter for starting the Linux system. The cmdline parameter may be used to specify partitions, serial ports, clocks, drivers, motherboard hardware feature parameters, virtualization feature parameters, CPU optimization parameters, memory optimization parameters, kernel optimization parameters, etc. used by the kernel to boot. The existing kernel program loading kernel parameters include two ways:
the first method is to directly write the cmdline parameter into the kernel source code, then compile the kernel code, put the compiled kernel code into hardware equipment, start with the cmdline parameter fixed in advance, because the cmdline parameter is written in the kernel code, the kernel parameter can not be changed, and the later maintenance cost is too high.
The second is to use the third-party bootstrap program to transfer the cmdline parameter into the kernel program, firstly transfer the cmdline parameter to the bootstrap program of the third party, the third-party bootstrap program loads the cmdline parameter, the cmdline parameter is transferred into the memory designated position through the bootstrap program of the third party, the third-party bootstrap program gives the authority to the kernel, and the kernel itself reads the cmdline of the corresponding memory position to start. Because the types of the third-party bootstrap programs are very many, different hardware manufacturers use different types of the third-party bootstrap programs, and the third-party bootstrap programs have the same principle of loading kernel parameters, but the used methods are very different, so that the same operating system cannot run on equipment of different hardware manufacturers at the same time.
Disclosure of Invention
The embodiment of the application provides a method and a device for starting a Linux system and a readable storage medium, which are used for providing a method for starting the Linux system after successfully loading kernel parameters without learning the method for configuring the kernel parameters in a third-party bootstrap program without considering the difference of the third-party bootstrap program.
In a first aspect, an embodiment of the present application provides a Linux system starting method, which is applied to an electronic device for installing a Linux system, and includes:
loading a guide program corresponding to the electronic equipment under the condition that the electronic equipment is started;
loading and starting a kernel program in the Linux system through the bootstrap program;
when the kernel program loads a target file, reading target kernel parameters corresponding to the electronic equipment from a designated position of the target file;
loading the target kernel parameters and peeling the target files restored after the kernel parameters by the kernel program to finish the starting of the Linux system;
the target file is a virtual disk file which is required to be loaded in the starting process of the Linux system, the virtual disk file comprises a necessary program required by the starting of the Linux system, and kernel parameters are preconfigured at the appointed position of the target file.
Optionally, before the kernel program loads the target file, the method further includes:
and modifying a source code program corresponding to the kernel program, so that when the kernel program is loaded, the kernel program reads the target kernel parameters from a designated position in the loaded target file.
Optionally, the preconfigured kernel parameters in the target file include kernel parameters of a plurality of different types of hardware that are integrated, the preconfigured kernel parameters in the target file are kernel parameters encrypted according to a preset encryption algorithm, and loading the target kernel parameters through the kernel program includes:
decrypting the target kernel parameters according to a decryption algorithm corresponding to the preset encryption algorithm;
and loading the decrypted target kernel parameters through the kernel program.
Optionally, the loading, by the kernel program, the decrypted target kernel parameter includes:
and carrying out validity detection on the decrypted target kernel parameters, and loading the decrypted target kernel parameters through the kernel program if the decrypted target kernel parameters are detected to be qualified.
Optionally, the method further comprises:
if the Linux system is started for the first time, after the Linux system is started, obtaining optimization parameters corresponding to the running state of the electronic equipment;
and adding the optimization parameters to the designated position of the target file as target kernel parameters, so that the kernel program can read the target kernel parameters from the designated position the next time the electronic device starts the linux system.
Optionally, the optimization parameters include any one or more of a core clock source optimization parameter, a large page memory optimization parameter, and a kdump log collection parameter.
Optionally, the target file includes an initrd file and/or an initrimfs file.
In a second aspect, an embodiment of the present application provides a Linux system starting apparatus, applied to an electronic device for installing a Linux system, including:
the first loading unit is used for loading a bootstrap program corresponding to the electronic equipment under the condition that the electronic equipment is started;
the second loading unit is used for loading and starting a kernel program in the Linux system through the bootstrap program;
the reading unit is used for reading target kernel parameters corresponding to the electronic equipment from a designated position of the target file when the kernel program loads the target file;
the starting unit is used for loading the target kernel parameters and restoring the target files after stripping the kernel parameters through the kernel program to finish the starting of the Linux system;
the target file is a virtual disk file which is required to be loaded in the starting process of the Linux system, the virtual disk file comprises a necessary program required by the starting of the Linux system, and kernel parameters are preconfigured at the appointed position of the target file.
Optionally, the device further includes a modifying unit, where the modifying unit is configured to modify, before the kernel program loads the target file, a source code program corresponding to the kernel program, so that when the kernel program is loaded, the kernel program reads the target kernel parameter from a specified location in the loaded target file.
Optionally, the preconfigured kernel parameters in the target file include kernel parameters of a plurality of different types of hardware that are integrated, the preconfigured kernel parameters in the target file are kernel parameters encrypted according to a preset encryption algorithm, and the starting unit is specifically configured to:
decrypting the target kernel parameters according to a decryption algorithm corresponding to the preset encryption algorithm;
and loading the decrypted target kernel parameters through the kernel program.
Optionally, the starting unit is specifically configured to:
and carrying out validity detection on the decrypted target kernel parameters, and loading the decrypted target kernel parameters through the kernel program if the decrypted target kernel parameters are detected to be qualified.
Optionally, the apparatus further comprises an optimizing unit, where the optimizing unit is configured to:
if the Linux system is started for the first time, after the Linux system is started, obtaining optimization parameters corresponding to the running state of the electronic equipment;
and adding the optimization parameters to the designated position of the target file as target kernel parameters, so that the kernel program can read the target kernel parameters from the designated position the next time the electronic device starts the linux system.
Optionally, the optimization parameters include any one or more of a core clock source optimization parameter, a large page memory optimization parameter, and a kdump log collection parameter.
Optionally, the target file includes an initrd file and/or an initrimfs file.
In a third aspect, an embodiment of the present application provides a Linux system starting apparatus, which is applied to an electronic device for installing a Linux system, where the Linux system starting apparatus includes a processor, and the processor is configured to implement the steps of the Linux system starting method described in the foregoing first aspect when executing a computer program stored in a memory.
In a fourth aspect, an embodiment of the present application provides a readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the Linux system startup method as described in the foregoing embodiment of the first aspect.
The above technical solutions in the embodiments of the present application at least have one or more of the following technical effects:
according to the technical scheme, in the electronic equipment provided with the Linux system, the kernel program of the Linux system is started through the bootstrap program after the electronic equipment is started, the kernel program can read the target kernel parameter which is well configured in advance and corresponds to the electronic equipment from the appointed position in the target file which is required to be loaded when the Linux system is started regardless of the configuration mode of the kernel parameter in the bootstrap program of the electronic equipment, and after the kernel program successfully reads the target kernel parameter, the Linux system can be started according to the content of the loaded target kernel parameter and the target file which is restored after the kernel parameter is stripped, so that a method for how to configure the kernel parameter in the third-party bootstrap program is not needed, the learning cost of system users and system developers is reduced, the Linux system can be adapted to different hardware equipment, and the Linux system can be successfully started on different hardware equipment.
Drawings
FIG. 1 is a flowchart of a method for starting a Linux system according to a first embodiment of the present application;
FIG. 2 is a detailed schematic diagram of the Linux system according to the first embodiment of the present application;
FIG. 3 is an interface diagram of a Linux system when a kernel parameter cmdline is transferred to a kernel program by a bootstrap grub.cfg according to a first embodiment of the present application;
FIG. 4 is an interface diagram of a bzimage started by reading kernel parameters in initrd. Gz according to a first embodiment of the present application;
FIG. 5 is a schematic diagram of a Linux system startup device according to a second embodiment of the present application;
fig. 6 is a schematic diagram of a Linux system startup device according to a third embodiment of the present application.
Detailed Description
The embodiment of the application provides a method and a device for starting a Linux system and a readable storage medium, which are used for providing a method for starting the Linux system after successfully loading kernel parameters without learning the method for configuring the kernel parameters in a third-party bootstrap program without considering the diversity of the third-party bootstrap program. The method is applied to the electronic equipment for installing the Linux system, and comprises the following steps: loading a guide program corresponding to the electronic equipment under the condition that the electronic equipment is started; loading and starting a kernel program in the Linux system through the bootstrap program; when the kernel program loads a target file, reading target kernel parameters corresponding to the electronic equipment from a designated position of the target file; loading the target kernel parameters and peeling the target files restored after the kernel parameters by the kernel program to finish the starting of the Linux system; the target file is a virtual disk file which is required to be loaded in the starting process of the Linux system, the virtual disk file comprises a necessary program required by the starting of the Linux system, and kernel parameters are preconfigured at the appointed position of the target file.
The following detailed description of the technical solutions of the present application will be given by way of the accompanying drawings and specific embodiments, and it should be understood that the specific features of the embodiments and embodiments of the present application are detailed descriptions of the technical solutions of the present application, and not limiting the technical solutions of the present application, and that the embodiments and technical features of the embodiments of the present application may be combined with each other without conflict.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
Examples
Referring to fig. 1, a first embodiment of the present application provides a Linux system starting method applied to an electronic device installed with a Linux system, where the Linux system starting method includes the following steps:
s101: loading a guide program corresponding to the electronic equipment under the condition that the electronic equipment is started;
s102: loading and starting a kernel program in the Linux system through the bootstrap program;
s103: when the kernel program loads a target file, reading target kernel parameters corresponding to the electronic equipment from a designated position of the target file;
s104: and loading the target kernel parameters and stripping the restored target files after the kernel parameters by the kernel program to finish the starting of the Linux system.
The target file is a virtual disk file which is required to be loaded in the starting process of the Linux system, the virtual disk file comprises a necessary program required by the starting of the Linux system, and kernel parameters are preconfigured at the appointed position of the target file.
If the Linux system is started for the first time, naming the kernel program and the target file in the Linux system according to the configuration rule of the bootstrap program before the kernel program in the Linux system is started by the bootstrap program.
Specifically, the method in this embodiment is mainly applied to an electronic device for installing a Linux system, where the electronic device may be an electronic device such as a computer, a mobile phone, a tablet computer, or other electronic devices, and this embodiment is not limited herein.
In the prior art, the Linux system must transmit the kernel parameters into the kernel program according to the rule of writing the kernel parameters of the bootstrap program, and the writing rules corresponding to the bootstrap programs provided by different hardware are different, so that when the Linux system runs in different hardware devices, the Linux system needs to learn the rule of writing the kernel parameters of the bootstrap program in the corresponding hardware devices, then the Linux system can be started after successfully loading the kernel parameters, and the suitability is poor.
In order to solve the above-mentioned problem, in the method of this embodiment, first, through step S101, when the electronic device is started, a boot program is loaded, and the boot program of the electronic device has a specific configuration rule to configure various parameters, if the Linux system is started for the first time, after the boot program is loaded, the names of the kernel program and the target file in the Linux system are named according to the configuration rule based on the configuration rule in the boot program, so, through step S102, the kernel program in the Linux system can be loaded and started successfully by the boot program. In this embodiment, the kernel program is mainly taken as a bzImage as an example for detailed explanation, and bzImage is a compressed executable kernel form, however, the kernel program can be configured according to the actual environment, and the embodiment is not limited thereto.
Since the kernel program bzImage does not need to be introduced into the kernel parameter by the bootstrap program, but reads the kernel parameter from the target file initrd. Gz in a different manner, before the kernel program loads the target file, the method further includes: and modifying a source code program corresponding to the kernel program, so that when the kernel program is loaded, the kernel program reads the target kernel parameters from a designated position in the loaded target file.
Specifically, in this embodiment, please refer to the detailed start-up procedure of the Linux system in fig. 2, the source code program kemel_src of the kernel program bzImage may be modified by the script program, the kernel parameter cmdline flow may be read in a self-defined manner, and then compiled into the kernel program bzImag, so that the kernel program bzImag reads the target kernel parameter from the target file initrd.
In this embodiment, the target file is a virtual disk file that must be loaded in the Linux system starting process, where the virtual disk file includes a necessary program required for the Linux system starting, including initrd files, such as: initrd.gz files may also include initrimfs files such as: an initrimfs. The initrimfs and initrd store the same file, the two formats are different, and the parameters of the cmdline band are different. In this embodiment, let's take the reference initrd. Gz as an example, the whole name of initrd is initial ramdisk (initial RAM disk system or temporary root partition), and the suffix gz indicates that it is a compressed file of a ginzip. initrd. Gz functions to emulate a root partition in memory just before the real file system (root partition) is not yet available at the time of start-up of the Linux system. The root file system contains the necessary programs to achieve startup. Such as the tool "insmod" that loads the kernel module into the kernel. Of course, in the implementation process, the target file may also be another file that must be loaded when the Linux system is started, where the embodiment is not limited.
In the method in this embodiment, for an object file initrd.gz in the Linux system, a kernel parameter is configured in advance at a formulated position of the object file initrd.gz, where the kernel parameter configured in advance in the object file includes kernel parameters of a plurality of integrated different types of hardware.
Specifically, in this embodiment, in order to enable the Linux system to run on different hardware devices and different manufacturers' hardware devices, in order to support specific hardware characteristics, kernel parameters cmdline configured correspondingly are different from each other, and to implement compatibility with different hardware devices, first, kernel parameters corresponding to existing hardware devices of all manufacturers installing the Linux system need to be integrated, then differences are compared, and repeated removal is performed, so that, for example, if a manufacturer a needs parameters P1 and B needs parameters P2, and finally kernel parameters in a target file initrd. Gz include P1 and P2, the Linux system can be compatible with hardware devices of a manufacturer a and B manufacturer. In the implementation process, as many kernel parameters cmdline as possible can be integrated in the target file initrd. Gz, so as to better adapt to hardware devices of more factories.
Further, in this embodiment, before integrating the kernel parameter cmdline into the target file initrd. Gz, the kernel parameter cmdline may also be encrypted in advance. Specifically, the object file initrd. Gz describes the flow of modification from the optical disc mounting system perspective: firstly, the commonly used INITRD. Tgz is obtained FROM the optical disc, and then the integrated kernel parameters are encrypted by an internal preset encryption algorithm, for example, the integrated kernel parameters can be encrypted into binary strings not exceeding READSIZE_FROM_INITRD. Writing the encrypted character string into the appointed position of INITRD. Tgz through a tool, filling the length READSIZE_FROM_INITRD with preset characters if the length is 1024 bits and filling the length with '0', putting the modified kernel program and the modified INITRD. Gz back to the optical disk, and enabling the subsequent use flow to be consistent with the common system. In a specific implementation process, the kernel parameter cmdline may be placed in the header of the target file INITRD. Gz, and the length is READSIZE_FROM_INITRD, which is assumed to occupy 1024 bits.
Because the kernel parameter cmdline added in the target file initrd.gz is in an encryption state, the kernel parameter obtained from the initrd.gz is ciphertext, any three parties cannot crack the content of the kernel parameter, and the whole target file initrd.gz is also in the encryption state, so that the difficulty of cracking the kernel parameter cmdline and initrd.gz by a bad attacker is improved.
Thus, in step S103, when the kernel program loads the target file, the target kernel parameter corresponding to the electronic device is read from the designated location of the target file. Specifically, in this embodiment, in the foregoing embodiment, when modifying the source code program kemel_src of the kernel program bzImage and custom reading the kernel parameter cmdline flow, it is specified that the kernel program bzImage needs to read the encrypted kernel parameter with the length of read_from_initrd FROM the specified location of the target file initrd.gz, and then when loading the target kernel parameter through the kernel program in step S104, the following steps may be implemented:
decrypting the target kernel parameters according to a decryption algorithm corresponding to the preset encryption algorithm;
loading the decrypted target kernel parameters through the kernel program; the loading the decrypted target kernel parameter by the kernel program includes: and carrying out validity detection on the decrypted target kernel parameters, and loading the decrypted target kernel parameters through the kernel program if the decrypted target kernel parameters are detected to be qualified.
Specifically, in this embodiment, please refer to fig. 2, the kernel program bzimage reads the binary parameter of the read_from_initrd length FROM the INITRD. And stripping the part filled with the special character 0 to obtain an encrypted kernel parameter cmdline with the effective bit number, decrypting the binary cmdline by using a decryption algorithm corresponding to a preset encryption algorithm, and indicating that the binary cmdline is tampered by a person and directly quitting the starting after the decryption failure.
Further, the validity of the decrypted parameters is checked, a check rule is preset, the validity of the parameters is checked, and the safety of the system is ensured. For example, if the decrypted kernel parameter has preset characters such as "single", "init=", the kernel parameter is likely to be tampered, and the illegal process is considered to be started, so that the illegal process is stopped and tampering is prevented. If the detection is qualified, the target file initrd.gz is restored to a state before the kernel parameter is embedded, namely, the kernel parameter is stripped from a designated position and then recombined into a new file initrd.gz, and the kernel program bzimage reloads the restored initrd.gz.
Further, since the decrypted kernel parameters include kernel parameters integrating multiple types of hardware devices, the kernel program bzimage only needs to extract target kernel parameters related to the currently running electronic device, and store the decrypted target kernel parameters into variables of kernel storage parameters, even if the original boot program transfers the kernel parameters related to the electronic device, the kernel program bzimage replaces the kernel parameters transferred by the boot program with the target kernel parameters read from the target file initrd. In this way, bad cracking personnel may attempt to modify kernel parameters through the bootstrap program to change the kernel starting flow to start the system, so in this embodiment, the target kernel parameters read from the target file initrd. Gz are adopted to replace the original kernel parameters transmitted from the bootstrap program by using the kernel program bzimage, so that the system can be effectively ensured not to be cracked by an attacker. The subsequent process returns to the logic of normal kernel start, and this embodiment is not described here again.
Further, in this embodiment, if the Linux system is started for the first time, after the completion of the start of the Linux system, an optimization parameter corresponding to the running state of the electronic device is obtained;
and adding the optimization parameters to the designated position of the target file as target kernel parameters, so that the kernel program can read the target kernel parameters from the designated position the next time the electronic device starts the linux system. The optimization parameters comprise any one or more of a kernel clock source optimization parameter, a large page memory optimization parameter and a kdump log collection parameter.
Specifically, in this embodiment, modification and addition of some kernel parameters are also involved, specifically, some kernel parameters p3 of optimization class are involved, and after the Linux system completes initial startup in the related electronic device, optimization configuration is performed according to the running state of the electronic device. Such as: and determining the kernel parameters of the optimization class adapted to the CPU, the memory and the like of the electronic equipment according to the parameters of the running time. The kernel parameters may include a kernel clock source optimization parameter, a large page memory optimization parameter, a kdump log collection parameter, and the like, but may also be other parameters, which are not limited in this embodiment. Furthermore, the kernel parameter cmdline of the optimized class p3 can be added to the designated position of the target file initrd. Gz by the manner of adding the kernel parameter cmdline to the designated position of the target file initrd. Gz, so that the target file initrd. Gz covers the complete kernel parameter, and when the next starting, the initialization starting is performed according to the original kernel parameter, the initialization starting is performed according to the new kernel parameter of the optimized class, and in the subsequent use process, the Linux system can better run in the electronic equipment. The manner of adding the kernel parameter p3 of the optimization class to the specified location of the target file initrd.gz may refer to the details of adding the kernel parameter cmdline to the specified location of the target file initrd.gz, which is not described in detail in this embodiment.
In order to better understand the difference between the method in this embodiment and the existing method of performing kernel parameter input to kernel program start through a bootstrap, this embodiment tests two existing modes, and uses the configuration of equipment manufacturer grub (a bootstrap) as an illustration, fig. 3 is an interface diagram when the Linux system starts when kernel parameter cmdline is transferred to the kernel program through the bootstrap grub.cfg, and fig. 4 is an interface diagram when the bzimage starts by reading kernel parameter in initrd.gz through the method in this embodiment. It can be seen that, since the characters following the character/bzimage in fig. 3 are all kernel parameters cmdline, the kernel parameters are visible in the existing manner, so that the kernel parameters can be easily utilized by illegal parties to attack the system. The method in this embodiment does not care about the kernel parameter cmdline transmitted by the bootstrap program, and uses the kernel parameter in the Linux system's initrd. Gz, so that the bootstrap program no longer needs to configure the kernel parameter, and even if the kernel parameter is configured, the bootstrap program will be covered by the kernel parameter in the initrd. Gz. As the file initrd. Gz in the Linux system is an encryption state, as can be seen from fig. 4, by the mode in this embodiment, in the starting process of the Linux system, the kernel parameter is not visible, so that other attacks can be avoided from attacking the system according to the file initrd. Gz.
Compared with the existing mode, the method in the embodiment has the advantages that the execution flow of the kernel program is changed, the kernel program is started in a mode without parameters, kernel parameters are acquired from the setting position of initrd.gz, any kernel parameters transmitted in a bootstrap mode are covered by the kernel parameters acquired from the initrd.gz, and finally the initialization starting of the system is carried out by the kernel parameters in the initrd.gz. Since the kernel parameters obtained from initrd. Gz are ciphertext, any three-party personnel cannot crack the contents of the kernel parameters. The kernel parameters are controlled by an internal developer, the parameters which are carried by the bootstrap program and are transmitted to the kernel are covered by the parameters in initrd. Gz, any person attempting to crack cannot influence the running logic of the kernel by modifying the cmdline of the bootstrap program, and the attack on the Linux system by utilizing the kernel parameters can be effectively reduced.
Referring to fig. 5, a second embodiment of the present application provides a Linux system starting apparatus, which is applied to an electronic device for installing a Linux system, and includes:
a first loading unit 501, configured to load a boot program corresponding to the electronic device when the electronic device is turned on;
a second loading unit 502, configured to load and start a kernel program in the Linux system through the bootstrap program;
a reading unit 503, configured to read, when the kernel program loads a target file, a target kernel parameter corresponding to the electronic device from a specified location of the target file;
the starting unit 504 is configured to load the target kernel parameter and the restored target file after stripping the kernel parameter through the kernel program, so as to complete the Linux system starting;
the target file is a virtual disk file which is required to be loaded in the starting process of the Linux system, the virtual disk file comprises a necessary program required by the starting of the Linux system, and kernel parameters are preconfigured at the appointed position of the target file.
In an optional implementation manner, the device further includes a modification unit, where the modification unit is configured to modify, before the kernel program loads the target file, a source code program corresponding to the kernel program, so that when the kernel program is loaded, the kernel program reads the target kernel parameter from a specified location in the loaded target file.
In an optional implementation manner, the preconfigured kernel parameters in the target file include kernel parameters of a plurality of integrated different types of hardware, the preconfigured kernel parameters in the target file are kernel parameters encrypted according to a preset encryption algorithm, and the starting unit 504 is specifically configured to:
decrypting the target kernel parameters according to a decryption algorithm corresponding to the preset encryption algorithm;
and loading the decrypted target kernel parameters through the kernel program.
In an alternative implementation, the starting unit 504 is specifically configured to:
and carrying out validity detection on the decrypted target kernel parameters, and loading the decrypted target kernel parameters through the kernel program if the decrypted target kernel parameters are detected to be qualified.
In an alternative implementation, the apparatus further includes an optimizing unit, where the optimizing unit is configured to:
if the Linux system is started for the first time, after the Linux system is started, obtaining optimization parameters corresponding to the running state of the electronic equipment;
and adding the optimization parameters to the designated position of the target file as target kernel parameters, so that the kernel program can read the target kernel parameters from the designated position the next time the electronic device starts the linux system.
In an alternative implementation, the optimization parameters include any one or more combinations of core clock source optimization parameters, large page memory optimization parameters, and kdump log collection parameters.
In an alternative implementation, the target file includes an initrd file and/or an initrimfs file.
The detailed process of the Linux system starting device in the present embodiment for performing the Linux system starting is described in detail in the foregoing first embodiment, and reference may be made to the content in the first embodiment, which is not described herein again.
Referring to fig. 6, a third embodiment of the present application provides a Linux system starting apparatus, where the apparatus of the embodiment includes: the processor 601, the memory 602, and a computer program stored in the memory and executable on the processor, for example, a program corresponding to the Linux system startup method in the first embodiment. The processor, when executing the computer program, implements the steps in path detection in the first embodiment described above. Alternatively, the processor, when executing the computer program, performs the functions of the modules/units in the apparatus of the second embodiment.
The computer program may be divided into one or more modules/units, which are stored in the memory and executed by the processor to accomplish the present application, for example. The one or more modules/units may be a series of computer program instruction segments capable of performing the specified functions, which instruction segments are used to describe the execution of the computer program in the computer device. For example, the computer program may be divided into functions of a first loading unit, a second loading unit, a reading unit, and a starting unit, where the specific functions of the units are as follows:
the first loading unit is used for loading a bootstrap program corresponding to the electronic equipment under the condition that the electronic equipment is started;
the second loading unit is used for loading and starting a kernel program in the Linux system through the bootstrap program;
the reading unit is used for reading target kernel parameters corresponding to the electronic equipment from a designated position of the target file when the kernel program loads the target file;
the starting unit is used for loading the target kernel parameters and restoring the target files after stripping the kernel parameters through the kernel program to finish the starting of the Linux system;
the target file is a virtual disk file which is required to be loaded in the starting process of the Linux system, the virtual disk file comprises a necessary program required by the starting of the Linux system, and kernel parameters are preconfigured at the appointed position of the target file.
The device may include, but is not limited to, a processor, a memory. It will be appreciated by those skilled in the art that the schematic diagram 6 is merely an example of a computer apparatus and is not limiting of the apparatus, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., the apparatus may further include input and output devices, network access devices, buses, etc.
The processor 601 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like that is a control center of the computer device, connecting various parts of the overall computer device using various interfaces and lines.
The memory 602 may be used to store the computer programs and/or modules, and the processor may perform various functions of the computer device by executing or executing the computer programs and/or modules stored in the memory, and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data (such as audio data, video data, etc.) created according to the use of the cellular phone, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart Media Card (SMC), secure Digital (SD) Card, flash Card (Flash Card), at least one disk storage device, flash memory device, or other volatile solid-state storage device.
Further, the apparatus includes a processor 601 having the following functions:
loading a guide program corresponding to the electronic equipment under the condition that the electronic equipment is started;
loading and starting a kernel program in the Linux system through the bootstrap program;
when the kernel program loads a target file, reading target kernel parameters corresponding to the electronic equipment from a designated position of the target file;
loading the target kernel parameters and peeling the target files restored after the kernel parameters by the kernel program to finish the starting of the Linux system;
the target file is a virtual disk file which is required to be loaded in the starting process of the Linux system, the virtual disk file comprises a necessary program required by the starting of the Linux system, and kernel parameters are preconfigured at the appointed position of the target file.
Further, the apparatus includes a processor 601 having the following functions:
before the kernel program loads a target file, modifying a source code program corresponding to the kernel program, so that when the kernel program is loaded, the kernel program reads the target kernel parameters from a designated position in the loaded target file.
Further, the preconfigured kernel parameters in the target file include kernel parameters of a plurality of integrated hardware of different types, the preconfigured kernel parameters in the target file are kernel parameters encrypted according to a preset encryption algorithm, and the processor 601 included in the device further has the following functions:
decrypting the target kernel parameters according to a decryption algorithm corresponding to the preset encryption algorithm;
and loading the decrypted target kernel parameters through the kernel program.
Further, the apparatus includes a processor 601 having the following functions:
and carrying out validity detection on the decrypted target kernel parameters, and loading the decrypted target kernel parameters through the kernel program if the decrypted target kernel parameters are detected to be qualified.
Further, the apparatus includes a processor 601 having the following functions:
if the Linux system is started for the first time, after the Linux system is started, obtaining optimization parameters corresponding to the running state of the electronic equipment;
and adding the optimization parameters to the designated position of the target file as target kernel parameters, so that the kernel program can read the target kernel parameters from the designated position the next time the electronic device starts the linux system.
Further, the optimization parameters include any one or more combinations of core clock source optimization parameters, large page memory optimization parameters, and kdump log collection parameters.
Further, the target file includes an initrd file and/or an initrimfs file.
A fourth embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and the functional units integrated with the Linux system startup device in the second embodiment of the present application may be stored in a computer-readable storage medium if implemented as software functional units and sold or used as independent products. Based on such understanding, the present application may implement all or part of the flow in the Linux system startup method of the first embodiment, or may be implemented by instructing related hardware by a computer program, where the computer program may be stored in a computer readable storage medium, and the computer program may implement the steps of each method embodiment when executed by a processor. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (10)

1. The Linux system starting method is applied to the electronic equipment provided with the Linux system and is characterized by comprising the following steps:
loading a guide program corresponding to the electronic equipment under the condition that the electronic equipment is started;
loading and starting a kernel program in the Linux system through the bootstrap program;
when the kernel program loads a target file, reading target kernel parameters corresponding to the electronic equipment from a designated position of the target file;
loading the target kernel parameters and the restored target files after stripping the kernel parameters through the kernel program, and completing the starting of the Linux system;
wherein the target file is a virtual disk file which is required to be loaded in the starting process of the Linux system, the virtual disk file comprises a necessary program required by the starting of the Linux system, kernel parameters are pre-configured at the appointed position of the target file,
the appointed position of the target file is preconfigured with kernel parameters, and the method specifically comprises the following steps:
the pre-configured kernel parameters in the target file comprise the kernel parameters of the integrated multiple different types of hardware.
2. The method of claim 1, wherein prior to the kernel loading the target file, the method further comprises:
and modifying a source code program corresponding to the kernel program, so that when the kernel program is loaded, the kernel program reads the target kernel parameters from a designated position in the loaded target file.
3. The method of claim 1, wherein the pre-configured kernel parameters in the target file are kernel parameters encrypted according to a pre-set encryption algorithm, and the loading the target kernel parameters by the kernel program comprises:
decrypting the target kernel parameters according to a decryption algorithm corresponding to the preset encryption algorithm;
and loading the decrypted target kernel parameters through the kernel program.
4. The method of claim 3, wherein loading the decrypted target kernel parameters by the kernel program comprises:
and carrying out validity detection on the decrypted target kernel parameters, and loading the decrypted target kernel parameters through the kernel program if the decrypted target kernel parameters are detected to be qualified.
5. The method of claim 1, wherein the method further comprises:
if the Linux system is started for the first time, after the Linux system is started, obtaining optimization parameters corresponding to the running state of the electronic equipment;
and adding the optimized parameter to the appointed position of the target file as a target kernel parameter, so that the kernel program can read the target kernel parameter from the appointed position when the electronic device starts the Linux system next time.
6. The method of claim 5, wherein the optimization parameters include any one or more combinations of core clock source optimization parameters, large page memory optimization parameters, and kdump log collection parameters.
7. The method according to any of claims 1-6, wherein the target file comprises an initrd file and/or an initrimfs file.
8. The Linux system starting device is applied to electronic equipment provided with a Linux system and is characterized by comprising:
the first loading unit is used for loading a bootstrap program corresponding to the electronic equipment under the condition that the electronic equipment is started;
the second loading unit is used for loading and starting a kernel program in the Linux system through the bootstrap program;
the reading unit is used for reading target kernel parameters corresponding to the electronic equipment from a designated position of the target file when the kernel program loads the target file;
the starting unit is used for loading the target kernel parameters and the restored target files after stripping the kernel parameters through the kernel program to finish the starting of the Linux system;
wherein the target file is a virtual disk file which is required to be loaded in the starting process of the Linux system, the virtual disk file comprises a necessary program required by the starting of the Linux system, kernel parameters are pre-configured at the appointed position of the target file,
the appointed position of the target file is preconfigured with kernel parameters, and the method specifically comprises the following steps:
the pre-configured kernel parameters in the target file comprise the kernel parameters of the integrated multiple different types of hardware.
9. A Linux system starting device applied to an electronic device provided with a Linux system, wherein the Linux system starting device comprises a processor, and the processor is used for implementing the steps of the Linux system starting method according to any one of claims 1-7 when executing a computer program stored in a memory.
10. A readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the Linux system startup method according to any one of claims 1-7.
CN202010867734.5A 2020-08-26 2020-08-26 Linux system starting method and device and readable storage medium Active CN112000382B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010867734.5A CN112000382B (en) 2020-08-26 2020-08-26 Linux system starting method and device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010867734.5A CN112000382B (en) 2020-08-26 2020-08-26 Linux system starting method and device and readable storage medium

Publications (2)

Publication Number Publication Date
CN112000382A CN112000382A (en) 2020-11-27
CN112000382B true CN112000382B (en) 2023-10-13

Family

ID=73470859

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010867734.5A Active CN112000382B (en) 2020-08-26 2020-08-26 Linux system starting method and device and readable storage medium

Country Status (1)

Country Link
CN (1) CN112000382B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114637559B (en) * 2020-12-15 2023-11-24 博泰车联网科技(上海)股份有限公司 Method, system, equipment and storage medium for displaying startup interface
CN113505074A (en) * 2021-07-15 2021-10-15 北京紫光展锐通信技术有限公司 Linux system debugging method and device and electronic equipment
CN114296835B (en) * 2021-12-31 2024-02-13 奇安信科技集团股份有限公司 Application program starting method and device

Citations (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1828538A (en) * 2006-03-31 2006-09-06 浙江大学 Method for realizing operating procedure directly from file system in embedded system
JP2010282645A (en) * 2010-07-26 2010-12-16 Victor Co Of Japan Ltd Linux program start-up system
CN103577210A (en) * 2012-08-06 2014-02-12 广州三星通信技术研究有限公司 System and method for mounting between mobile terminals
CN103761124A (en) * 2014-01-06 2014-04-30 武汉烽火富华电气有限责任公司 Method for starting embedded-type Linux system used for protection measuring and controlling device
US8874888B1 (en) * 2011-01-13 2014-10-28 Google Inc. Managed boot in a cloud system
CN104751062A (en) * 2013-12-31 2015-07-01 研祥智能科技股份有限公司 Method and device improving operation system reliability
CN106502739A (en) * 2016-10-31 2017-03-15 北京深之度科技有限公司 Method, device and the computing device that boot disk is made using movable storage device
CN107885536A (en) * 2017-11-30 2018-04-06 建荣半导体(深圳)有限公司 Startup method, embeded processor and the storage device of a kind of embeded processor
CN109254805A (en) * 2018-09-21 2019-01-22 武汉斗鱼网络科技有限公司 A kind of application self-start method, terminal installation and readable storage medium storing program for executing
JP2019032610A (en) * 2017-08-04 2019-02-28 富士通株式会社 Computer starting method and computer
CN109426591A (en) * 2017-09-04 2019-03-05 武汉斗鱼网络科技有限公司 Guard the method and apparatus of multiple processes of the single program of windows
CN109634687A (en) * 2018-12-19 2019-04-16 恒为科技(上海)股份有限公司 The starting method and apparatus of application software in a kind of embedded Linux system
CN109840096A (en) * 2019-01-02 2019-06-04 紫光华山信息技术有限公司 The installation method and device of operating system
CN109857468A (en) * 2019-01-04 2019-06-07 烽火通信科技股份有限公司 A kind of method and system for supporting more DTB in single linux system mirror image
CN110780935A (en) * 2019-10-31 2020-02-11 深圳市友华软件科技有限公司 Synchronous starting method and device for multi-system fusion product
CN110837376A (en) * 2019-10-28 2020-02-25 天津七一二通信广播股份有限公司 LINUX system for wireless plane shunting system equipment and introduction method
CN111399929A (en) * 2018-12-17 2020-07-10 深圳市茁壮网络股份有限公司 Test application starting method and device
CN111414202A (en) * 2020-01-02 2020-07-14 杭州迦智科技有限公司 Hardware operation management method, system, management subsystem, electronic equipment and storage medium

Patent Citations (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1828538A (en) * 2006-03-31 2006-09-06 浙江大学 Method for realizing operating procedure directly from file system in embedded system
JP2010282645A (en) * 2010-07-26 2010-12-16 Victor Co Of Japan Ltd Linux program start-up system
US8874888B1 (en) * 2011-01-13 2014-10-28 Google Inc. Managed boot in a cloud system
CN103577210A (en) * 2012-08-06 2014-02-12 广州三星通信技术研究有限公司 System and method for mounting between mobile terminals
CN104751062A (en) * 2013-12-31 2015-07-01 研祥智能科技股份有限公司 Method and device improving operation system reliability
CN103761124A (en) * 2014-01-06 2014-04-30 武汉烽火富华电气有限责任公司 Method for starting embedded-type Linux system used for protection measuring and controlling device
CN106502739A (en) * 2016-10-31 2017-03-15 北京深之度科技有限公司 Method, device and the computing device that boot disk is made using movable storage device
JP2019032610A (en) * 2017-08-04 2019-02-28 富士通株式会社 Computer starting method and computer
CN109426591A (en) * 2017-09-04 2019-03-05 武汉斗鱼网络科技有限公司 Guard the method and apparatus of multiple processes of the single program of windows
CN107885536A (en) * 2017-11-30 2018-04-06 建荣半导体(深圳)有限公司 Startup method, embeded processor and the storage device of a kind of embeded processor
CN109254805A (en) * 2018-09-21 2019-01-22 武汉斗鱼网络科技有限公司 A kind of application self-start method, terminal installation and readable storage medium storing program for executing
CN111399929A (en) * 2018-12-17 2020-07-10 深圳市茁壮网络股份有限公司 Test application starting method and device
CN109634687A (en) * 2018-12-19 2019-04-16 恒为科技(上海)股份有限公司 The starting method and apparatus of application software in a kind of embedded Linux system
CN109840096A (en) * 2019-01-02 2019-06-04 紫光华山信息技术有限公司 The installation method and device of operating system
CN109857468A (en) * 2019-01-04 2019-06-07 烽火通信科技股份有限公司 A kind of method and system for supporting more DTB in single linux system mirror image
CN110837376A (en) * 2019-10-28 2020-02-25 天津七一二通信广播股份有限公司 LINUX system for wireless plane shunting system equipment and introduction method
CN110780935A (en) * 2019-10-31 2020-02-11 深圳市友华软件科技有限公司 Synchronous starting method and device for multi-system fusion product
CN111414202A (en) * 2020-01-02 2020-07-14 杭州迦智科技有限公司 Hardware operation management method, system, management subsystem, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
盲杖***底层软件模块的开发;马倩倩;信息科技(第4期);全文 *

Also Published As

Publication number Publication date
CN112000382A (en) 2020-11-27

Similar Documents

Publication Publication Date Title
CN112000382B (en) Linux system starting method and device and readable storage medium
EP3674954B1 (en) Security control method and computer system
RU2542930C2 (en) Booting and configuring subsystem securely from non-local storage
US9081596B2 (en) Information processing device, virtual machine creation method, and application distribution system
CN107577937B (en) Application program protection method and system
CN110334512B (en) Static measurement method and device of trusted computing platform based on dual-system architecture
EP2989544A1 (en) Systems and methods for replacing application methods at runtime
CN110321713B (en) Dynamic measurement method and device of trusted computing platform based on dual-system architecture
CN110321235B (en) System interaction method and device of trusted computing platform based on dual-system architecture
CN111143869A (en) Application package processing method and device, electronic equipment and storage medium
CN108229144B (en) Verification method of application program, terminal equipment and storage medium
WO2022078366A1 (en) Application protection method and apparatus, device and medium
CN110390201A (en) The method of computer system and initializing computer system
CN110874467A (en) Information processing method, device, system, processor and storage medium
CN114969713A (en) Equipment verification method, equipment and system
US10503430B2 (en) Method and device for clearing data and electronic device
CN108920962B (en) Firmware downloading and signing checking method, firmware publishing method, mobile terminal and server
AU2018250531A1 (en) Method for programming and terminal device
US20110145596A1 (en) Secure Data Handling In A Computer System
CN110334509B (en) Method and device for constructing trusted computing platform of dual-system architecture
CN115688120A (en) Secure chip firmware importing method, secure chip and computer readable storage medium
CN108171063A (en) Method, terminal and the computer readable storage medium of access safety element
CN116112412A (en) Virtual network card binding redundancy function test method, system, device and medium
TWI682296B (en) Image file packaging method and image file packaging system
CN113868700B (en) BIOS mirror image offline signature method, system, terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant