Linux operating system installation method and device, electronic equipment and storage medium
By not storing the system files of the Linux operating system in the image file in the disk partition format, and generating partition tables and partitions according to the installation mode selected by the user during the installation process, the problem of large space and long download time of the image file is solved, and an efficient Linux operating system installation is achieved.
Patent Information
- Application Number
- CN202411797118.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-03-14
AI Technical Summary
In the prior art, the image files of the Linux operating system take up a lot of space, and downloading and copying the image files takes a lot of time.
By obtaining the image file of the Linux operating system, the system files are not stored in the format of disk partitions, the installation mode list is displayed and the partition table is generated according to user selection, the target disk is partitioned, and the system files are copied to the corresponding partition.
It effectively reduces the size of the image file, shortens the download and copy time, and ensures the normal installation and operation of the Linux operating system.
Smart Images

Figure CN119621086A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of system installation, and specifically to a Linux operating system installation method, a Linux operating system installation device, an electronic device, and a computer-readable storage medium. Background Art
[0002] The operating system is the system software used to manage computer hardware and software resources on a computer platform. In some computer platforms, such as the Feiteng platform, the commonly used operating systems are closed-source Kylin, Tongxin UOS, Deepin and other systems. When a problem occurs on a computer platform, developers cannot quickly locate and fix the problem, which in turn affects the normal use of the computer platform. If you want to use the open source Linux operating system on a computer platform, you need to use the Linux operating system's image file to install the Linux operating system on the computer platform.
[0003] However, existing image files usually store Linux operating systems in the format of disk partitions, which results in relatively large image files, which not only take up a lot of space, but also require a lot of time to download and copy the image files. Summary of the invention
[0004] In view of the above problems, the embodiments of the present application provide a Linux operating system installation method, a Linux operating system installation device, an electronic device, a computer-readable storage medium and a computer program product, which are used to solve the problem in the prior art that image files take up a lot of space and downloading and copying image files takes a lot of time.
[0005] According to one aspect of an embodiment of the present application, a method for installing a Linux operating system is provided, the method comprising: obtaining an image file of a Linux operating system, wherein system files of the Linux operating system in the image file are not stored in a disk partition format; obtaining an installation mode list from the image file, and sending the list to a display screen to display the installation mode list; obtaining configuration information in response to an installation mode selected by a user, the configuration information comprising target disk information and disk partition information; generating a partition table according to the disk partition information, and storing the partition table to a target disk corresponding to the target disk information; partitioning the target disk according to the partition table to generate an EFI partition and a ROOT partition; copying the EFI file and the Linux kernel file in the system file to the EFI partition; and copying the root file system in the system file to the ROOT partition.
[0006] In an optional manner, in response to the installation mode selected by the user, configuration information is obtained, specifically including: in response to the manual installation mode selected by the user, a configuration information list is obtained from the image file, and sent to a display screen to display the configuration information list; and configuration information input by the user is obtained.
[0007] In an optional manner, after obtaining the configuration information input by the user, the method also includes: determining the free disk space of the target disk; counting the required disk space corresponding to the disk partition information, wherein the required disk space is the total space of multiple disk partitions recorded in the disk partition information; judging whether the free disk space is greater than or equal to the required disk space; if the free disk space is greater than or equal to the required disk space, executing the step of generating a partition table according to the disk partition information, and storing the partition table to the target disk corresponding to the target disk information; if the free disk space is less than the required disk space, generating a configuration failure instruction, sending the configuration failure instruction to the display screen to pop up a configuration failure window to show that the target disk space is insufficient, and jumping to the step of obtaining the configuration information input by the user.
[0008] In an optional manner, in response to an installation mode selected by a user, configuration information is obtained, specifically including: in response to an automatic installation mode selected by a user, obtaining a pre-stored configuration information file from an image file; parsing the configuration information file to obtain configuration information; determining the free disk space of the target disk; counting the required disk space corresponding to the disk partition information, wherein the required disk space is the total space of multiple disk partitions recorded in the disk partition information; determining whether the free disk space is greater than or equal to the required disk space; if the free disk space is greater than or equal to the required disk space, executing the step of generating a partition table according to the disk partition information, and storing the partition table to the target disk corresponding to the target disk information; if the free disk space is less than the required disk space, terminating the installation of the operating system, generating an installation failure instruction, and sending it to the display screen to pop up an installation failure window to display insufficient target disk space.
[0009] In an optional manner, the configuration information also includes system information; after copying the root file system in the system file to the ROOT partition, the method also includes: setting the system information in the root file system of the ROOT partition; creating a swap partition in the root file system to expand memory capacity when the Linux operating system lacks memory.
[0010] In an optional manner, after creating a swap partition in the root file system to expand memory capacity when the Linux operating system lacks memory, the method also includes: setting the target disk information and the startup information of the Linux kernel file in the grub configuration file to guide the Linux operating system to start through the grub configuration file.
[0011] In an optional manner, the method further includes: generating a log file and recording the installation process of the Linux operating system in the log file; storing the log file in a ROOT partition, so as to determine the cause of the abnormality through the log file when the Linux operating system runs abnormally.
[0012] According to another aspect of an embodiment of the present application, a Linux operating system installation device is provided, the device comprising: a first acquisition module, used to acquire an image file of a Linux operating system, wherein the system files of the Linux operating system in the image file are not stored in the format of a disk partition; a sending module, used to acquire an installation mode list from the image file, and send the list to a display screen to display the installation mode list; a second acquisition module, used to acquire configuration information in response to an installation mode selected by a user, the configuration information comprising target disk information and disk partition information; a generation module, used to generate a partition table according to the disk partition information, and store the partition table to a target disk corresponding to the target disk information; a partition module, used to partition the target disk according to the partition table, and generate an EFI partition and a ROOT partition; a first copy module, used to copy the EFI file and the Linux kernel file in the system file to the EFI partition; and a second copy module, used to copy the root file system in the system file to the ROOT partition.
[0013] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement any of the above-mentioned Linux operating system installation methods.
[0014] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the Linux operating system installation method described in any one of the above items is implemented.
[0015] In the embodiment of the present application, during the process of installing the Linux operating system using the image file, the configuration information such as the target disk information and the disk partition information is obtained to generate a partition table and partition the target disk during the installation process, and then the system files of the Linux operating system in the image file are copied to the corresponding partitions. Under the premise of ensuring that the Linux operating system can be normally stored in the format of disk partitions on the target disk, the system files in the image file do not need to be stored in the format of disk partitions, that is, only the system files of the Linux operating system need to be stored in the image file, and there is no need to reserve space in the image file for users to store data, and there is no need to store the partition table in the image file, which can effectively reduce the space occupied by the image file and shorten the time for downloading and copying the image file.
[0016] The above description is only an overview of the technical solution of the embodiment of the present application. In order to more clearly understand the technical means of the embodiment of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present application. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:
[0018] Figure 1 A schematic diagram showing a flow chart of a method for installing a Linux operating system provided in the first embodiment of the present application is shown;
[0019] Figure 2 A schematic diagram of disk partitioning of a Linux operating system according to an embodiment of the present application is shown;
[0020] Figure 3 A schematic diagram showing a flow chart of a Linux operating system installation method provided in the second embodiment of the present application is shown;
[0021] Figure 4 A schematic diagram showing a flow chart of a Linux operating system installation method provided in the third embodiment of the present application is shown;
[0022] Figure 5 A schematic diagram of the structure of a Linux operating system installation device provided in an embodiment of the present application is shown;
[0023] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0024] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein.
[0025] With the development of chip localization, more and more imported chips are being replaced by domestic products. Take the Feiteng platform, that is, the Feiteng CPU, as an example. The Feiteng platform is the leader of domestic CPUs, with the characteristics of full spectrum, high performance and complete ecology, and can meet different levels of needs in multiple fields.
[0026] However, the current Feiteng platform only supports running Kylin, Tongxin UOS, Deepin and other operating systems. Since these operating systems are closed source, when problems occur in the system, developers cannot quickly locate and fix the problems, which in turn affects the normal use of the system. Therefore, in order to use the open source Linux operating system on the Feiteng platform, it is necessary to add the Feiteng kernel patch to the kernel of the Linux operating system, then generate the corresponding image file, and finally install the Linux operating system on the Feiteng platform through the image file.
[0027] The image file of the Linux operating system is usually stored in the format of a disk partition. When installing the Linux operating system, you only need to copy the data in the image file to the disk to complete the installation of the Linux operating system. In addition, since users need to add user data to the system file when using the operating system, in addition to storing the system files of the Linux operating system itself, the image file also needs to reserve a certain amount of space to store user data, so that users can store data normally when using the Linux operating system. Moreover, when storing system files in the format of a disk partition, it is also necessary to store data such as the partition table in the image file. This will not only cause the image file to take up a lot of space, but also take a lot of time to download and copy the image file.
[0028] Based on this, in order to reduce the space occupied by the image file, the present application considers not storing the system files of the Linux operating system in the image file in the format of a disk partition, but directly packaging the system files of the Linux operating system into an image file after placing them in a directory. Such an image file only needs to store the system files of the Linux operating system, and no extra space needs to be reserved, which effectively reduces the space occupied by the image file and reduces the time spent on downloading the image file.
[0029] In addition, since the system files of the Linux operating system need to be stored in the format of disk partitions on the disk to ensure the normal operation of the Linux operating system, the present application also provides a method for installing the Linux operating system. During the installation of the Linux operating system, a list of installation modes is displayed to the user through a display screen for the user to select a corresponding installation mode, and based on the installation mode selected by the user, the corresponding target disk information and disk partition information are obtained and a partition table is generated, and the disk is partitioned through the generated partition table to copy the system files of the Linux operating system to the target disk and store them in the format of disk partitions to ensure the normal operation of the Linux operating system, and during the copying process, only the data in the system files needs to be copied to the corresponding disk partitions, reducing the time required for data copying.
[0030] Figure 1The flowchart of the Linux operating system installation method provided in the embodiment of the present application is shown, and the method is executed by an electronic device. The electronic device can be a computer device such as a computer, a server, a cloud server, etc. Figure 1 As shown, the method comprises the following steps:
[0031] Step S110: obtaining an image file of the Linux operating system, wherein the system files of the Linux operating system in the image file are not stored in the format of a disk partition.
[0032] Among them, the Linux operating system is an open source UNIX-like operating system kernel, which mainly includes versions of operating systems such as Ubuntu, Fedore, and Debian. An image file is a collection of all files containing a Linux operating system, which are organized into one or more files that can be used to install or restore the operating system. In other words, an image file is a complete copy of the operating system, usually in the form of a single file, and can be directly written to a storage medium such as a hard disk, a USB flash drive, or a CD to install or restore the Linux operating system. Its main formats include CD images, hard disk images, floppy disk images, etc. The specific format of the image file is not limited in the embodiments of the present application.
[0033] System files are a collection of files used in the Linux operating system to control and manage computer hardware and software resources and provide user interfaces and application program interfaces. Such files are the basis for the normal operation of the operating system, mainly including EFI files (mainly including the boot loader of the Linux operating system, such as the grub.efi file, which is responsible for loading the kernel of the operating system and initializing the memory disk), Linux kernel files (the kernel is the core part of the Linux operating system, responsible for managing system processes, memory, device drivers, file systems and networks, etc.), root file systems (mainly including the startup scripts and configuration files of the operating system, etc.), etc.
[0034] like Figure 2 As shown, Figure 2The schematic diagram of the disk partition of the Linux operating system involved in the embodiment of the present application is shown. After the Linux operating system is installed on the disk, five areas will be generated on the disk, namely, MBR, partition table, EFI partition, ROOT partition and other partitions. Specifically, MBR is used to store the boot code for booting the Linux operating system; the partition table stores the partition information of the entire disk, such as the starting position and size of each partition, as well as their types and other information; the EFI partition is used to store the EFI file (the EFI file is used to boot the Linux operating system) and the Linux kernel file; the ROOT partition is used to store the root file system of the Linux operating system. When running the Linux operating system, the initialization process after the Linux kernel is started is run according to the settings in the ROOT partition; other partitions are used to store user data.
[0035] The system files of the Linux operating system in the image file are stored in the format of disk partitions, that is, the system files are stored in the image file in the form of the above five areas. When installing the Linux operating system, you only need to directly copy the contents of the image file to the target disk to complete the installation of the Linux operating system. However, in addition to storing the system files of the Linux operating system in the image file, such a storage format also requires space reserved for user data storage in each area, which results in the image file taking up a very large space, which is not conducive to downloading and copying the image file.
[0036] In the embodiment of the present application, in order to reduce the size of the image file, the system files of the Linux operating system in the image file are not stored in the format of disk partitions, but the system files are stored in a directory and packaged into an image file. After obtaining the image file, the electronic device first obtains the configuration information of the Linux operating system, then partitions the target disk according to the configuration information, and finally copies the system files to the corresponding partition to achieve the installation of the Linux operating system.
[0037] In addition, in order to ensure that the image file can be used on the Feiteng platform, when generating the image file, it is also necessary to add the Feiteng platform kernel patch to the kernel source code of the Linux operating system, so that the compiled kernel can run normally on the Feiteng platform. Furthermore, the system files can be packaged into an IOS format image file and burned on a storage medium such as a CD or USB flash drive. When installing the Linux operating system, the Linux operating system can be directly started and installed through the storage medium. In this way, there is no need to start an operating system first, and then rely on the copy command under this operating system to copy the content in the image file from the storage medium to the disk of the electronic device.
[0038] Step S120: Obtain the installation mode list from the image file, and send it to the display screen to display the installation mode list.
[0039] Step S130: In response to the installation mode selected by the user, configuration information is obtained, where the configuration information includes target disk information and disk partition information.
[0040] Among them, the installation mode list includes the installation modes that the user can select, which may specifically include manual installation mode and automatic installation mode. When the user selects manual installation mode, the Linux operating system can be installed according to the configuration information input by the user. When the user selects automatic installation mode, the Linux operating system can be directly installed according to the configuration information pre-stored in the image file. Configuration information refers to a series of parameters used to install the Linux operating system. These parameters determine how the Linux operating system is installed and how it runs after installation. It should be particularly pointed out that in the embodiment of the present application, in addition to the target disk information and disk partition information, the configuration information may also include information such as language, time, account password, etc.
[0041] The target disk information is used to represent the installation location of the Linux operating system, such as the commonly used disk information such as C drive and D drive. The disk partition information is used to represent the specific layout on the disk when the Linux operating system is stored in the disk partition format, mainly including the size and format of the disk partition, among which the size of the disk partition is usually determined by the size of the operating system, data storage requirements, etc., and the format of the disk partition is usually determined by the file system format supported by the operating system.
[0042] Step S140: Generate a partition table according to the disk partition information, and store the partition table in the target disk corresponding to the target disk information.
[0043] Step S150: partition the target disk according to the partition table to generate an EFI partition and a ROOT partition.
[0044] Among them, since the image file does not store the system files in the disk partition format, and the system files need to be stored in the disk partition format to ensure the normal operation of the Linux operating system, before copying the system files in the image file, it is necessary to partition the target disk and record the information of each partition in the target disk (for example, the starting position, end position, size, format, etc. of each partition). Specifically, first, a partition table is generated according to the disk partition information, and the partition table is stored in the target disk to generate the following on the target disk: Figure 2The partition table shown. In addition, when determining the starting position of each partition, the first byte of the target disk can be used as the starting position of the first partition in the disk partition, and then the end position of the first partition and the starting position of the next partition are determined according to the size of the first partition in the disk partition information, and so on to generate the partition table; when other data has been stored in the target disk, before generating the partition table, the starting position of the free space on the target disk can be obtained, and the starting position can be used as the starting position of the first partition in the disk partition information to avoid the system files of the Linux operating system overwriting the original data in the target disk, causing data loss.
[0045] Then, partition according to the partition table to generate the following on the target disk: Figure 2 The EFI partition and ROOT partition shown in the figure can of course generate MBR and other partitions on the target disk. Usually, the EFI partition and ROOT partition are continuous spaces on the target disk. As an example, under the Linux operating system, you can use the fdisk command to partition the disk and determine the size and format of the disk partition; finally, according to the function of each partition on the target disk, copy the corresponding files in the image file to the corresponding partition.
[0046] Step S160: copy the EFI files and Linux kernel files in the system files to the EFI partition.
[0047] Step S170: copy the root file system in the system file to the ROOT partition.
[0048] Finally, the EFI file (i.e., the boot loader of the Linux operating system) and the Linux kernel file (i.e., the kernel of the Linux operating system) in the system files are copied to the EFI partition. In the embodiment of the present application, as an example, the grub.efi file can be installed to the EFI partition through the grud install command. At the same time, the kernel image file (i.e., the Linux kernel file) compiled by the Linux kernel source code is also stored in the grub.efi partition, which makes it convenient for grub.efi to find and load the startup kernel.
[0049] In addition, copy the root file system in the system files to the ROOT partition. The root file system is the top level of the file system hierarchy in the Linux operating system and the starting point of the entire file system tree structure. It mainly includes startup scripts (used to initialize the system when the Linux operating system starts), system configuration files (used to configure user accounts, groups, file system mounting, etc.), library files, device files, etc.
[0050] In the above embodiment, during the process of installing the Linux operating system using the image file, the configuration information such as the target disk information and the disk partition information is obtained to generate a partition table and partition the target disk during the installation process, and then the system files of the Linux operating system in the image file are copied to the corresponding partitions. Under the premise of ensuring that the Linux operating system can be normally stored in the format of disk partitions on the target disk, the system files in the image file do not need to be stored in the format of disk partitions, that is, only the system files of the Linux operating system need to be stored in the image file, and there is no need to reserve space in the image file for users to store data, and there is no need to store the partition table in the image file, which can effectively reduce the space occupied by the image file and shorten the time for downloading and copying the image file.
[0051] Furthermore, in order to make the installation of the Linux operating system more convenient, the installation mode list may include an automatic installation mode, specifically, Figure 3 As shown, Figure 3 A flowchart of a Linux operating system installation method provided by the second embodiment of the present application is shown, and step S130 may include the following steps:
[0052] Step S131a: In response to the automatic installation mode selected by the user, a pre-stored configuration information file is obtained from the image file.
[0053] When generating an image file, a configuration information file can be generated in the image file, and the default configuration can be set in the configuration information file, such as target disk information, disk partition information (EFI partition, ROOT partition and partition size, etc.), account password, host name, language, time zone and other information.
[0054] Step S132a: Parse the configuration information file to obtain configuration information.
[0055] In order to facilitate users to modify the content in the configuration information file, the configuration information file can be in the format of a text document, a PDF document, a word document, etc., and the configuration information can be expressed in a natural language (e.g., Chinese, English, etc.). Since natural languages are highly complex and diverse, electronic devices are usually unable to directly recognize and use natural languages. Therefore, when obtaining configuration information, it is necessary to parse the configuration information file to parse the configuration information in the configuration information file into a computer language (i.e., a programming language).
[0056] Step S133a: Determine the free disk space of the target disk.
[0057] The free disk space is the unused space on the target disk, that is, the space where no data is stored on the disk, usually continuous space. When the free disk space is less than the space required to install the Linux operating system, the system will not run properly, data will be lost, system files will be damaged, etc. Therefore, when installing the Linux operating system, you also need to make sure that the target disk has enough free disk space.
[0058] Step S134a: Count the required disk space corresponding to the disk partition information, wherein the required disk space is the total space of multiple disk partitions recorded in the disk partition information.
[0059] The disk partition information includes the size and format of each partition, wherein the size of each partition is used to represent the space occupied by the partition on the disk. For example, if the size of the EFI partition recorded in the disk partition information is 500MB, it means that the EFI partition on the target disk needs to occupy 500MB of space. If the size of the EFI partition recorded in the disk partition information is 1GB, it means that the EFI partition on the target disk needs to occupy 1GB of space. Similarly, if the size of the ROOT partition recorded in the disk partition information is 50GB, it means that the ROOT partition on the target disk needs to occupy 50GB of space. If the size of the ROOT partition recorded in the disk partition information is 100GB, it means that the ROOT partition on the target disk needs to occupy 100GB of space.
[0060] The required disk space is the sum of the sizes of each partition in the disk partition information, that is, the sum of the space occupied by each partition on the target disk after the partition table generated by the disk partition information is installed to partition the target disk. For example, if the disk partition information only records the size of the EFI partition as 1GB and the size of the ROOT partition as 50GB, the required disk space is 51GB. If the disk partition information records the size of other partitions (space for storing user data) as 200GB in addition to the size of the EFI partition and the ROOT partition, the required disk space is 251GB.
[0061] Step S135a: Determine whether the free disk space is greater than or equal to the required disk space.
[0062] If yes, it means that there is enough space on the target disk to store the system files of the Linux operating system and to run the Linux operating system. The Linux operating system can be installed according to the installation steps of the Linux operating system, and step S140 is continued.
[0063] If not, it means that the space on the target disk is insufficient to store the system files of the Linux operating system, or the remaining space after installing the Linux operating system is insufficient to support the normal operation of the Linux operating system, and step S136a needs to be executed.
[0064] Step S136a: End the installation of the operating system, generate an installation failure instruction, and send it to the display screen to pop up an installation failure window to show that the target disk space is insufficient.
[0065] Among them, when the free disk space is less than the required disk space, the space on the target disk is insufficient to store the system files of the Linux operating system, or the remaining space after installing the Linux operating system is insufficient to support the normal operation of the Linux operating system. At this time, it is necessary to directly stop the installation process, that is, end the installation of the operating system, and generate an installation failure instruction. In addition, it is necessary to remind the user that the target disk has insufficient space and the Linux operating system cannot be installed, that is, send the installation failure instruction to the display screen to pop up an installation failure window to show that the target disk space is insufficient.
[0066] In the above embodiment, by pre-storing the configuration information file in the image file, during the process of installing the Linux operating system, the user can directly select the automatic installation mode, so that the electronic device directly obtains the configuration information file from the image file, and parses the configuration information file to install the Linux operating system according to the configuration information in the configuration information file. In addition, by judging whether the target disk has enough space to install and run the Linux operating system, and when the target disk has insufficient space, the installation of the operating system is terminated in time, thereby ensuring the stability of the Linux operating system.
[0067] Furthermore, in order to improve the flexibility of Linux operating system installation, the installation mode list may also include a manual installation mode, specifically, Figure 4 As shown, Figure 4 A flowchart of a Linux operating system installation method provided in the third embodiment of the present application is shown. Step S130 may include the following steps:
[0068] Step S131b: In response to the manual installation mode selected by the user, a configuration information list is obtained from the image file and sent to a display screen to display the configuration information list.
[0069] Step S132b: Obtain configuration information input by the user.
[0070] The configuration information list is used to represent a series of parameters required during the installation of the Linux operating system, such as target disk information, disk partition information, account password, root account, host name, time zone, language, etc. The configuration information list is sent to the display screen, and the configuration information list is displayed to the user through the display screen to prompt the user which parameters need to be entered, thereby ensuring the normal installation of the Linux operating system, and finally obtaining the configuration information entered by the user to install the Linux operating system according to the configuration information. Furthermore, the display screen can display the configuration information list in the form of text, a visual interface, etc.
[0071] In the above embodiment, when the user selects the manual installation mode, the configuration information category is obtained from the image file and displayed on the display screen to prompt the user with the configuration information required, and the configuration information input by the user is obtained to install the Linux operating system according to the configuration information. In this process, the user can control the installation location of the Linux operating system, the size of each partition, etc. through the configuration information, making the installation of the Linux operating system more flexible and able to install the Linux operating system according to the user's habits.
[0072] In addition, during the automatic installation of the Linux operating system, if the operating system installation fails because the target disk does not have enough free disk space, it is possible to jump to step S120 for the user to reselect the installation mode to ensure that the user can complete the installation of the Linux operating system by selecting the manual installation mode and entering the appropriate configuration information.
[0073] Furthermore, in order to prevent the required disk space corresponding to the disk partition information input by the user from exceeding the free disk space of the target disk, thereby causing abnormal installation or operation of the Linux operating system, after step S132b, the method further includes the following steps:
[0074] Step S133b: Determine the free disk space of the target disk.
[0075] Step S134b: Count the required disk space corresponding to the disk partition information, wherein the required disk space is the total space of multiple disk partitions recorded in the disk partition information.
[0076] Step S135b: Determine whether the free disk space is greater than or equal to the required disk space.
[0077] If yes, execute step S140; if no, execute step S136b.
[0078] Among them, the specific process of step S133b to step S135b is the same as the specific process of step S133a to step S135a, which will not be repeated here.
[0079] Step S136b: Generate a configuration failure instruction, send the configuration failure instruction to the display screen to pop up a configuration failure window to show that the target disk space is insufficient, and jump to step S132b.
[0080] If the free disk space is less than the required disk space, it means that the space on the target disk is insufficient to store the system files of the Linux operating system, or the remaining space after installing the Linux operating system is insufficient to support the normal operation of the Linux operating system. At this time, it is necessary to remind the user that the target disk has insufficient space and the Linux operating system cannot be installed, so that the user can re-enter the disk partition information, that is, generate a configuration failure instruction, and send the configuration failure instruction to the display screen to pop up a configuration failure window to show that the target disk space is insufficient. Finally, jump to step S132b to obtain the configuration information re-entered by the user.
[0081] In the above embodiment, by judging whether the target disk has enough space to install and run the Linux operating system, and when the target disk has insufficient space, promptly reminding the user of the insufficient target disk space, and re-obtaining the configuration information input by the user, the stability of the Linux operating system after installation is ensured.
[0082] Furthermore, in order to further ensure the stable operation of the operating system and meet user needs, the configuration information may also include system information (for example, account password, root account, host name, time zone, language, etc.). The method includes the following steps:
[0083] Step S210: Set the system information in the root file system of the ROOT partition.
[0084] Among them, the system information is used to configure the system to ensure the stable operation of the operating system. Specifically, the system installation time can be recorded first, and then the system time zone, local language, host name, etc. can be set. After the Linux operating system is installed, the Linux operating system provides an operating environment for users or system administrators according to the system information.
[0085] Step S220: Create a swap partition in the root file system to expand the memory capacity when the Linux operating system lacks memory.
[0086] The swap partition, also known as swap space, is a portion of the hard disk that the operating system can use as virtual memory. When physical memory is insufficient to meet the running requirements of applications, the operating system can move infrequently used data from memory to the swap partition to make room for new or more active data. Specifically, you can create a new partition using tools such as fdisk or parted, format the partition as swap space, enable the swap partition, and automatically mount it when the Linux operating system starts.
[0087] In the above embodiment, by setting the system information in the root file system, a better operating environment can be provided for the user when using the Linux operating system, and by creating a swap partition, the Linux operating system can store data in the memory through the swap partition when the physical memory is insufficient, thereby ensuring the normal operation of the application and improving the performance and stability of the Linux operating system.
[0088] Furthermore, in order to further improve the performance and stability of the Linux operating system, after step S220, the method further includes the following steps:
[0089] Step S230: setting the target disk information and the startup information of the Linux kernel file in the grub configuration file, so as to guide the Linux operating system to start up through the grub configuration file.
[0090] Among them, the grub configuration file is used to guide the Linux kernel to start up, and is usually used to customize the boot menu, set the default boot item, define the timeout period, and configure the kernel startup parameters, etc. Specifically, in the process of starting the Linux operating system, the location of the Linux kernel and the location of the root file system are determined by reading the content in the grub configuration file. After determining this information, the Linux kernel is guided to start up, and this information is also passed to the Linux kernel, so that the Linux kernel initializes the disk device and switches to the root file system.
[0091] In the above embodiment, by setting the target disk information and the startup information of the Linux kernel file in the grub configuration file, the startup of the Linux operating system can be guided by the grub configuration file, thereby ensuring the normal operation of the Linux operating system and improving the performance and stability of the Linux operating system.
[0092] Furthermore, when the Linux operating system runs abnormally, in order to more conveniently perform abnormality detection, the method further includes the following steps:
[0093] Step S310: Generate a log file and record the installation process of the Linux operating system in the log file.
[0094] Step S320: Store the log file in the ROOT partition so that when the Linux operating system runs abnormally, the cause of the abnormality can be determined through the log file.
[0095] Among them, log files are used to record events, operations, error messages, and status changes that occur during the Linux operating system installation process. Log files are usually stored in text format and can be read by technicians to track installation progress, diagnose problems, or conduct audits. In the system maintenance phase after installation, log files can be used as a reference to help maintenance personnel understand the system configuration and installation history. In particular, when the Linux operating system runs abnormally, maintenance personnel can check log files to determine whether the system runs abnormally because the installation process did not follow the established steps and configurations.
[0096] In the above embodiment, each operation step in the installation process is recorded in a log file, which helps to audit and track the Linux operating system and can also provide a reference for subsequent system maintenance and problem diagnosis.
[0097] According to another aspect of the embodiment of the present application, a Linux operating system installation device is also provided. Figure 5 As shown, Figure 5 A structural schematic diagram of the Linux operating system installation device provided in an embodiment of the present application is shown, and the Linux operating system installation device 2 includes: a first acquisition module 21, a sending module 22, a second acquisition module 23, a generation module 24, a partition module 25, a first copy module 26 and a second copy module 27.
[0098] The first acquisition module 21 is used to obtain the image file of the Linux operating system, wherein the system files of the Linux operating system in the image file are not stored in the format of disk partitions. The sending module 22 is used to obtain the installation mode list from the image file and send it to the display screen to display the installation mode list. The second acquisition module 23 is used to obtain configuration information in response to the installation mode selected by the user, and the configuration information includes target disk information and disk partition information. The generation module 24 is used to generate a partition table according to the disk partition information, and store the partition table to the target disk corresponding to the target disk information. The partition module 25 is used to partition the target disk according to the partition table to generate an EFI partition and a ROOT partition. The first copy module 26 is used to copy the EFI file and the Linux kernel file in the system file to the EFI partition. The second copy module 27 is used to copy the root file system in the system file to the ROOT partition.
[0099] In the above embodiment, during the process of installing the Linux operating system using the image file, the configuration information such as the target disk information and the disk partition information is obtained to generate a partition table and partition the target disk during the installation process, and then the system files of the Linux operating system in the image file are copied to the corresponding partitions. Under the premise of ensuring that the Linux operating system can be normally stored in the format of disk partitions on the target disk, the system files in the image file do not need to be stored in the format of disk partitions, that is, only the system files of the Linux operating system need to be stored in the image file, and there is no need to reserve space in the image file for users to store data, and there is no need to store the partition table in the image file, which can effectively reduce the space occupied by the image file and shorten the time for downloading and copying the image file.
[0100] According to another aspect of the embodiment of the present application, there is also provided an electronic device, such as Figure 6 As shown, Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown, and the specific embodiment of the present application does not limit the specific implementation of the electronic device.
[0101] like Figure 6 As shown, the electronic device 1 may include: a processor (processor) 11 and a memory (memory) 12.
[0102] The memory 12 is used to store a computer program 13. The memory 12 may include a high-speed RAM memory, or may also include a non-volatile memory, such as at least one disk memory. The computer program 13 may include computer executable instructions.
[0103] The processor 11 is used to execute the computer program 13 to implement the above-mentioned Linux operating system installation method embodiment.
[0104] The processor 11 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the electronic device 1 may be processors of the same type, such as one or more CPUs; or may be processors of different types, such as one or more CPUs and one or more ASICs.
[0105] In the above embodiment, during the process of installing the Linux operating system using the image file, the configuration information such as the target disk information and the disk partition information is obtained to generate a partition table and partition the target disk during the installation process, and then the system files of the Linux operating system in the image file are copied to the corresponding partitions. Under the premise of ensuring that the Linux operating system can be normally stored in the format of disk partitions on the target disk, the system files in the image file do not need to be stored in the format of disk partitions, that is, only the system files of the Linux operating system need to be stored in the image file, and there is no need to reserve space in the image file for users to store data, and there is no need to store the partition table in the image file, which can effectively reduce the space occupied by the image file and shorten the time for downloading and copying the image file.
[0106] An embodiment of the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned Linux operating system installation method embodiment is implemented.
[0107] An embodiment of the present application provides a computer program, which can be executed by a processor to implement the above-mentioned Linux operating system installation method embodiment.
[0108] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned Linux operating system installation method embodiment is implemented.
[0109] In several embodiments provided in the present application, if any function is implemented in the form of a software function module / unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, part or all of the technical solution of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, server or other electronic device) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (RandomAccess Memory, RAM), disk or optical disk and other media that can store computer program code.
[0110] The algorithm or display provided here are not inherently related to any specific computer, virtual system or other equipment. Various general systems can also be used together with the teaching based on this. According to the above description, it is obvious to construct the structure required for this type of system. In addition, the present application embodiment is not directed to any specific programming language yet. It should be understood that various programming languages can be utilized to realize the content of the present application described here, and the above description of specific languages is to disclose the best mode of implementation of the present application.
[0111] It should be noted that the above embodiments illustrate the present application rather than limit the present application, and that those skilled in the art may design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be constructed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of multiple such elements. The present application may be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In the claims that list several devices, several units or modules in these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be understood as limitations on the order of execution.
[0112] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A Linux operating system installation method, characterized in that: The method comprises: Obtaining an image file of a Linux operating system, wherein system files of the Linux operating system in the image file are not stored in a disk partition format; Obtaining an installation mode list from the image file, and sending the list to a display screen to display the installation mode list; In response to the installation mode selected by the user, obtaining configuration information, the configuration information including target disk information and disk partition information; Generate a partition table according to the disk partition information, and store the partition table in a target disk corresponding to the target disk information; Partition the target disk according to the partition table to generate an EFI partition and a ROOT partition; Copy the EFI file and the Linux kernel file in the system file to the EFI partition; The root file system in the system file is copied to the ROOT partition.
2. The Linux operating system installation method according to claim 1, characterized in that: The obtaining of configuration information in response to the installation mode selected by the user specifically includes: In response to the manual installation mode selected by the user, obtaining a configuration information list from the image file and sending the configuration information list to the display screen to display the configuration information list; The configuration information input by the user is obtained.
3. The Linux operating system installation method according to claim 2, characterized in that: After obtaining the configuration information input by the user, the method further includes: Determine the free disk space of the target disk; Counting the required disk space corresponding to the disk partition information, wherein the required disk space is the total space of multiple disk partitions recorded in the disk partition information; Determining whether the free disk space is greater than or equal to the required disk space; If the free disk space is greater than or equal to the required disk space, executing the step of generating a partition table according to the disk partition information and storing the partition table in the target disk corresponding to the target disk information; If the free disk space is less than the required disk space, a configuration failure instruction is generated, and the configuration failure instruction is sent to the display screen to pop up a configuration failure window to show that the target disk space is insufficient, and jump to the step of obtaining the configuration information input by the user.
4. The Linux operating system installation method according to claim 1, characterized in that: The obtaining of configuration information in response to the installation mode selected by the user specifically includes: In response to the automatic installation mode selected by the user, obtaining a pre-stored configuration information file from the image file; Parsing the configuration information file to obtain the configuration information; Determine the free disk space of the target disk; Counting the required disk space corresponding to the disk partition information, wherein the required disk space is the total space of multiple disk partitions recorded in the disk partition information; Determining whether the free disk space is greater than or equal to the required disk space; If the free disk space is greater than or equal to the required disk space, executing the step of generating a partition table according to the disk partition information and storing the partition table in the target disk corresponding to the target disk information; If the free disk space is less than the required disk space, the installation of the operating system is terminated, an installation failure instruction is generated, and sent to the display screen to pop up an installation failure window to display the insufficient target disk space.
5. The Linux operating system installation method according to claim 1, characterized in that: The configuration information also includes system information; After copying the root file system in the system file to the ROOT partition, the method further includes: Setting the system information in the root file system of the ROOT partition; A swap partition is created in the root file system to expand memory capacity when the Linux operating system is short of memory.
6. The Linux operating system installation method according to claim 5, characterized in that: After creating a swap partition in the root file system to expand memory capacity when the Linux operating system lacks memory, the method further includes: The target disk information and the startup information of the Linux kernel file are set in a grub configuration file, so as to guide the Linux operating system to start up through the grub configuration file.
7. The Linux operating system installation method according to claim 1, characterized in that: The method further comprises: Generate a log file and record the installation process of the Linux operating system in the log file; The log file is stored in the ROOT partition, so that when the Linux operating system runs abnormally, the cause of the abnormality is determined through the log file.
8. A Linux operating system installation device, characterized in that: The device comprises: A first acquisition module is used to acquire an image file of a Linux operating system, wherein the system files of the Linux operating system in the image file are not stored in a disk partition format; A sending module, used for obtaining the installation mode list from the image file, and sending it to a display screen to display the installation mode list; A second acquisition module, configured to acquire configuration information in response to the installation mode selected by the user, wherein the configuration information includes target disk information and disk partition information; A generating module, used for generating a partition table according to the disk partition information, and storing the partition table in a target disk corresponding to the target disk information; A partitioning module, used for partitioning the target disk according to the partition table to generate an EFI partition and a ROOT partition; A first copy module, used for copying the EFI file and the Linux kernel file in the system file to the EFI partition; The second copy module is used to copy the root file system in the system file to the ROOT partition.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the Linux operating system installation method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the Linux operating system installation method according to any one of claims 1 to 7 is implemented.