Method, device and application of automatic burning virtual machine system

By using automated script processes in Linux maintenance mode, the problems of compatibility, cost, risk, and low efficiency of virtual machine burning methods are solved, achieving efficient, stable, and automated virtual machine system burning and installation, which is suitable for various virtual machine management systems.

CN118760448BActive Publication Date: 2024-11-22HANGZHOU FEIZHU SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411247834.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2024-11-22
Estimated Expiration
2044-09-06

AI Technical Summary

Technical Problem

Existing virtual machine burning methods suffer from poor compatibility, high cost, high risk, and low efficiency. In particular, they lack universality across different virtual machine management systems, and the burning process relies on external devices and is easily affected by the environment, making the operation cumbersome and inefficient.

Method used

The system employs an automated script process within Linux maintenance mode. This process involves creating a virtual machine, configuring the device, entering maintenance mode, performing the burning operation, and cleaning up. It automates the burning and installation of the virtual machine system by utilizing a temporary file storage server within the local area network to obtain the script and image files, thus avoiding reliance on external devices and improving compatibility and stability.

Benefits of technology

It improves the compatibility and stability of virtual machine burning, reduces costs and risks, increases burning efficiency, enables simultaneous burning and installation of multiple virtual machine systems, and reduces manual intervention and equipment operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760448B_ABST
    Figure CN118760448B_ABST
Patent Text Reader

Abstract

The present invention proposes a method, device and application of automatically burning a virtual machine system, including creating or downloading and executing a first script, creating a virtual machine with default parameters and setting two virtual optical drives and two virtual hard disks, filling in corresponding image files and setting hard disk capacity as needed, activating the virtual machine after setting the startup sequence, entering the command line interface of Linux maintenance mode after the virtual machine is started, creating or downloading and executing a second script for burning, burning the virtual machine system to be burned from the second virtual optical drive to the first virtual hard disk, and shutting down the virtual machine after the burning is successful. It also includes file detection, virtual device detection before burning, executing a third script for subsequent cleanup, and a fourth script to delete the virtual machine. It has the advantages of wide compatibility, automatic and efficient, low cost, and safe and stable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of virtual machine technology, and in particular to a method, a device and an application thereof for an automated virtual machine burning system. Background Art

[0002] In virtual machine technology, a virtual machine must be installed with a corresponding operating system. However, many operating systems do not provide image files that can be directly installed. Such image files need to be burned into a medium with a boot function before the installation of the virtual machine system can be booted.

[0003] Currently, the common virtual machine system burning methods are mainly the following:

[0004] 1. Use the commands provided by the virtual machine management system to burn it to the local virtual hard disk. When in use, read the local virtual hard disk to boot the installation of the virtual machine system.

[0005] 2. Use a third-party hard disk burning tool to burn it to the local virtual hard disk. When in use, read the local virtual hard disk to boot the installation of the virtual machine system.

[0006] 3. Use third-party optical drive burning software to burn the disc to an external optical disc device. When using it, connect the optical disc device to the target virtual machine management system / virtual machine management software through the CD / DVD optical drive to boot the virtual machine system for installation.

[0007] 4. Use third-party storage burning software to burn to an external storage device. When in use, connect the storage device to the target virtual machine management system / virtual machine management software via a data cable or interface to boot the virtual machine system for installation.

[0008] However, these existing methods have the following obvious defects:

[0009] 1. Poor compatibility: The built-in burning command only supports a few virtual machine management systems, while the rest of the virtual machine management systems and most virtual machine management software require an additional computer to install specific third-party burning tools for burning, which is not very universal.

[0010] 2. High cost: Some burning methods require the preparation of an external storage device such as a USB flash drive or USB drive or CD or SD card or mobile hard disk that meets the requirements of sufficient quantity, stability, high speed, and security. Some burning tools even require payment, which increases expenditure costs; changing to different platforms often requires changing corresponding tools and methods, increasing learning costs; many methods can only be manually operated in the interface and cannot be automated, which increases time costs.

[0011] 3. High risk: The environment affects the working state of external devices. High temperature, low temperature, power failure, poor contact, etc. will cause burning failure. Wrong operation methods may cause data loss, burning abnormalities, etc. Poor storage chips and materials may lead to uncontrollable consequences and low stability.

[0012] 4. Low efficiency: Many burning methods require specific operating steps; some methods also require manual verification to check whether the burning is successful; a storage device can only be used to install a virtual machine, and it cannot be automated or synchronized with multiple virtual machine systems at the same time; during the burning process, it is necessary to continuously connect, identify, read, remove and other complicated and trivial operations of storage devices on different platforms, which is inefficient. Summary of the invention

[0013] The embodiments of the present invention provide a method, device and application of an automatic burning virtual machine system, aiming at the problems of poor compatibility, high cost, high risk and low efficiency existing in the current technology.

[0014] The core technology of the present invention mainly utilizes the Linux maintenance mode to realize the automatic burning and installation of the virtual machine system through a series of scripts, including the steps of creating a virtual machine, setting up virtual devices, entering maintenance mode, performing burning operations, cleaning and optional virtual machine deletion, etc., which solves many problems of the existing virtual machine burning methods.

[0015] In a first aspect, the present invention provides a method for automatically burning a virtual machine system, the method comprising the following steps:

[0016] S00, creating or downloading and executing a first script;

[0017] S10, creating a virtual machine with default parameters, and setting the number of virtual CD-ROM drives and virtual hard disks to two;

[0018] S20, filling the image file of the Linux system to be maintained into the first virtual CD-ROM drive, filling the image file of the virtual machine system to be burned into the second virtual CD-ROM drive, and setting the capacity of the two virtual hard disks as needed;

[0019] S30, setting the boot sequence, setting and activating the virtual machine according to the first virtual CD-ROM drive, the second virtual CD-ROM drive, the first virtual hard disk and the second virtual hard disk;

[0020] S40. After the virtual machine is started, enter the command line interface of Linux maintenance mode;

[0021] S50, creating or downloading and executing a second script;

[0022] S60, using a burning command to burn the virtual machine system to be burned from the second virtual optical drive to the first virtual hard disk;

[0023] S70. After the burning is successful, shut down the virtual machine.

[0024] Furthermore, in step S20, the capacity of the first virtual hard disk is set to be more than twice the image file of the virtual machine system to be burned, and the capacity of the second virtual hard disk is set to be more than 32 GB.

[0025] Furthermore, between step S10 and step S20, a file check is performed, including the virtual machine system file to be burned and the Linux file with maintenance mode; if the file does not exist, it is downloaded from the network and decompressed.

[0026] Furthermore, in step S60, before burning, it is first detected whether all virtual hard disks and virtual optical drives are successfully loaded, and the number is greater than or equal to 2;

[0027] If yes, the virtual hard disk and virtual optical drive will be automatically matched according to capacity and type; if not, an error message will be given and the burning process will be exited.

[0028] Furthermore, the method further includes step S80, after the virtual machine is shut down, creating or downloading and executing a third script;

[0029] Step S90: delete all virtual optical drives and restart the virtual machine to enter the virtual machine system installation interface, and use the second virtual hard disk as the system installation disk.

[0030] Furthermore, a fourth script is included, which deletes the corresponding virtual machine in response to the virtual machine ID input by the user, or deletes all virtual machines in response to the all-delete instruction input by the user.

[0031] Furthermore, in step S00, a temporary file storage server is located in a local area network, and all scripts and image files are stored on the temporary file storage server.

[0032] In a second aspect, the present invention provides a device for automatically burning a virtual machine system, comprising:

[0033] Temporary file storage server module, used to store all scripts and image files;

[0034] The LAN module provides local network services for data interaction between the temporary file storage server module and the virtual machine module;

[0035] The virtual machine module is used to create a virtual machine with default parameters and set the number of virtual optical drives and virtual hard disks to two; fill the image file of the Linux system in maintenance mode into the first virtual optical drive, fill the image file of the virtual machine system to be burned into the second virtual optical drive, and set the capacity of the two virtual hard disks as needed; set the startup sequence, set and activate the virtual machine according to the first virtual optical drive, the second virtual optical drive, the first virtual hard disk and the second virtual hard disk; after the virtual machine is started, enter the command line interface of the Linux maintenance mode; create or download and execute the second script; use the burning command to burn, and burn the virtual machine system to be burned from the second virtual optical drive to the first virtual hard disk; and shut down the virtual machine after the burning is successful.

[0036] In a third aspect, the present invention provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the above-mentioned method of automatically burning a virtual machine system.

[0037] In a fourth aspect, the present invention provides a readable storage medium, in which a computer program is stored. The computer program includes a program code for controlling a process to execute the process. The process includes the method of automatically burning a virtual machine system according to the above-mentioned method.

[0038] The main contributions and innovations of the present invention are as follows:

[0039] 1. Improved compatibility

[0040] In the prior art, the use of built-in burning commands only supports a few virtual machine management systems, while the remaining virtual machine management systems and most virtual machine management software need to rely on an additional computer to install a specific third-party burning tool for burning, and the versatility is not high. The present invention implements the burning of the virtual machine system in Proxmox VE through specific scripts and processes, does not rely on a specific virtual machine management system or an additional computer, and greatly improves compatibility. Therefore, the current mainstream virtual machine management systems directly installed on the motherboard, such as Proxmox VE, VMware Esxi, Unraid, etc., and virtual machine management software installed on the host host, such as Parallels Desktop, VMware Fusion, VMware Workstation Player, Oracle VM Virtual Box, etc., can all adopt the method of the present invention. The specific platform only needs targeted trimming, the basic steps are consistent, and it is not limited to specific platforms and specific devices, and it has strong versatility.

[0041] 2. Cost reduction

[0042] In the prior art, some burning methods require the preparation of external storage devices, which increases the expenditure cost; changing different platforms often requires the replacement of corresponding tools and methods, which increases the learning cost; many methods can only be operated manually in the interface and cannot be automated, which increases the time cost. The present invention does not require additional external storage devices, and the required scripts and image files can be obtained through the temporary file storage server in the local area network, reducing the expenditure cost. At the same time, the entire burning and installation process has a high degree of automation, which reduces the learning cost and time cost. Various files and startup virtual disks can be deleted directly after use, saving the capacity of the local hard disk. The effect of slimming and leaving no trace is achieved.

[0043] 3. Risk reduction

[0044] In the prior art, the environment affects the working state of external devices. High temperature, low temperature, power failure, poor contact, etc. can cause burning failure. Wrong operation methods may cause data loss, burning abnormalities, etc. Poor storage chips and materials may lead to uncontrollable consequences and low stability. The present invention performs burning operations inside the virtual machine, which is not affected by external environmental factors and reduces the risk of burning failure. At the same time, through strict detection and matching steps, the accuracy and stability of the burning process are ensured.

[0045] 4. Improved efficiency

[0046] In the prior art, many burning methods require specific operation steps; some methods also require manual verification to check whether the burning is successful; a storage device can only be used for the installation of a virtual machine, and it is impossible to automate and simultaneously burn multiple virtual machine systems; during the burning process, it is necessary to continuously perform complicated and trivial operations such as connecting, identifying, reading, and removing storage devices on different platforms, etc., which is inefficient. The present invention uses automated script execution, except for manual selection and manual input required to enter the maintenance mode of Linux, other operations are completely automated, without the need for manual intervention and manual proofreading; there is no need to frequently connect / remove storage devices; there is no restriction that a storage device can only be connected to one virtual machine; it also avoids the need to clear the storage device and format it in a specific format, and can burn any system at will, which is flexible and free; in addition, it can simultaneously perform synchronous burning deployment of multiple virtual machine systems, and the efficiency is increased by 90% compared with the previous method.

[0047] The details of one or more embodiments of the invention are set forth in the following drawings and description so that other features, objects, and advantages of the invention are more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0049] Figure 1 is a flow chart of a method for automatically burning a virtual machine system according to an embodiment of the present invention;

[0050] Figure 2 4 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0051] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0052] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0053] Embodiment 1

[0054] The present invention aims to propose a method for automatically burning a virtual machine system, which is implemented through the maintenance mode provided by Linux. Specifically, referring to Figure 1 Take the open source virtual machine management system ProxmoxVE, which uses RockyLinux to automatically burn the OpenWrt virtual machine system, and temporarily deploys a LAN script storage service, and directly downloads the script when using it as an example:

[0055] The first step is to create or download and execute the following script [s1_create.sh] in ProxmoxVE to automatically create and set up virtual machines. The script content of s1_create.sh is as follows:

[0056] #! / bin / bash

[0057] #ScriptName:s1_create.sh

[0058] #Description:Technical point Step 1 - Used for automatic creation and setting of virtual machines under PVE virtual management system.

[0059] #Author:Candy

[0060] #Date:2024-08-06

[0061] #################################

[0062] #Parameter Configuration#

[0063] #################################

[0064] readonlyVM_NAME="OpenWrt"

[0065] readonlyVM_CPU=1

[0066] readonlyVM_MEMORY=2048

[0067] #The capacity of the boot disk used for booting and installation after burning.

[0068] readonlyVM_BOOT_DISK=5

[0069] #The disk capacity used for virtual machine system installation and use.

[0070] readonlyVM_HARD_DISK=16

[0071] aliasLOG='f(){echo[$(TZ=UTC-8date"+%H:%M:%S")]:$1;};f'

[0072] #################################

[0073] #Steps#

[0074] #################################

[0075] #1. Detection File

[0076] LOG"=========File check whether it exists========"

[0077] readonlyISO_PATH=" / var / lib / vz / template / iso"

[0078] LOG "Local file save path: ${ISO_PATH}."

[0079] #(1) Check the files of the virtual machine system to be burned.

[0080] readonlyBURN_SYSTEM_NAME="OpenWrt"

[0081] readonlyBURN_SYSTEM_FILE="openwrt-23.05.3-x86-64-generic-ext4-combined-efi.img"

[0082] readonlyBURN_SYSTEM_LINK="https: / / downloads.openwrt.org / releases / 23.05.3 / targets / x86 / 64 / ${BURN_SYSTEM_FILE}.gz"

[0083] LOG"The name of the virtual machine system to be burned is: ${BURN_SYSTEM_NAME}."

[0084] LOG"The virtual machine system file to be burned is: ${BURN_SYSTEM_FILE}."

[0085] LOG"Check whether the virtual machine system files to be burned exist in this machine:"

[0086] if[-e"${ISO_PATH} / ${BURN_SYSTEM_FILE}"];then

[0087] LOG "The virtual machine system files to be burned exist, continue to the next step."

[0088] else

[0089] LOG "The virtual machine system file to be burned does not exist and will be downloaded from the network."

[0090] wget-P${ISO_PATH}${BURN_SYSTEM_LINK}

[0091] LOG "The virtual machine system files to be burned have been downloaded."

[0092] LOG "The virtual machine system files to be burned are starting to be decompressed."

[0093] gzip-d${ISO_PATH} / ${BURN_SYSTEM_FILE}.gz

[0094] LOG "The virtual machine system files to be burned have been decompressed. Continue to the next step."

[0095] fi

[0096] #(2)Detect Linux files with maintenance mode.

[0097] readonlyRESCUE_LINUX_NAME="RockyLinux"

[0098] readonlyRESCUE_LINUX_FILE="Rocky-9.4-x86_64-minimal.iso"

[0099] readonlyRESCUE_LINUX_LINK="https: / / download.rockylinux.org / pub / rocky / 9 / isos / x86_64 / ${RESCUE_LINUX_FILE}"

[0100] LOG"The name of the Linux with maintenance mode is: ${RESCUE_LINUX_NAME}."

[0101] LOG"The Linux file with maintenance mode is: ${RESCUE_LINUX_FILE}."

[0102] LOG"Detect whether the Linux file with maintenance mode exists on this machine:"

[0103] if[-e"${ISO_PATH} / ${RESCUE_LINUX_FILE}"];then

[0104] LOG "Linux file with maintenance mode exists, continue to the next step."

[0105] else

[0106] LOG "Linux with maintenance mode file does not exist, will be downloaded from the network."

[0107] wget-P${ISO_PATH}${RESCUE_LINUX_LINK}

[0108] LOG "Download of Linux file with maintenance mode completed, continue to the next step"

[0109] fi

[0110] LOG"========File detection completed========"

[0111] #2. Create a default virtual machine

[0112] LOG"=========The virtual machine is starting to be created========"

[0113] #(1) Get the next available virtual machine ID.

[0114] VM_ID=$(pveshget / cluster / nextid)

[0115] echo "newVM${VM_ID}:-id${VM_ID}"

[0116] #(2). Create a blank virtual machine.

[0117] qmcreate${VM_ID}--name${VM_NAME}

[0118] echo "createVM${VM_ID}:-name${VM_NAME}"

[0119] #(3)Set the default CPU.

[0120] qmset${VM_ID}--cpux86-64-v2-AES--cores${VM_CPU}--sockets${VM_CPU}

[0121] #(4)Set the default memory.

[0122] qmset${VM_ID}--memory${VM_MEMORY}

[0123] #(5) Set up the EFI hard disk.

[0124] qmset${VM_ID}--efidisk0local-lvm:0,efitype=4m,size=4M,pre-enrolled-keys=no

[0125] #(6)Set the default BIOS.

[0126] qmset ${VM_ID} --biosovmf

[0127] #(7)Set the default machine type.

[0128] qmset ${VM_ID} --machineq35

[0129] #(8)Set up the SCSI controller.

[0130] qmset${VM_ID}--scsihwvirtio-scsi-single

[0131] #(9) Set up the network.

[0132] qmset${VM_ID}--net0virtio,bridge=vmbr0,firewall=1

[0133] #(10) Dynamically adjust ThinPool. Some versions need to be set.

[0134] #lvmconfig--withcomments--typediffactivation / thin_pool_autoextend_threshold=80

[0135] #lvmconfig--withcomments--typediffactivation / thin_pool_autoextend_percent=20

[0136] LOG"=========Virtual machine creation completed========"

[0137] #3. Key setting point settings

[0138] LOG"=========Core setting point starts setting========"

[0139] #(1) Create and fill in virtual CD-ROM drive 1 as the Linux system image in maintenance mode.

[0140] qmset${VM_ID}--ide0local:iso / Rocky-9.4-x86_64-minimal.iso,media=cdrom

[0141] #(2) Create and fill in virtual CD-ROM drive 2 as the virtual machine system image to be burned.

[0142] qmset${VM_ID}--ide1local:iso / openwrt-23.05.3-x86-64-generic-ext4-combined-efi.img,media=cdrom

[0143] #(3) Create a blank virtual hard disk 1 to store the burning data of the virtual machine system image file.

[0144] qmset${VM_ID}--scsi0local-lvm:${VM_BOOT_DISK},iothread=1,size=${VM_BOOT_DISK}G

[0145] #(4) Create a blank virtual hard disk 1 for installing the virtual machine system.

[0146] qmset${VM_ID}--scsi1local-lvm:${VM_HARD_DISK},iothread=1,size=${VM_HARD_DISK}G

[0147] #(5) Set the boot order (virtual CD-ROM drive 1, virtual CD-ROM drive 2, virtual hard disk 1, virtual hard disk 2) and activate the virtual device.

[0148] qmset${VM_ID}--bootorder=ide0--bootdiskscsi0

[0149] LOG"========Core setting point setting completed========"

[0150] #4. Virtual Machine Operation

[0151] #(1) Prompt countdown.

[0152] LOG"=========The virtual machine starts========"

[0153] TIME_COUNTDOWN=5

[0154] while[${TIME_COUNTDOWN}-gt0];do

[0155] LOG"Virtual machine ${VM_NAME}:${VM_ID} will start after ${TIME_COUNTDOWN}s, please switch to Linux maintenance mode!"

[0156] sleep1

[0157] TIME_COUNTDOWN=$((TIME_COUNTDOWN-1))

[0158] done

[0159] LOG"=========Virtual machine startup completed========"

[0160] #(2)Start the virtual machine.

[0161] qmstart${VM_ID}.

[0162] After the virtual machine starts, you will be prompted to proceed to the next step.

[0163] In this embodiment, the general idea of ​​the first script (s1_create.sh) is:

[0164] First, configure the parameters, including the virtual machine name, CPU, memory, boot disk, and system installation disk capacity. Then perform file detection, including the virtual machine system files to be burned and the Linux files with maintenance mode. If the file does not exist, download it from the network and decompress it. Then create a default virtual machine, including obtaining the virtual machine ID, creating a blank virtual machine, setting the CPU, memory, BIOS, machine type, etc. Finally, set the key setting points, including creating a virtual CD-ROM drive and filling in the corresponding image file, creating a blank virtual hard disk for burning and installing the virtual machine system, setting the startup order and activating the virtual device.

[0165] In this embodiment, the means of building a temporary script storage service in a local area network is an existing technology, and the steps and principles are not repeated here. It can be built on a device running a virtual machine (built using virtual machine software or a system of a host device running a virtual machine), or a computer with moderate performance can be selected as a server to ensure that it has a stable network connection and sufficient storage space to store scripts and image files.

[0166] Step 2: After starting the virtual machine, you need to manually select the command line interface in the Linux maintenance mode because it spans different systems (since it is an operation interface of the prior art, it will not be shown in the figure or detailed description of the function). The operation steps are as follows:

[0167] a) On the RockyLinx installation interface, select Troubleshooting--> and press the "Enter" key.

[0168] b) Select the RescueaRockyLinuxsystem option and press the “Enter” key.

[0169] c) After the loading is complete, press the "1" key, then press the "Enter" key to enter the command line interface of the maintenance mode.

[0170] Step 3: Create or download and execute the following script [s2_burn.sh] to implement the automated burning system. The script content of s2_burn.sh is as follows:

[0171] #! / bin / bash

[0172] #ScriptName:s2_brun.sh

[0173] #Description: Technical point step 2 - used for automatic burning of virtual machines under the PVE virtual management system.

[0174] #Stored in Linux maintenance mode:

[0175] #->Either deploy a temporary file server and use the wget command to download to maintenance mode (recommended).

[0176] #-> Either create a new shellscript file in maintenance mode and type all the commands manually.

[0177] #Because Chinese characters are garbled in maintenance mode, logs are output in English.

[0178] #Author:Candy

[0179] #Date:2024-08-07

[0180] #################################

[0181] #Parameter Configuration#

[0182] #################################

[0183] readonlyVM_NAME="OpenWrt"

[0184] #Same as the variable defined in create.sh, used to automatically match the mounted virtual boot hard disk.

[0185] readonlyVM_BOOTDISK=5

[0186] #Same as the variable defined in create.sh, used to automatically match the mounted virtual hard disk.

[0187] readonlyVM_HARDDISK=16

[0188] #################################

[0189] #Burn Steps#

[0190] #################################

[0191] #(1) Check whether all virtual hard disks are loaded successfully. The number must be greater than or equal to 2.

[0192] echo

[0193] echo "========STARTCheckingDisks========"

[0194] DISKS_COUNT=$(lsblk-oTYPEawk'$1=="disk"{count++}END{printcount}')

[0195] if["${DISKS_COUNT}"-lt2];then

[0196] echo "Failedtoloaddisks,exitburning."

[0197] exit1

[0198] fi

[0199] echo "Therequired${DISKS_COUNT}numberofdiskshavebeenloaded."

[0200] echo "========ENDCheckingDisks========"

[0201] echo

[0202] #(2) Check whether all virtual CD-ROM drives are loaded successfully. The number must be greater than or equal to 2.

[0203] echo "========STARTCheckingCDROMs========"

[0204] CDROMS_COUNT=$(lsblk-oTYPEawk'$1=="rom"{count++}END{printcount}')

[0205] if["${CDROMS_COUNT}"-lt2];then

[0206] echo "Failedtoloadcdroms,exitburning."

[0207] exit1

[0208] fi

[0209] echo "The required ${CDROMS_COUNT} number of cdroms have been loaded."

[0210] echo "========END Checking CDROMs========"

[0211] echo

[0212] #(3) Automatically match virtual hard disks.

[0213] echo "========START Matching Disks========"

[0214] echo "Automatically match disk names based on their capacity:"

[0215] NAME_BOOTDISK=$(lsblk -o NAME,SIZE,TYPE | awk -v size="${VM_BOOTDISK}G" '$2==size && $3=="disk" {print $1}')

[0216] NAME_HARDDISK=$(lsblk -o NAME,SIZE,TYPE | awk -v size="${VM_HARDDISK}G" '$2==size && $3=="disk" {print $1}')

[0217] echo "The matched boot disk 1 is \"${NAME_BOOTDISK}\", hard disk 2 is \"${NAME_HARDDISK}\"."

[0218] if [ -z "${NAME_BOOTDISK}" ] && [ -z "${NAME_HARDDISK}" ]; then

[0219] echo "Failed to match disks, exit burning."

[0220] exit 1

[0221] fi

[0222] echo "========END Matching Disks========"

[0223] echo

[0224] #(4) Automatically match the virtual CD-ROM drive.

[0225] echo "========STARTMatchingCDROMs========"

[0226] echo "Automaticallymatchcdromnamesbasedontheirtype:"

[0227] NAME_RESCUECDROM=$(lsblk-oNAME,TYPE,MOUNTPOINTawk-vmp=" / run / install / repo"'$2=="rom"&&$3==mp{print$1}')

[0228] NAME_SYSTEMCDROM=$(lsblk-oNAME,TYPE,MOUNTPOINTawk'$2=="rom"&&$3==""{print$1}')

[0229] echo"Thematchedrescuecdrom1is\"${NAME_RESCUECDROM}\",systemcdrom2is\"${NAME_SYSTEMCDROM}\"."

[0230] if[-z"${NAME_RESCUECDROM}"][-z"${NAME_SYSTEMCDROM}"];then

[0231] echo "Failedtomatchcdroms,exitburning."

[0232] exit1

[0233] fi

[0234] echo "========ENDMatchingCDROMs========"

[0235] echo

[0236] #(5) Use native burning commands to achieve automated burning.

[0237] echo "========STARTBurning========"

[0238] echo"Burnvirtualmachine'ssystemfromSystemCD-ROM( / dev / ${NAME_SYSTEMCDROM})toBootableDisk( / dev / ${NAME_BOOTDISK}):"

[0239] ddif= / dev / ${NAME_SYSTEMCDROM}of= / dev / ${NAME_BOOTDISK}bs=4Mstatus=progress

[0240] if[$?-eq0];then

[0241] echo"Congratulations,virtualmachine'ssystem\"${VM_NAME}\"isburnedsuccessful!"

[0242] echo"Pleaseshutdownthisvirtualmachine."

[0243] echo"Andexecute\"clean.sh\"onthehostmachinetoproceedwiththesubsequentoperations."

[0244] echo"========ENDBurning========"

[0245] echo

[0246] read-p"ShutdownNow?(y / n):"answer

[0247] case${answer}in

[0248] [Yy]*)

[0249] echo"Shutdownthisvirtualmachinein3s..."

[0250] sleep3

[0251] shutdown-hnow ;;

[0253] [Nn]*)

[0254] echo"Cancel.Pleasemanuallyshutdown." ;;

[0256] *)

[0257] echo "Invalidinput,pleaseenteryorn." ;;

[0259] esac

[0260] else

[0261] echo "Burningfailed,pleasetryagain."

[0262] echo "========ENDBurning========"

[0263] fi

[0264] After the execution is successful, start burning.

[0265] In this embodiment, the general idea of ​​the second script (s2_burn.sh) is:

[0266] First, check whether all virtual hard disks and virtual optical drives are successfully loaded. The number must be greater than or equal to 2. Then automatically match virtual hard disks and virtual optical drives according to capacity and type. Finally, use the native burning command to achieve automatic burning, burning the virtual machine system from the system CD-ROM to the startup disk. If the burning is successful, prompt the user to shut down the virtual machine and perform subsequent cleanup operations. If the burning fails, prompt the user to try again.

[0267] Step 4. After shutting down the virtual machine, create or download and execute the following script [s3_clean.sh] to achieve automatic cleanup before subsequent installation. The specific code of s3_clean.sh is as follows:

[0268] #! / bin / bash

[0269] #ScriptName:s3_clean.sh

[0270] #Description: Technical point step 3 - used for automatic cleanup of virtual machines under the PVE virtual management system.

[0271] #Author:Candy

[0272] #Date:2024-08-08

[0273] #################################

[0274] #Parameter Configuration#

[0275] #################################

[0276] readonlyVM_NAME="OpenWrt"

[0277] #Same as the variables defined in create.sh.

[0278] readonlyVM_BOOT_DISK=5

[0279] #Same as the variables defined in create.sh.

[0280] readonlyVM_HARD_DISK=16

[0281] #################################

[0282] #Steps#

[0283] #################################

[0284] echo

[0285] echo "=========Virtual machine cleanup started========"

[0286] #(1) Search for the previously created virtual machine by name.

[0287] VM_ID=$(qmlistgrep-i${VM_NAME}awk'{print$1}')

[0288] if[-z"${VM_ID}"];then

[0289] echo">>>>>Error: Unable to find the specified '${VM_NAME}' virtual machine."

[0290] echo"=========Virtual machine cleanup failed========"

[0291] exit1

[0292] fi

[0293] echo">>>>>Found virtual machine "${VM_NAME}:${VM_ID}".

[0294] #(2)Stop the virtual machine.

[0295] echo">>>>>Stop virtual machine ${VM_ID}."

[0296] qmstop${VM_ID}

[0297] #(3) Delete all virtual drives.

[0298] CDROMS=$(qmconfig${VM_ID}grep-oP'^(idesatascsi)\d+:.*cdrom'cut-d:-f1)

[0299] forCDROMin${CDROMS};do

[0300] qmset ${VM_ID} -delete ${CDROM}

[0301] echo">>>>>The virtual CD-ROM drive "${CDROM}" has been deleted from the virtual machine "${VM_NAME}:${VM_ID}"."

[0302] done

[0303] #(4) Search for the virtual hard disk.

[0304] ID_BOOTDISK=$(echo$(qmconfig${VM_ID}grep-E"size=${VM_BOOT_DISK}G")awk-F:'{print$1}')

[0305] if[-z"${ID_BOOTDISK}"];then

[0306] echo">>>>>Error: Unable to find the specified startup disk."

[0307] echo"=========Virtual machine cleanup failed========"

[0308] exit1

[0309] fi

[0310] echo">>>>>Found the boot disk: ${ID_BOOTDISK}."

[0311] ID_HARDDISK=$(echo$(qmconfig${VM_ID}grep-E"size=${VM_HARD_DISK}G")awk-F:'{print$1}')

[0312] if[-z"${ID_HARDDISK}"];then

[0313] echo">>>>>Error: Unable to find the specified system disk."

[0314] echo"=========Virtual machine cleanup failed========"

[0315] exit1

[0316] fi

[0317] echo">>>>>Found system disk: ${ID_HARDDISK}."

[0318] #(4) Set the boot sequence (virtual boot hard disk 1, virtual blank hard disk 2) and activate the virtual device.

[0319] qmset${VM_ID}--bootorder="${ID_BOOTDISK};${ID_HARDDISK}"--bootdisk${ID_BOOTDISK}

[0320] echo"=========Virtual machine cleanup completed========"

[0321] echo">>>>>Start virtual machine ${VM_ID}."

[0322] qmstart${VM_ID}

[0323] echo">>>>>The virtual machine ${VM_ID} has been started. Please continue to install the virtual machine system."

[0324] echo

[0325] After successful execution, you can install the virtual machine system.

[0326] In this embodiment, the general idea of ​​the third script (s3_clean.sh) is:

[0327] First, search for the previously created virtual machine by name. If it is not found, exit. Then stop the virtual machine and delete all virtual CD-ROMs. Next, search for the virtual hard disk. If it is not found, exit. Finally, set the boot order and activate the virtual device, start the virtual machine, and prompt the user to continue the installation of the virtual machine system.

[0328] Step 5. Attach the script [s4_destroy.sh] to implement automated testing (not a required script or step). The specific code of s4_destroy.sh is as follows:

[0329] #! / bin / bash

[0330] #ScriptName:s4_destroy.sh

[0331] #Description: Technical point step 4 - used for virtual machine deletion under PVE virtual management system.

[0332] #Author:Candy

[0333] #Date:2024-08-09

[0334] #################################

[0335] #Parameter Configuration#

[0336] #################################

[0337] aliasLOG='f(){echo[$(TZ=UTC-8date"+%H:%M:%S")]:$1;};f'

[0338] #################################

[0339] #Steps#

[0340] #################################

[0341] LOG"========Start deleting virtual machine========"

[0342] read-p">>>Please enter the virtual machine ID to be deleted (enter 0 to delete all):"VM_ID

[0343] if["${VM_ID}"-eq0];then

[0344] qmlistawk'NR>1'whileIFS=read-rline;do

[0345] NAME=$(echo"$line"awk'{print$2}')

[0346] ID=$(echo"$line"awk'{print$1}')

[0347] LOG "Deleting virtual machine ${NAME}:${ID}."

[0348] qmstop${ID}

[0349] sleep3

[0350] qmdestroy ${ID} --purge

[0351] LOG "Virtual machine ${NAME}:${ID} has been deleted."

[0352] done

[0353] else

[0354] VM_NAME=$(qmconfig"${VM_ID}"grepnameawk-F':''{print$2}')

[0355] if[-z"${VM_NAME}"];then

[0356] LOG "Virtual machine ${VM_ID} does not exist!"

[0357] exit1

[0358] fi

[0359] LOG "Deleting virtual machine ${VM_NAME}:${VM_ID}."

[0360] qmstop${VM_ID}

[0361] sleep3

[0362] qmdestroy ${VM_ID} --purge

[0363] LOG "Virtual machine ${VM_NAME}:${VM_ID} has been deleted."

[0364] fi

[0365] LOG"========Deleting virtual machine completed========"

[0366] In this embodiment, the general idea of ​​the fourth script (s4_destroy.sh) is:

[0367] The user can enter the ID of the VM to be deleted. If 0 is entered, all VMs will be deleted. First, the VM will be stopped, then deleted and related data will be cleared.

[0368] Through the above steps, the present invention realizes the automatic burning and installation of the virtual machine system in Proxmox VE, improves compatibility, reduces costs, reduces risks, and improves efficiency.

[0369] The codes of the command line interface in the figure shown in this implementation are all required by the code standards and therefore cannot be translated into Chinese. Only the comments can be written in Chinese.

[0370] Embodiment 2

[0371] Based on the same concept, the present invention also proposes a device for automatically burning a virtual machine system, comprising:

[0372] Temporary file storage server module, used to store all scripts and image files;

[0373] The LAN module provides local network services for data interaction between the temporary file storage server module and the virtual machine module;

[0374] The virtual machine module is used to create a virtual machine with default parameters and set the number of virtual optical drives and virtual hard disks to two; fill the image file of the Linux system in maintenance mode into the first virtual optical drive, fill the image file of the virtual machine system to be burned into the second virtual optical drive, and set the capacity of the two virtual hard disks as needed; set the startup sequence, set and activate the virtual machine according to the first virtual optical drive, the second virtual optical drive, the first virtual hard disk and the second virtual hard disk; after the virtual machine is started, enter the command line interface of the Linux maintenance mode; create or download and execute the second script; use the burning command to burn, and burn the virtual machine system to be burned from the second virtual optical drive to the first virtual hard disk; and shut down the virtual machine after the burning is successful.

[0375] Embodiment 3

[0376] This embodiment also provides an electronic device, referring to Figure 2 , comprises a memory 404 and a processor 402, wherein the memory 404 stores a computer program, and the processor 402 is configured to run the computer program to execute the steps in any of the above method embodiments.

[0377] Specifically, the processor 402 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiment of the present invention.

[0378] Among them, the memory 404 may include a large capacity memory 404 for data or instructions. For example, but not limitation, the memory 404 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive, or a combination of two or more of these. In appropriate cases, the memory 404 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 404 may be inside or outside the data processing device. In a specific embodiment, the memory 404 is a non-volatile memory. In a specific embodiment, the memory 404 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable Programmable Read-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable Programmable Read-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. In appropriate circumstances, the RAM may be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM may be a fast page mode dynamic random access memory 404 (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.

[0379] The memory 404 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 402 .

[0380] The processor 402 reads and executes the computer program instructions stored in the memory 404 to implement any one of the methods for automatically burning a virtual machine system in the above embodiments.

[0381] Optionally, the electronic device may further include a transmission device 406 and an input / output device 408 , wherein the transmission device 406 is connected to the processor 402 , and the input / output device 408 is connected to the processor 402 .

[0382] The transmission device 406 can be used to receive or send data via a network. Specific examples of the above-mentioned network may include a wired or wireless network provided by a communication provider of the electronic device. In one example, the transmission device includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 406 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0383] Input / output devices 408 are used to input or output information.

[0384] Embodiment 4

[0385] This embodiment further provides a readable storage medium, in which a computer program is stored. The computer program includes a program code for controlling a process to execute the process. The process includes the method for automatically burning a virtual machine system according to the first embodiment.

[0386] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.

[0387] In general, various embodiments may be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects of the invention may be implemented in hardware, while other aspects may be implemented in firmware or software executed by a controller, microprocessor, or other computing device, but the invention is not limited thereto. Although various aspects of the invention may be shown and described as block diagrams, flow charts, or using some other graphical representation, it should be understood that, as non-limiting examples, the boxes, devices, systems, techniques, or methods described herein may be implemented in hardware, software, firmware, dedicated circuits or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof.

[0388] Embodiments of the present invention may be implemented by computer software that is executable by a data processor of a mobile device, such as in a processor entity, or by hardware, or by a combination of software and hardware. Computer software or programs (also referred to as program products) including software routines, applets and / or macros may be stored in any device-readable data storage medium, and they include program instructions for performing specific tasks. A computer program product may include one or more computer executable components configured to perform an embodiment when the program is run. One or more computer executable components may be at least one software code or a portion thereof. In addition, at this point, it should be noted that, for example, Figure 1 Any block of the logic flow in the program may represent program steps, or interconnected logic circuits, blocks and functions, or a combination of program steps and logic circuits, blocks and functions. The software may be stored on physical media such as memory chips or storage blocks implemented within the processor, magnetic media such as hard disk or floppy disks, and optical media such as, for example, DVDs and their data variants, CDs, etc. Physical media are non-transitory media.

[0389] Those skilled in the art should understand that the technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0390] The above embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present invention. It should be pointed out that, for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the attached claims.

Claims

1. A method for automatically burning a virtual machine system, characterized in that: The following steps are involved: S00, creating or downloading and executing a first script; S10, creating a virtual machine with default parameters, and setting the number of virtual CD-ROM drives and virtual hard disks to two; S20, filling the image file of the Linux system to be maintained into the first virtual CD-ROM drive, filling the image file of the virtual machine system to be burned into the second virtual CD-ROM drive, and setting the capacity of the two virtual hard disks as needed; S30, setting the boot sequence, setting and activating the virtual machine according to the first virtual CD-ROM drive, the second virtual CD-ROM drive, the first virtual hard disk and the second virtual hard disk; The first virtual hard disk is used for burning data storage of the virtual machine system, and the second virtual hard disk is used as an installation disk of the virtual machine system; S40. After the virtual machine is started, enter the command line interface of Linux maintenance mode; S50, creating or downloading and executing a second script; S60, using a burning command to burn the virtual machine system to be burned from the second virtual optical drive to the first virtual hard disk; S70. After the burning is successful, shut down the virtual machine.

2. The method for automatically burning a virtual machine system according to claim 1, characterized in that: In step S20, the capacity of the first virtual hard disk is set to be more than twice the image file of the virtual machine system to be burned, and the capacity of the second virtual hard disk is set to be more than 32 GB.

3. The method for automatically burning a virtual machine system according to claim 1, characterized in that: Between step S10 and step S20, a file check is performed, including the virtual machine system file to be burned and the Linux file with maintenance mode; if the file does not exist, it is downloaded from the network and decompressed.

4. The method for automatically burning a virtual machine system according to claim 1, characterized in that: In step S60, before burning, it is first detected whether all virtual hard disks and virtual optical drives are successfully loaded, and the number is greater than or equal to 2; If yes, the virtual hard disk and virtual optical drive will be automatically matched according to capacity and type; if not, an error message will be given and the burning process will be exited.

5. The method for automatically burning a virtual machine system according to claim 1, characterized in that: The step S80 is also included, after the virtual machine is shut down, creating or downloading and executing a third script; Step S90: delete all virtual optical drives and restart the virtual machine to enter the virtual machine system installation interface, and use the second virtual hard disk as the system installation disk.

6. The method for automatically burning a virtual machine system according to claim 1, characterized in that: The system further includes a fourth script, which deletes the corresponding virtual machine in response to a virtual machine ID input by a user, or deletes all virtual machines in response to a delete all instruction input by a user.

7. A method for automatically burning a virtual machine system according to any one of claims 1 to 6, characterized in that: In step S00, a temporary file storage server is located in a local area network, and all scripts and image files are stored on the temporary file storage server.

8. A device for automatically burning a virtual machine system, characterized in that: include: Temporary file storage server module, used to store all scripts and image files; The LAN module provides local network services for data interaction between the temporary file storage server module and the virtual machine module; A virtual machine module, used for creating or downloading and executing a first script; Used to create a virtual machine with default parameters, and set the number of virtual CD-ROM drives and virtual hard disks to two; fill the image file of the Linux system to be maintained in the first virtual CD-ROM drive, fill the image file of the virtual machine system to be burned in the second virtual CD-ROM drive, and set the capacity of the two virtual hard disks as needed; Set the boot sequence, set up and activate the virtual machine according to the first virtual CD-ROM drive, the second virtual CD-ROM drive, the first virtual hard disk and the second virtual hard disk; after the virtual machine starts, enter the command line interface of Linux maintenance mode; create or download and execute the second script; use the burning command to burn the virtual machine system to be burned from the second virtual CD-ROM drive to the first virtual hard disk; after the burning is successful, shut down the virtual machine; The first virtual hard disk is used for burning data storage of the virtual machine system, and the second virtual hard disk is used as an installation disk of the virtual machine system.

9. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to run the computer program to execute the method for automatically burning a virtual machine system according to any one of claims 1 to 7.

10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, wherein the computer program includes a program code for controlling a process to execute a process, wherein the process includes the method for automatically burning a virtual machine system according to any one of claims 1 to 7.