Operating system installation method and apparatus

By configuring GRUB in the virtual machine's boot menu and managing the storage locations of initrd and vmlinuz files, a fast operating system switch is achieved, solving the problem of low operating system deployment efficiency in existing technologies and improving the efficiency of operating system deployment.

CN115857968BActive Publication Date: 2026-03-20BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-13
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing technologies have low operating system deployment efficiency and cannot quickly switch between different operating systems, resulting in cumbersome virtual machine installation.

Method used

By configuring the target operating system's GRUB settings in the virtual machine's boot options, the virtual machine can be restarted to obtain the target kernel file, enabling rapid switching of operating systems, including the storage location management of the initrd and vmlinuz files.

Benefits of technology

Operating system switching can be achieved quickly without installing a new virtual machine, improving the efficiency of operating system deployment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115857968B_ABST
    Figure CN115857968B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of operating systems, and provides an operating system installation method and device. The method comprises the following steps: in response to a switching operation of a target operating system, restarting a virtual machine deployed by a terminal device, so as to obtain a target kernel file of the target operating system from each kernel file stored in the virtual machine according to a grub configuration of the target operating system in a starting item of the virtual machine; and installing the target operating system according to the target kernel file, so as to switch an original operating system of the virtual machine to the target operating system; wherein the grub configuration comprises a storage position of the target kernel file; and the kernel file comprises an initrd file and a vmlinuz file. The operating system installation method provided in the application can improve the deployment efficiency of the operating system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of operating systems, in particular to an operating system installation method and device. BACKGROUND

[0002] In a cloud environment, the way to install a business virtual machine is usually achieved by an ISO image file. The general operation method is to upload a local ISO image file to the storage system of a cloud server through the management interface of the cloud server, and then install the virtual machine through a graphical interface

[0003] Configure the memory information, CPU information, disk information, network information, etc. of the pre-created virtual machine, allocate resources to the virtual machine, and finally complete the creation and run. However, after creating a virtual machine using this method, the operating system running in the virtual machine is fixed. For example,

[0004] If a virtual machine installed with the CentOS operating system needs to switch from the CentOS5 release version to the Ubuntu operating system due to business needs, a new virtual machine can only be reinstalled,

[0005] which causes the installation of the operating system to be complicated and affects the deployment efficiency of the operating system. SUMMARY

[0006] The present application aims to at least solve one of the technical problems in the related art. To this end, the present application provides an operating system installation method, which can improve the deployment efficiency of the operating system.

[0007] The present application also provides an operating system installation device.

[0008] The present application also provides an electronic device.

[0009] The present application also provides a computer-readable storage medium.

[0010] The operating system installation method according to the first aspect of the present application comprises:

[0011] In response to a switching operation of a target operating system, restarting a virtual machine deployed by the terminal device to obtain a target kernel file of the target operating system from each kernel file stored according to a grub configuration of the target operating system in a startup item of the virtual machine;

[0012] According to the target kernel file, installing the target operating system to switch the original operating system of the virtual machine to the target operating system;

[0013] The grub configuration comprises a storage location of the target kernel file.

[0014] The kernel files include an initrd file and a vmlinuz file.

[0015] The operating system installation method provided by the embodiments of the present application enables the virtual machine to be restarted in response to a switching operation of the target operating system, so that the target kernel file of the target operating system is obtained from the stored kernel files through the grub configuration of the target operating system in the start item, and the target operating system is installed, so that the original operating system of the virtual machine is switched to the target operating system. Therefore, when different operating systems are needed, the grub configuration of the target operating system only needs to be added in the start item, and the switching of the operating system can be quickly realized by restarting the virtual machine, without the need to install a new virtual machine, thereby improving the deployment efficiency of the operating system.

[0016] According to an embodiment of the present application, the method further comprises:

[0017] The grub configuration is added in the start item recorded in the grub.cfg file according to the storage position of the target kernel file.

[0018] According to an embodiment of the present application, the method further comprises:

[0019] The working directory of the compiled Docker is compressed and packaged to obtain the initrd file.

[0020] The kernel file is generated and stored according to the initrd file and the vmlinuz file obtained from the ISO image, and the storage position of the kernel file is recorded.

[0021] According to an embodiment of the present application, in response to a switching operation of the target operating system, the virtual machine deployed by the terminal device is restarted to obtain the target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the start item of the virtual machine.

[0022] The grub configuration of the target operating system in the start item of the virtual machine is obtained to obtain the target kernel file of the target operating system from the stored kernel files.

[0023] The target kernel file of the target operating system includes:

[0024] In response to a switching operation of the target operating system, it is determined that the vmlinuz file of the target operating system is inconsistent with the vmlinuz file of the original operating system, and the virtual machine is restarted to obtain the target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the start item of the virtual machine.

[0025] The terminal device deploys a virtual machine to obtain a target kernel file of a target operating system from each kernel file stored according to a grub configuration of the target operating system in a startup item of the virtual machine.

[0026] According to one embodiment of the present application, further comprising:

[0027] determining that a vmlinuz file of the target operating system is consistent with a vmlinuz file of the original operating system, and obtaining an initrd file of the target operating system from a root file corresponding to the initrd file of the target operating system according to the vmlinuz file of the original operating system.

[0028]

[0029]

[0030] installing the target operating system according to the initrd file of the target operating system to switch the original operating system of the virtual machine to the target operating system.

[0031] According to one embodiment of the present application, installing the target operating system according to the initrd file of the target operating system comprises:

[0032] switching a working directory of the original operating system to a working directory of the initrd file of the target operating system to install the target operating system.

[0033] According to one embodiment of the present application, the working directory comprises a usr directory, an etc directory, and a lib directory.

[0034] The operating system installation apparatus according to the second aspect of the present application is applied to a terminal device, and comprises:

[0035] a kernel file obtaining module configured to restart a virtual machine deployed by the terminal device in response to a switching operation of a target operating system, to obtain a target kernel file of the target operating system from each kernel file stored according to a grub configuration of the target operating system in a startup item of the virtual machine;

[0036] a kernel file obtaining module configured to restart a virtual machine deployed by the terminal device in response to a switching operation of a target operating system, to obtain a target kernel file of the target operating system from each kernel file stored according to a grub configuration of the target operating system in a startup item of the virtual machine;

[0037] an operating system installation module configured to install the target operating system according to the target kernel file to switch an original operating system of the virtual machine to the target operating system;

[0038] wherein the grub configuration comprises a storage location of the target kernel file.

[0039] The kernel file comprises an initrd file and a vmlinuz file.​​

[0040] The electronic device according to the third aspect of the present application comprises a processor and a memory storing a computer program, and the processor implements the operating system installation method of any of the above embodiments when executing the computer program.

[0041] 5. The computer readable storage medium according to the fourth aspect of the present application, having stored thereon

[0042] 5. The computer readable storage medium according to the fourth aspect of the present application, having stored thereon

[0043] The computer program product according to the fifth aspect of the present application comprises: the computer

[0044] The computer program product according to the fifth aspect of the present application comprises: the computer

[0045] The one or more technical solutions in the embodiments of the present application have at least one of the following technical effects:

[0046] By configuring the grub configuration of the target operating system in the startup item of the virtual machine, when responding to the switching operation of the target operating system, the virtual machine is restarted to obtain the target kernel file of the target operating system from the stored kernel files through the grub configuration of the target operating system in the startup item, to install the target operating system, so that the original operating system of the virtual machine is switched to the target operating system, so that when different operating systems are needed, only the grub configuration of the target operating system needs to be added in the startup item, and the switching of the operating system can be quickly realized by restarting the virtual machine, without the need to install a new virtual machine, thereby improving the deployment efficiency of the operating system.

[0047] Further, by using the storage location of the target kernel file, the grub configuration of the target operating system corresponding to the target kernel file is added to the startup item, so that the kernel file of the new system can be found through the grub configuration of the startup item when the virtual machine of the terminal device is restarted, and loaded into the memory for running, thereby quickly obtaining the kernel file of the target operating system for installation, and improving the installation and deployment efficiency of the target operating system.

[0048] Further, when it is detected that the target operating system follows the vmlinuz file of the original operating system, only the working directory of the original operating system needs to be switched to the working directory of the initrd file of the target operating system, so that the installation of the target operating system can be realized without restarting, thereby further improving the installation and deployment efficiency of the target operating system. BRIEF DESCRIPTION OF DRAWINGS

[0049] In order to more clearly illustrate the technical solutions in the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0050] Figure 1 is a flowchart of an operating system installation method provided by an embodiment of the present application;

[0051] Figure 2 is a flowchart of recording the storage location of the kernel file in an embodiment of the present application;

[0052] Figure 3 is a flowchart of an operating system installation method provided by another embodiment of the present application;

[0053] Figure 4 is a structural diagram of an operating system installation device provided by an embodiment of the present application;

[0054] Figure 5 is a structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0056] In the following, the operating system installation method and device provided by the embodiments of the present application will be described and explained in detail through several specific embodiments.

[0057] Therefore, in an embodiment, an operating system installation method is provided, which is applied to a terminal device deployed with a virtual machine, and is used to implement installation of an operating system of the virtual machine. The terminal device can be a user terminal or a server. The user terminal can be a desktop terminal or a portable terminal, such as a desktop computer, a notebook computer, etc. The server can be an independent server or a server cluster composed of multiple servers to implement, and can also be a cloud server providing basic cloud computing services such as cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and big data and artificial intelligence sampling point device.

[0058] As Figure 1As shown, the operating system installation method provided in the embodiment includes:

[0059] In step 101, in response to a switching operation of a target operating system, a virtual machine deployed by the terminal device is restarted to obtain a target kernel file of the target operating system from each kernel file stored according to a grub configuration of the target operating system in a startup item of the virtual machine;

[0060] In step 102, the target operating system is installed according to the target kernel file to switch an original operating system of the virtual machine to the target operating system;

[0061] The grub configuration includes a storage location of the target kernel file.

[0062] The kernel file includes an initrd file and a vmlinuz file.

[0063] The grub configuration of the target operating system in the startup item of the virtual machine is configured, so that when the switching operation of the target operating system is responded to, the virtual machine is restarted to obtain the target kernel file of the target operating system from each kernel file stored according to the grub configuration of the target operating system in the startup item to install the target operating system, so that the original operating system of the virtual machine is switched to the target operating system, thereby when different operating systems need to be used, the grub configuration of the target operating system is only added in the startup item, and the switching of the operating system can be quickly realized by restarting the virtual machine, without the need to install a new virtual machine, thereby the deployment efficiency of the operating system can be improved.

[0064] In an embodiment, the terminal device can pre-store kernel files of each operating system, wherein the kernel files of each system can be made using a Dockerfile. The focus of writing the Dockerfile is to adapt different platform architectures such as x86, ARM, and domestic Shenwei platform using the same Dockerfile, so that the kernel files of vmlinuz and initrd adapted to different architectures can be automatically compiled. In order to achieve this, when writing the Dockerfile file, a suitable basic compilation environment needs to be selected, such as: X86 platform selects Centos basic system, ARM platform selects ARM version of Centos basic system, and Shenwei platform selects Shenwei basic system, and according to the package management tools used by different architecture platforms, the corresponding management tools are used, such as: Centos uses yum tool, Ubuntu uses apt tool, and various necessary software required by the system is installed.

[0065] After obtaining the kernel files of each operating system by writing the Dockerfile, the storage locations of the kernel files can be recorded to facilitate subsequent operating system switching, so that the corresponding kernel files can be obtained according to the storage locations.

[0066] As shown in Figure 2 The recording of the storage locations of the kernel files includes:

[0067] Step 201, compress and package the working directory of the compiled Docker mount to obtain the initrd file.

[0068] Step 202, generate the kernel file according to the initrd file and the vmlinuz file obtained from the ISO image, store the kernel file, and record the storage location of the kernel file.

[0069] In an embodiment, before making the kernel file, a unified compilation environment needs to be built by Docker to obtain the working directory of the Docker mount. The working directory can be obtained by first installing and running Docker, then using the Volume technology to mount the output directory in the container to the local, and then pulling each basic image corresponding to each operating system according to the architecture of the operating system. After obtaining each basic image, each package installation tool corresponding to each basic image is used to install the basic tools of each basic image, and the generated files after installation are stored in the usr, bin, lib, lib64, sbin, etc, var directories, etc. Then, the usr, bin, lib, lib64, sbin, etc, var directories are copied to the output directory, thereby forming the working directory of the Docker mount.

[0070] After obtaining the working directory of the Docker mount, the kernel file can be made using the Dockerfile. When making the kernel file using the Dockerfile, the vmlinuz file in the kernel file is generally obtained by decompressing the ISO image file, and the initrd file in the kernel file needs to be formed by a series of packaging operations in the Dockerfile file. The working directory of the mounted directory files required by the system for running, such as the usr directory, the etc directory, the lib directory, etc. is compressed to generate the final initrd file.

[0071] For example, for obtaining the kernel file, it can be firstly detected whether the working directory of the output mounting in the Docker exists locally, i.e. whether the working directory is acquired by the terminal device. If not acquired by the terminal device, the production of the kernel file is exited; otherwise, the working directory can be compressed and packaged by using the find, cpio and gzip commands, to generate the initrd file. Meanwhile, the ISO image is decompressed, and the vmlinuz file in the ISO image is copied, so as to obtain the initrd file and the vmlinuz file of the operating system for storage, and record the storage positions of the initrd file and the vmlinuz file of the operating system. In this way, the start item of the virtual machine deployed by the terminal device can be set through the recorded storage positions of the initrd file and the vmlinuz file, so that when the virtual machine is restarted, the corresponding initrd file and vmlinuz file can be acquired through the storage positions set in the start item for installation, thereby facilitating the installation of the operating system.

[0072] After determining the storage positions of the kernel files of the operating systems, the demand for starting and running other target operating systems on the basis of the original operating system can be met by adding a start item in the boot / grub / grub.cfg file. To avoid errors during starting, for adding the start item, it can be firstly detected whether the grub.cfg file exists in the terminal device. The grub (G Rand Unified Bootloader) is a multi-operating system start manager, which is used to boot different systems. It allows the user to select the operating system to be run when the computer starts, and can be used to select different kernel files on the operating system partition, and can also be used to pass start parameters to these kernel files. If the grub.cfg file exists in the terminal device, it indicates that the start item setting of the operating system can be performed, and at this time, a selected operating system in the operating systems can be determined as a target operating system. Meanwhile, the linux attribute can be used to change the kernel parameters of the operating system in the grub.cfg file according to the target operating system, and to make settings such as displaying the terminal and the Debug switch in the kernel parameters.

[0073] After the target operating system is determined, a new boot item is added in the grub.cfg file, and then a kernel file of the target operating system is obtained from each kernel file as a target kernel file, and then the root parameter in the grub.cfg file is set by using a linux attribute according to a storage location of a vmlinuz file in the target kernel file, so as to record the storage location of the vmlinuz file in the target kernel file in the grub.cfg file. And the root parameter in the grub.cfg file is set by using an initrd attribute according to a storage location of an initrd file in the target kernel file, so as to record the storage location of the initrd file in the target kernel file in the grub.cfg file. After the storage locations of the vmlinuz file and the initrd file in the target kernel file are recorded, the grub configuration of the target operating system is regenerated by using grub-install, so that the grub configuration of the target operating system corresponding to the target kernel file is added to the boot item.

[0074] By using the storage location of the target kernel file, the grub configuration of the target operating system corresponding to the target kernel file is added to the boot item, so that the kernel file of the new system can be found by the grub configuration of the boot item to be loaded into the memory for running when the virtual machine of the terminal device is restarted, so that the kernel file of the target operating system can be quickly obtained for installation, and the installation and deployment efficiency of the target operating system is improved.

[0075] After the setting of the boot item is completed, if a switching operation indicating that the original operating system is switched to the target operating system is received, for example, the target operating system is selected on a configuration interface of the virtual machine of the terminal device, the virtual machine deployed by the terminal device is restarted in response to the switching operation, so that the target kernel file of the target operating system is obtained to be loaded into the memory for running according to the grub configuration of the target operating system recorded in the boot item of the virtual machine when the virtual machine is restarted, so as to install the target operating system, thereby realizing switching of the original operating system of the virtual machine to the target operating system without reinstalling a new virtual machine.

[0076] In an embodiment, in response to the switching operation of the target operating system, the virtual machine deployed by the terminal device is restarted to obtain the target kernel file of the target operating system from each kernel file according to the grub configuration of the target operating system recorded in the boot item of the virtual machine, including:

[0077] In response to the switching operation of the target operating system, it is determined that the vmlinuz file of the target operating system is inconsistent with the vmlinuz file of the original operating system, and the virtual machine deployed by the terminal device is restarted to obtain a target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the startup item of the virtual machine.

[0078] In an embodiment, after the switching operation is acquired, the vmlinuz file of the target operating system can be detected first to determine whether the vmlinuz file of the target operating system is consistent with the vmlinuz file of the original operating system. For example, whether the vmlinuz file of the target operating system is consistent with the vmlinuz file of the original operating system can be determined by comparing the attribute information of the two, such as the corresponding ISO image of the two or the storage location of the two. If the two are copied from the same ISO image and / or have the same storage location, it can be determined that they are consistent, otherwise, it is determined that they are inconsistent.

[0079] If the two are inconsistent, it indicates that the target operating system does not need to follow the vmlinuz file of the original operating system, at this time, the virtual machine deployed by the terminal device is restarted to install the target operating system through the grub configuration in the startup item.

[0080] In an embodiment, as shown in Figure 3 , it further comprises:

[0081] Step 301, determining that the vmlinuz file of the target operating system is consistent with the vmlinuz file of the original operating system, and obtaining the initrd file of the target operating system from the root file corresponding to the initrd file of the target operating system according to the vmlinuz file of the original operating system;

[0082] Step 302, installing the target operating system according to the initrd file of the target operating system to switch the original operating system of the virtual machine to the target operating system.

[0083] In an embodiment, if it is detected that the vmlinuz file of the target operating system is consistent with the vmlinuz file of the original operating system, it indicates that the target operating system can use the vmlinuz kernel file of the original operating system, and at this time, only the scenario of switching a new working directory is needed to realize the installation of the target operating system. Therefore, when the switching operation is acquired, if the vmlinuz file of the target operating system is consistent with the vmlinuz file of the original operating system, the vmlinuz file of the original operating system is used to enter the root file corresponding to the initrd file of the target operating system to acquire the initrd file of the target operating system from the root file. Then, the initrd file of the target operating system is decompressed to install the target operating system by using the decompressed initrd file.

[0084] The installation of the target operating system by using the decompressed initrd file can be switching the working directory of the initrd file of the original operating system to the working directory of the initrd file of the target operating system by using the chroot command to realize the installation of the target operating system.

[0085] In this way, when it is detected that the target operating system uses the vmlinuz file of the original operating system, the installation of the target operating system can be realized by only switching the working directory of the original operating system to the working directory of the initrd file of the target operating system, without the need of restarting, thereby further improving the installation and deployment efficiency of the target operating system.

[0086] The operating system installation apparatus provided in the present application is described below, and the operating system installation apparatus described below can be referred to in correspondence with the operating system installation method described above.

[0087] In an embodiment, as shown in Figure 4 An operating system installation apparatus is provided, applied to a terminal device, and includes:

[0088] The kernel file acquisition module 210 is configured to respond to a switching operation of a target operating system, restart a virtual machine deployed by the terminal device, and acquire a target kernel file of the target operating system from each kernel file stored according to a grub configuration of the target operating system in a startup item of the virtual machine.

[0089] The operating system installation module 220 is configured to install the target operating system according to the target kernel file to switch an original operating system of the virtual machine to the target operating system.

[0090] The grub configuration includes a storage location of the target kernel file.

[0091] The kernel files include an initrd file and a vmlinuz file.

[0092] By configuring the grub configuration of the target operating system in the startup item of the virtual machine, when a switching operation of the target operating system is responded, the virtual machine is restarted to obtain the target kernel file of the target operating system from the stored kernel files through the grub configuration of the target operating system in the startup item, to install the target operating system, and to switch the original operating system of the virtual machine to the target operating system, so that when different operating systems are needed, only the grub configuration of the target operating system needs to be added in the startup item, and the switching of the operating system can be quickly realized by restarting the virtual machine, without the need to install a new virtual machine, thereby improving the deployment efficiency of the operating system.

[0093] In an embodiment, the kernel file obtaining module 210 is further configured to:

[0094] When the terminal device has the grub.cfg file, the grub configuration is added in the startup item recorded in the grub.cfg file according to the storage location of the target kernel file.

[0095] In an embodiment, the kernel file obtaining module 210 is further configured to:

[0096] The working directory of the compiled Docker is compressed and packaged to obtain the initrd file;

[0097] According to the initrd file and the vmlinuz file obtained from the ISO image, the kernel file is generated and stored, and the storage location of the kernel file is recorded.

[0098] In an embodiment, the kernel file obtaining module 210 is specifically configured to:

[0099] In response to a switching operation of the target operating system, it is determined that the vmlinuz file of the target operating system is inconsistent with the vmlinuz file of the original operating system, and the virtual machine deployed by the terminal device is restarted to obtain the target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the startup item of the virtual machine.

[0100] In an embodiment, the kernel file obtaining module 210 is further configured to:

[0101] Determine that the vmlinuz file of the target operating system is consistent with the vmlinuz file of the original operating system. Based on the vmlinuz file of the original operating system, obtain the initrd file of the target operating system from the root file corresponding to the initrd file of the target operating system.

[0102] Install the target operating system according to the initrd file of the target operating system to switch the original operating system of the virtual machine to the target operating system.

[0103] In one embodiment, the kernel file acquisition module 210 is specifically used for:

[0104] Change the working directory of the original operating system to the working directory of the initrd file of the target operating system in order to install the target operating system.

[0105] In one embodiment, the working directory includes the usr directory, the etc directory, and the lib directory.

[0106] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call computer programs stored in the memory 830 to execute operating system installation methods, such as including:

[0107] In response to the target operating system switching operation, the virtual machine deployed on the terminal device is restarted to obtain the target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the boot items of the virtual machine;

[0108] Based on the target kernel file, install the target operating system to switch the original operating system of the virtual machine 5 to the target operating system;

[0109] The grub configuration includes the storage location of the target kernel file;

[0110] The kernel files include the initrd file and the vmlinuz file.

[0111] Moreover, the logic instructions in the memory 830 described above can be implemented in the form of software functional units and sold or used as independent products, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or substantially

[0112] The part that contributes to the prior art or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes instructions for making a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the embodiments of the present application. The storage medium of the foregoing 5 includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various storage medium that can store program codes.

[0113] The network device, etc.) execute all or part of the steps of the embodiments of the present application. The storage medium of the foregoing 5 includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various storage medium that can store program codes.

[0114] On the other hand, the embodiments of the present application also provide a processor readable storage medium, which stores a computer program, and the computer program is used to make a processor execute the method provided by the foregoing embodiments, for example, including:

[0115] In response to a switching operation of a target operating system, restarting a virtual machine deployed by the terminal device, to obtain a target kernel file of the target operating system from stored kernel files according to a grub configuration of the target operating system in a startup item of the virtual machine;

[0116] According to the target kernel file, installing the target operating system to switch an original operating system of the virtual machine to the target operating system;

[0117] According to the target kernel file, installing the target operating system to switch an original operating system of the virtual machine to the target operating system;

[0118] The grub configuration includes a storage location of the target kernel file;

[0119] The kernel file includes an initrd file and a vmlinuz file.

[0120] The processor readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to a magnetic memory (such as a floppy disk, a hard disk, a magnetic tape, a magneto-optical disk (MO), etc.), an optical memory (such as a CD, a DVD, a BD, a HVD, etc.), and a semiconductor memory (such as a ROM, an EPROM, an EEPROM, a non-volatile memory (NAND FLASH), a solid state disk (SSD)), etc.

[0121] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0122] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. An operating system installation method, characterized in that, Applied to terminal devices, including: In response to the target operating system switching operation, the virtual machine deployed on the terminal device is restarted to obtain the target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the boot items of the virtual machine; Based on the target kernel file, install the target operating system to switch the original operating system of the virtual machine to the target operating system; The grub configuration includes the storage location of the target kernel file; The kernel files include the initrd file and the vmlinuz file; In response to the target operating system switching operation, the virtual machine deployed on the terminal device is restarted to obtain the target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the boot menu of the virtual machine, including: In response to the target operating system switching operation, it is determined that the vmlinuz file of the target operating system is consistent with the vmlinuz file of the original operating system. Based on the vmlinuz file of the original operating system, the initrd file of the target operating system is obtained from the root file corresponding to the initrd file of the target operating system as the target kernel file of the target operating system.

2. The operating system installation method according to claim 1, characterized in that, Also includes: It is determined that the terminal device has a grub.cfg file. Based on the storage location of the target kernel file, the grub configuration is added to the boot entry recorded in the grub.cfg file.

3. The operating system installation method according to claim 1 or 2, characterized in that, Also includes: Compress and package the working directory mounted by the compiled Docker container to obtain the initrd file; The kernel file is generated and stored based on the initrd file and the vmlinuz file obtained from the ISO image, and the storage location of the kernel file is recorded.

4. The operating system installation method according to claim 1, characterized in that, In response to a target operating system switch operation, the virtual machine deployed on the terminal device is restarted to obtain the target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the boot menu of the virtual machine, including: In response to the target operating system switching operation, if it is determined that the vmlinuz file of the target operating system is inconsistent with the vmlinuz file of the original operating system, the virtual machine deployed on the terminal device is restarted to obtain the target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the boot items of the virtual machine.

5. The operating system installation method according to claim 1, characterized in that, Install the target operating system according to its initrd file, including: Change the working directory of the original operating system to the working directory of the initrd file of the target operating system in order to install the target operating system.

6. The operating system installation method according to claim 5, characterized in that, The working directory includes the usr directory, the etc directory, and the lib directory.

7. An operating system installation device, characterized in that, Applied to terminal devices, including: The kernel file acquisition module is used to respond to the target operating system switching operation, restart the virtual machine deployed on the terminal device, and obtain the target kernel file of the target operating system from the stored kernel files according to the grub configuration of the target operating system in the boot item of the virtual machine; An operating system installation module is used to install the target operating system according to the target kernel file, so as to switch the original operating system of the virtual machine to the target operating system; The grub configuration includes the storage location of the target kernel file; The kernel files include the initrd file and the vmlinuz file; The kernel file acquisition module is specifically used for: In response to the target operating system switching operation, it is determined that the vmlinuz file of the target operating system is consistent with the vmlinuz file of the original operating system. Based on the vmlinuz file of the original operating system, the initrd file of the target operating system is obtained from the root file corresponding to the initrd file of the target operating system as the target kernel file of the target operating system.

8. An electronic device comprising a processor and a memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the operating system installation method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the operating system installation method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Switching method and electronic device

    CN103870295A

  • Automatic deployment method and system supporting multiple domestic operating systems

    CN112230942A