Linux-based security management starting process method, system and equipment and medium
By modifying the startup mechanism of the memory file system and compressing the kernel file system, the limitations of the Linux system in version management and upgrade are solved, and an automatic repair mechanism is provided, which realizes a more flexible and efficient startup process and ensures the stability of the system. and usability.
Patent Information
- Application Number
- CN202411157163.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-12-17
AI Technical Summary
The traditional startup method of Linux system is not flexible and efficient enough when facing system component upgrades or version management, and lacks an automatic recovery mechanism, which leads to users needing to manually edit GRUB configuration files, making errors prone and unable to recover quickly when the system key components are damaged.
By modifying the startup mechanism of the memory file system, compressing the Linux file system and kernel, decompressing it to memory to boot, and switching to the hard disk file system according to the version selected by the user during the system startup, providing an automatic repair mechanism. The specific steps include calling the hook program to read the GRUB environment variables, using the xz algorithm to compress the file system and kernel, packaging it into SquashFS format, decompressing it to memory, and switching the decompressed file system to the hard disk user file system.
A more flexible and efficient version management and upgrade process is achieved, providing an automatic repair mechanism when critical system components are damaged, ensuring system availability and stability.
Smart Images

Figure CN119150295A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a Linux-based security management startup process method, system, device and medium. Background Art
[0002] The general startup process of the Linux system is as follows: BIOS startup: When the computer is turned on, the BIOS (Basic Input / Output System) program is executed first. The BIOS is responsible for initializing and detecting the system hardware and reading the bootloader program from the specified startup device (such as hard disk, optical drive, etc.).
[0003] BootLoader startup: BootLoader is a small program located on the boot device, which is responsible for loading and starting the operating system kernel. Common BootLoaders include GRUB (Grand Unified Bootloader) and LILO (Linux Loader).
[0004] Kernel startup: BootLoader hands control to the operating system kernel. The kernel is responsible for initializing various hardware device drivers, loading necessary system modules, and mounting the root file system.
[0005] Init process startup: After the kernel is started, the init process is started, which is the first process of the entire system. The init process is responsible for reading configuration files (such as / etc / inittab or systemd configuration files) and starting various system services according to the configuration.
[0006] Runlevel switching: The init process enters different runlevels according to the configuration file. Different runlevels represent different system states, such as multi-user mode, single-user mode, etc.
[0007] Graphical interface startup: If the system is configured to start up with a graphical interface, the init process will start the graphical display manager (such as gdm, kdm, lightdm, etc.), and the graphical interface manager will then start the graphical desktop environment (such as GNOME, KDE, etc.).
[0008] User login: End users can log in to the system in the graphical interface or command line interface and start using it.
[0009] During the entire startup process, various components collaborate through standard startup processes and interfaces to ensure that the system can start and run smoothly. In recent years, some Linux distributions have begun to use systemd as a system initialization tool to replace the traditional init process. The startup process has also changed, but the basic principles are the same.
[0010] A significant disadvantage of the current Linux boot method is its limitations in file system or kernel upgrades and version management. Since the traditional boot method relies on hard-coded paths and parameters in the bootloader, such as the GRUB configuration file, to locate the memory file system, kernel, and file system on the hard disk, this method is not flexible and efficient when faced with system component upgrades or version management. Specifically, when the kernel or file system needs to be updated, users usually need to manually edit the GRUB configuration file, which is cumbersome and error-prone, and it is difficult to support multi-version management.
[0011] In addition, the traditional boot method lacks a mechanism to automatically restore or repair the system when key components are accidentally deleted or damaged. If the user accidentally deletes the key files of the system, the system may not be able to start, and the traditional boot method does not provide a convenient recovery method. Summary of the invention
[0012] Aiming at the problem that the existing startup mode has no recovery mechanism and the system upgrade mode is complicated, the present invention proposes a Linux-based secure management startup process method, system, device and medium; the method compresses the Linux file system and kernel into files respectively, and decompresses them into memory after the user selects the system version at startup, which not only solves the limitations of the traditional startup mode in version management and upgrade, but also provides the possibility of automatic repair when the key components of the system are damaged; in this way, the system version can be managed more conveniently and the system availability can be quickly restored when problems occur.
[0013] The specific implementation contents of the present invention are as follows: A secure management startup process method based on Linux first modifies the startup mechanism of the Linux memory file system and determines the startup version of the memory file system. Then, the Linux memory file system, kernel and file system are compressed and packaged. Then, the compressed file system, kernel and file system are decompressed to the memory and data is read from the memory. Finally, the read data is switched to the user file system of the hard disk, the file system startup is completed and switched to the user space.
[0014] In order to better implement the present invention, further, the Linux-based security management startup process method specifically includes the following steps: Step S1: calling the hook program to read the GRUB environment variable, modifying the startup mechanism of the Linux memory file system, and determining the startup version of the memory file system; Step S2: Call the xz algorithm to compress the Linux memory file system, kernel and file system into compressed files, and pack them to the hard disk; Step S3: according to the determined startup version, decompress the compressed file system, kernel and file system to the startup partition of the memory; Step S4: Switch the file system in the memory to the user file system in the hard disk, complete the file system startup and switch to the user space.
[0015] In order to better implement the present invention, further, the step S1 specifically includes the following steps: Step S11: calling the hook program to read the label tag of the GRUB environment variable grubenv; Step S12: Determine the corresponding memory file system, kernel, and file system startup version according to the label tag.
[0016] In order to better implement the present invention, further, the step S2 specifically includes the following steps: Step S21: calling the xz algorithm to compress the memory file system, kernel and file system of Linux into a compressed file; Step S22: calling the mksquashfs command to package the compressed file into a SquashFS format image file; Step S23: placing the image file to a designated location on the hard disk.
[0017] In order to better implement the present invention, further, the step S3 specifically includes the following steps: Step S31: triggering the initialization logic of the memory file system, and reading the label tag in the GRUB environment variable according to the initialization logic; Step S32: determine the file system version according to the label tag and decompress it; Step S33: According to the determined startup version, the compressed file system, kernel and file system are decompressed to the startup partition of the memory, and the decompressed file system is mounted to the memory in read-only mode.
[0018] In order to better implement the present invention, further, the step S4 specifically includes the following steps: Step S41: copying the decompressed file system obtained from the memory to a designated location on the hard disk; Step S42: Switch the file system obtained from the memory to the user file system restored from the hard disk, complete the file system startup and switch to the user space.
[0019] Based on the above-mentioned Linux-based security management startup process method, in order to better realize the present invention, further, a Linux-based security management startup process system is proposed, which is used to execute the Linux-based security management startup process method; including an initialization unit, a compression and packaging unit, a decompression unit, and a switching startup unit; The initialization unit is used to modify the startup mechanism of the memory file system of Linux and determine the startup version of the memory file system; The compression and packaging unit is used to compress and package the memory file system, kernel and file system of Linux; The decompression unit is used to decompress the compressed file system, kernel and file system into the memory and read data from the memory; The switching startup unit is used to switch the read data to the user file system of the hard disk, complete the file system startup and switch to the user space.
[0020] Based on the above-mentioned Linux-based security management startup process method, in order to better realize the present invention, further, an electronic device is proposed, including a memory and a processor, and a computer program is stored on the memory; when the computer program is executed on the processor, the above-mentioned Linux-based security management startup process method is implemented.
[0021] Based on the above-mentioned Linux-based security management startup process method, in order to better realize the present invention, further, a computer-readable storage medium is proposed, on which computer instructions are stored; when the computer instructions are executed on the above-mentioned electronic device, the above-mentioned Linux-based security management startup process method is implemented.
[0022] The present invention has the following beneficial effects: The present invention modifies the startup mechanism of the memory file system, enhances the flexibility and configurability of the startup process, solves the limitations of traditional startup methods in version management and upgrading, provides the possibility of automatic repair when key system components are damaged, and realizes more convenient management of system versions and rapid recovery of system availability when problems arise. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 The present invention provides a schematic diagram of the overall process of the Linux-based security management startup process method. DETAILED DESCRIPTION
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. It should be understood that the described embodiments are only part of the embodiments of the present invention, not all of the embodiments, and therefore should not be regarded as limiting the scope of protection. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technical personnel in this field without making creative work are within the scope of protection of the present invention.
[0025] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "disposed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0026] The professional terms and explanations involved in this embodiment are as follows: xz: is a compressed file format that uses LZMA SDK for compression. The target file is 30% smaller than the gzip compressed file .gz or .tgz and 15% smaller than .bz2. It is used to compress a string of text.
[0027] mksquashfs: mksquashfs is a command tool used to create a SquashFS file system. SquashFS is a read-only file system under Linux that can compress the entire file system or a single directory together and store it in a device, partition or ordinary file.
[0028] Mount: Mounting refers to connecting a device, usually a storage device such as a hard disk partition, USB drive, CD, etc. or a file system to the directory tree of the Linux file system so that the files in the device or file system can be accessed and used through the Linux file system.
[0029] Embodiment 1: This embodiment proposes a Linux-based security management startup process method, first modifying the startup mechanism of the Linux memory file system, determining the startup version of the memory file system, and then compressing the Linux memory file system, kernel and file system and packaging them, and then decompressing the compressed file system, kernel and file system to the memory, and reading data from the memory, and finally switching the read data to the user file system of the hard disk, completing the file system startup and switching to the user space, the Linux-based security management startup process method specifically includes the following steps: Step S1: Call the hook program to read the GRUB environment variable, modify the startup mechanism of the Linux memory file system, and determine the startup version of the memory file system.
[0030] The step S1 specifically includes the following steps: Step S11: calling the hook program to read the label tag of the GRUB environment variable grubenv; Step S12: Determine the corresponding memory file system, kernel, and file system startup version according to the label tag.
[0031] Step S2: Call the xz algorithm to compress the Linux memory file system, kernel and file system into compressed files, and pack them to the hard disk.
[0032] Furthermore, the step S2 specifically includes the following steps: Step S21: calling the xz algorithm to compress the memory file system, kernel and file system of Linux into a compressed file; Step S22: calling the mksquashfs command to package the compressed file into a SquashFS format image file; Step S23: placing the image file to a designated location on the hard disk.
[0033] Step S3: According to the determined startup version, the compressed file system, kernel and file system are decompressed to the startup partition of the memory.
[0034] Furthermore, the step S3 specifically includes the following steps: Step S31: triggering the initialization logic of the memory file system, and reading the label tag in the GRUB environment variable according to the initialization logic; Step S32: determine the file system version according to the label tag and decompress it; Step S33: According to the determined startup version, the compressed file system, kernel and file system are decompressed to the startup partition of the memory, and the decompressed file system is mounted to the memory in read-only mode.
[0035] Step S4: Switch the file system in the memory to the user file system in the hard disk, complete the file system startup and switch to the user space.
[0036] Furthermore, the step S4 specifically includes the following steps: Step S41: copying the decompressed file system obtained from the memory to a designated location on the hard disk; Step S42: Switch the file system obtained from the memory to the user file system restored from the hard disk, complete the file system startup and switch to the user space.
[0037] Working principle: In this embodiment, the file system and kernel of Linux are compressed into independent files respectively to replace the traditional method of directly storing them on the hard disk. When the system starts, these compressed files are read by the boot program, and the operating system is started after being decompressed in the memory. First, the file system and the kernel are compressed. The file system and the kernel of Linux are compressed into two files separately, which not only optimizes the use of storage space, but also provides the possibility for the rapid startup of the system. Then, the decompression and startup in the memory are performed. During the startup process, the boot program decompresses the compressed file system and kernel into the memory, and directly reads data from the memory to start. This method can significantly improve the startup speed and enhance the security of the system. Finally, file comparison and repair are performed, and a file comparison and repair mechanism is introduced. At each startup, the system compares the pre-saved file with the current file to be started. If a difference or damage is found, it will be automatically repaired to ensure the stability and availability of the system. Through this innovative method and mechanism, this embodiment not only optimizes the startup process of Linux, improves the startup speed, but also enhances the security and stability of the system.
[0038] Embodiment 2: This embodiment is based on the above embodiment 1. Figure 1 As shown, a specific embodiment is described in detail.
[0039] Step S1: Startup modification of the memory file system.
[0040] In order to enhance the flexibility and configurability of the boot process, the boot mechanism of the memory file system has been modified. Instead of relying on the traditional / sbin / init as the boot point, a hook program logic is introduced. This hook program reads the label tag in the GRUB environment variable grubenv to select the corresponding memory file system, kernel, and file system version for booting.
[0041] Step S2: Packaging and compression.
[0042] Since the size of the memory file system, kernel, and file system itself can be very large, a two-step compression method is used to save storage space and facilitate production deployment. First, the xz algorithm is used to compress each component into a separate file; then, the mksquashfs command is used to package these compressed files into a SquashFS format image file and place it in the specified location on the hard disk.
[0043] Step S3: Decompression and preparation before startup.
[0044] Before the system starts, a necessary step is to decompress the kernel and key components of the memory file system into the boot partition. This step ensures that the system can be successfully started from these components.
[0045] Version selection and startup: When the system starts, the initialization logic in the memory file system is triggered first. This initialization program reads the label in the GRUB environment variable and selects the corresponding file system version for decompression according to the label. The decompressed file system will be mounted in memory in read-only mode to prevent accidental modification.
[0046] Step S4: Copy and restore the file system.
[0047] Once the file system is mounted in memory, the initialization program will start copying its contents one by one to the specified location on the hard disk. This step ensures that the user can clean the file system on the hard disk and quickly restore it to a previous state when needed.
[0048] Switching of user space: After the file system is copied and restored, the initialization program enters the final stage, i.e. switching of user space. At this point, the system switches from the file system in memory to the restored user file system on the hard disk for normal use by the user.
[0049] Startup completed: After the above steps, the system has been successfully started and switched to the user space, and the user can start normal operation and use. The entire startup process is efficient and flexible, supports multi-version management, and provides the ability to quickly restore the file system.
[0050] Working principle: This embodiment provides a more efficient, flexible and automatic repair Linux boot method. By compressing the Linux file system and kernel into files respectively, and decompressing them into memory after the user selects the system version at boot time, it not only solves the limitations of traditional boot methods in version management and upgrades, but also provides users with the possibility of automatic repair when key system components are damaged. In this way, users can manage system versions more conveniently and quickly restore system availability when encountering problems.
[0051] This embodiment first packages the key components into a whole, and then modifies the initialization logic of the memory file system at startup. The traditional init logic is no longer executed. The packaged files are decompressed one by one and mounted in the memory directory. Finally, the files in the memory directory are compared with the files on the current hard disk. If the files on the hard disk do not exist, the files in the memory directory are copied to the hard disk.
[0052] First of all, the current Linux system places a readable file system directly on the hard disk. When the user makes a mistake, such as deleting a key file, the system will become unusable and cannot be restored. However, this embodiment will copy the original system files to the hard disk every time it is started, so even if the user deletes it by mistake, the system functions can be guaranteed to be available.
[0053] The current Linux system upgrade method is relatively complicated, requiring the system components to be upgraded one by one. If a problem occurs in the middle, the system will not start.
[0054] The current Linux system does not support system version management. If you want to roll back to the original version after upgrading the system, you need to downgrade the system components one by one, and this process may not be executed because there are dependencies between components. However, this embodiment packages the key components first and upgrades them by replacing the entire system.
[0055] The other parts of this embodiment are the same as those of the above-mentioned embodiment 1, so they will not be described in detail.
[0056] Embodiment 3: Based on any one of the above-mentioned embodiments 1-2, this embodiment proposes a Linux-based security management startup process system based on the above-mentioned Linux-based security management startup process method, which is used to execute the Linux-based security management startup process method; including an initialization unit, a compression and packaging unit, a decompression unit, and a switching startup unit; The initialization unit is used to modify the startup mechanism of the memory file system of Linux and determine the startup version of the memory file system; The compression and packaging unit is used to compress and package the memory file system, kernel and file system of Linux; The decompression unit is used to decompress the compressed file system, kernel and file system into the memory and read data from the memory; The switching startup unit is used to switch the read data to the user file system of the hard disk, complete the file system startup and switch to the user space.
[0057] This embodiment also proposes an electronic device, including a memory and a processor, wherein a computer program is stored in the memory; when the computer program is executed on the processor, the above-mentioned Linux-based security management startup process method is implemented.
[0058] This embodiment also proposes a computer-readable storage medium, on which computer instructions are stored; when the computer instructions are executed on the above-mentioned electronic device, the above-mentioned Linux-based security management startup process method is implemented.
[0059] The other parts of this embodiment are the same as any one of the above-mentioned embodiments 1-2, so they will not be repeated here.
[0060] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification or equivalent change made to the above embodiment based on the technical essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. A Linux-based security management startup process method, It is characterized in that First, modify the startup mechanism of the Linux memory file system and determine the startup version of the memory file system. Then compress the Linux memory file system, kernel and file system and package them. Then decompress the compressed file system, kernel and file system to the memory and read the data from the memory. Finally, switch the read data to the user file system of the hard disk, complete the file system startup and switch to the user space.
2. According to claim 1, a Linux-based security management startup process method, It is characterized in that The Linux-based security management startup process method specifically includes the following steps: Step S1: calling the hook program to read the GRUB environment variable, modifying the startup mechanism of the Linux memory file system, and determining the startup version of the memory file system; Step S2: Call the xz algorithm to compress the Linux memory file system, kernel and file system into compressed files, and pack them to the hard disk; Step S3: according to the determined startup version, decompress the compressed file system, kernel and file system to the startup partition of the memory; Step S4: Switch the file system in the memory to the user file system in the hard disk, complete the file system startup and switch to the user space.
3. According to claim 2, a Linux-based security management startup process method, It is characterized in that The step S1 specifically includes the following steps: Step S11: calling the hook program to read the label tag of the GRUB environment variable grubenv; Step S12: Determine the corresponding memory file system, kernel, and file system startup version according to the label tag.
4. According to claim 3, a Linux-based security management startup process method, It is characterized in that The step S2 specifically includes the following steps: Step S21: calling the xz algorithm to compress the memory file system, kernel and file system of Linux into a compressed file; Step S22: calling the mksquashfs command to package the compressed file into a SquashFS format image file; Step S23: placing the image file to a designated location on the hard disk.
5. According to claim 4, a Linux-based security management startup process method, It is characterized in that The step S3 specifically comprises the following steps: Step S31: triggering the initialization logic of the memory file system, and reading the label tag in the GRUB environment variable according to the initialization logic; Step S32: determine the file system version according to the label tag and decompress it; Step S33: According to the determined startup version, the compressed file system, kernel and file system are decompressed to the startup partition of the memory, and the decompressed file system is mounted to the memory in read-only mode.
6. According to claim 5, a Linux-based security management startup process method, It is characterized in that The step S4 specifically comprises the following steps: Step S41: copying the decompressed file system obtained from the memory to a designated location on the hard disk; Step S42: Switch the file system obtained from the memory to the user file system restored from the hard disk, complete the file system startup and switch to the user space.
7. A Linux-based security management startup process system, used to execute the Linux-based security management startup process method as claimed in claim 1; It is characterized in that It includes an initialization unit, a compression and packaging unit, a decompression unit, and a switching and starting unit; The initialization unit is used to modify the startup mechanism of the memory file system of Linux and determine the startup version of the memory file system; The compression and packaging unit is used to compress and package the memory file system, kernel and file system of Linux; The decompression unit is used to decompress the compressed file system, kernel and file system into the memory and read data from the memory; The switching startup unit is used to switch the read data to the user file system of the hard disk, complete the file system startup and switch to the user space.
8. An electronic device, It is characterized in that It comprises a memory and a processor, wherein a computer program is stored in the memory; when the computer program is executed on the processor, the Linux-based security management startup process method as described in any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions; when the computer instructions are executed on the electronic device as described in claim 8, the Linux-based security management startup process method as described in any one of claims 1-6 is implemented.
