File system expansion method and device of virtual machine and electronic equipment

By monitoring and adjusting the capacity of the virtual machine data disk, the file system capacity of the virtual machine is automatically expanded, and the problem of low capacity expansion efficiency of virtual machine file system in the existing technology is solved, automatic capacity expansion is achieved, and operation efficiency is improved.

CN120067063APending Publication Date: 2025-05-30BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311629827.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-30
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

In the prior art, the file system expansion efficiency of virtual machines is low, and it requires manual uninstallation, expansion and mounting of data disks. The operation is cumbersome and inefficient.

Method used

By monitoring the real-time capacity of the target data disk, obtain the current capacity after the data disk is expanded, and adjust the file system capacity of the virtual machine according to the current capacity to achieve automatic capacity expansion.

Benefits of technology

It improves the efficiency of virtual machine file system expansion, realizes automated expansion, and reduces the steps and time of manual operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120067063A_ABST
    Figure CN120067063A_ABST
Patent Text Reader

Abstract

The invention relates to a file system capacity expansion method and device of a virtual machine and electronic equipment. The method comprises the following steps: monitoring the real-time capacity of a target data disk under the condition that an operation request for executing capacity expansion operation on the target data disk is received; after the capacity expansion operation is executed on the target data disk, the current capacity of the target data disk is obtained; and under the condition that the current capacity is greater than the historical capacity before the target data disk executes the capacity expansion operation, adjusting the system capacity of a file system of the virtual machine according to the numerical value of the current capacity. The technical problem that the expansion efficiency of the file system of the virtual machine is low is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and in particular, to a method and apparatus for expanding the file system of a virtual machine, and an electronic device. Background Art

[0002] In the prior art, the file system of a virtual machine can be stored in a data disk. If the virtual machine traffic increases, it is necessary to expand the capacity of the file system of the virtual machine. When expanding the file system of a virtual machine in the prior art, it is necessary to first unmount the data disk, then increase the capacity of the data disk, and finally mount the data disk to the virtual machine and configure the capacity of the file system of the virtual machine.

[0003] However, the capacity of the file system of the virtual machine in the above method depends entirely on manual expansion, and the capacity expansion efficiency is low. Summary of the Invention

[0004] This application provides a method and apparatus for expanding the file system of a virtual machine, and an electronic device, so as to solve the technical problem of low efficiency in expanding the file system of a virtual machine.

[0005] In a first aspect, this application provides a method for expanding the file system of a virtual machine, including: monitoring the real-time capacity of the target data disk when an operation request for expanding the target data disk is received; obtaining the current capacity of the target data disk after performing the expansion operation on the target data disk; and adjusting the system capacity of the file system of the virtual machine according to the value of the current capacity when the current capacity is greater than the historical capacity of the target data disk before the expansion operation is performed on the target data disk.

[0006] In a second aspect, this application provides an apparatus for expanding the file system of a virtual machine, including: a monitoring module, configured to monitor the real-time capacity of the target data disk when an operation request for expanding the target data disk is received; an obtaining module, configured to obtain the current capacity of the target data disk after performing the expansion operation on the target data disk; and an adjustment module, configured to adjust the system capacity of the file system of the virtual machine according to the value of the current capacity when the current capacity is greater than the historical capacity of the target data disk before the expansion operation is performed on the target data disk.

[0007] As an optional example, the monitoring module includes: a monitoring unit, configured to obtain the data disk identifier in the operation request; determine the target data disk in the data disks of the virtual machine according to the data disk identifier; start the monitoring script of the virtual machine, and the monitoring script obtains the data disk capacity of the target data disk once every predetermined time period; and determine the obtained data disk capacity as the real-time capacity.

[0008] As an alternative example, the above monitoring module further includes: an adjustment unit, configured to, during the process of the above monitoring script obtaining the data disk capacity of the above target data disk once every predetermined time period, increase the value of the above predetermined time period when the sizes of the data disk capacities obtained continuously for multiple times are the same; determine the latter data disk capacity among the data disk capacities obtained continuously twice when the sizes of the data disk capacities obtained continuously twice are different, and restore the value of the above predetermined time period to the initial value; and stop monitoring the data disk capacity of the above target data disk when the sizes of multiple data disk capacities obtained in subsequent monitoring are the same as the latter data disk capacity.

[0009] As an alternative example, the above adjustment unit includes: a determination subunit, configured to determine the latter data disk capacity as the above current capacity.

[0010] As an alternative example, the above adjustment module includes: a processing unit, configured to adjust the above system capacity to a first capacity, where the above first capacity is greater than the above historical capacity and less than or equal to the above current capacity.

[0011] As an alternative example, the above adjustment module further includes: a determination unit, configured to determine the required capacity of the above file system before adjusting the above system capacity to the first capacity; and determine the sum of the system capacity of the above file system and the required capacity as the above first capacity.

[0012] As an alternative example, the above determination unit includes: an estimation subunit, configured to estimate the change of the system capacity of the above file system within a predetermined time period starting from the current moment; and determine the difference between the maximum value and the current value in the above change as the above required capacity.

[0013] In a third aspect, the present application provides an electronic device, including: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, where the above memory stores a computer program, and the above processor is configured to implement the file system expansion method of the virtual machine in any one of the above when executing the above computer program.

[0014] In a fourth aspect, the present application further provides a computer storage medium, storing computer executable instructions, where the above computer executable instructions are used to execute the file system expansion method of the virtual machine in any one of the above of the present application.

[0015] The above technical solution provided by the embodiments of the present application has the following advantages compared with the prior art: In the process of expanding the system capacity of the file system of a virtual machine, the real-time capacity of the data disk monitored by the virtual machine can be used. If the real-time capacity of the data disk becomes larger, the system capacity of the file system is automatically expanded, achieving the purpose of automatically expanding the file system of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present invention and used together with the specification to explain the principles of the present invention.

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0018] One or more embodiments are exemplarily illustrated by the pictures in the corresponding accompanying drawings. These exemplary illustrations do not limit the embodiments. Elements with the same reference numerals in the drawings represent similar elements, unless otherwise stated, and the drawings in the figures do not constitute a proportional limitation.

[0019] Figure 1 It is a flowchart of a method for expanding the file system of a virtual machine provided by the embodiments of the present application;

[0020] Figure 2 It is a schematic diagram of the system disk and data disk of a virtual machine system for a method for expanding the file system of a virtual machine provided by the embodiments of the present application;

[0021] Figure 3 It is a flowchart of another method for expanding the file system of a virtual machine provided by the embodiments of the present application;

[0022] Figure 4 It is a flowchart of yet another method for expanding the file system of a virtual machine provided by the embodiments of the present application;

[0023] Figure 5 It is a flowchart of yet another method for expanding the file system of a virtual machine provided by the embodiments of the present application;

[0024] Figure 6 It is a schematic diagram of a system for expanding the file system of a virtual machine provided by the embodiments of the present application;

[0025] Figure 7 It is a schematic diagram of the structure of a device for expanding the file system of a virtual machine provided by the embodiments of the present application;

[0026] Figure 8 Schematic diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0027] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some but not all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0028] The following disclosure provides many different embodiments or examples for implementing different structures of the present invention. To simplify the disclosure of the present invention, the components and settings of specific examples are described below. Of course, they are only examples and are not intended to limit the present invention. In addition, the present invention may repeat reference numerals and / or letters in different examples. Such repetition is for the purpose of simplification and clarity and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0029] To solve the technical problem of low efficiency in expanding the file system of a virtual machine in the prior art, the present application provides a method for expanding the file system of a virtual machine, which can achieve the purpose of automatically expanding the file system of the virtual machine.

[0030] Figure 1 Flowchart of a method for expanding the file system of a virtual machine provided by an embodiment of the present application. As Figure 1 shown, the above method for expanding the file system of a virtual machine includes:

[0031] S102, when an operation request for performing an expansion operation on a target data disk is received, monitor the real-time capacity of the target data disk;

[0032] S104, after performing an expansion operation on the target data disk, obtain the current capacity of the target data disk;

[0033] S106, when the current capacity is greater than the historical capacity of the target data disk before the expansion operation is performed, adjust the system capacity of the file system of the virtual machine according to the value of the current capacity.

[0034] The disks of a virtual machine are divided into a system disk and a data disk. The system disk is used to install the operating system of the virtual machine, and the data disk is used to store the customer data of the virtual machine, that is, the file system. The system disk and the data disk can be cloud disks or local disks. Figure 2Schematic diagram of the system disk and data disk of the virtual machine in this embodiment. The virtual machine system of the virtual machine is located in the system disk, and the file system is located in the data disk. The system disk and the data disk can be cloud disks or local disks or a combination of both.

[0035] The above-mentioned target data disk can be the disk of the storage file system of the virtual machine. Since the storage space occupied by the file system fluctuates as the virtual machine runs. If the system capacity of the file system is insufficient, it will affect the execution of the tasks of the virtual machine. Therefore, it is necessary to expand the capacity of the file system. If the capacity of the file system is to be expanded, the data disk where the file system is located must be expanded first. When expanding the system disk, an operation request can be used to request the expansion. The operation request can include the identifier of the system disk to be expanded, the expanded size, the expansion time period, etc.

[0036] The real-time capacity of the above-mentioned target data disk can be the data obtained each time the data disk capacity of the target data disk is detected during the process of performing the expansion operation on the target data disk. For example, during the expansion of the data disk, the data disk capacity is detected 10 times, and 10 real-time capacities of the data disk are obtained. After the data disk is expanded, the current capacity after expansion is obtained. The current capacity is the real-time capacity obtained after the data disk is expanded.

[0037] The operation of obtaining the real-time capacity is executed by the virtual machine. The virtual machine can insert a monitoring script, and the monitoring script obtains the real-time capacity of the data disk.

[0038] The above-mentioned historical capacity is the capacity of the data disk of the virtual machine before the expansion operation is performed. If the current capacity is greater than the historical capacity, it means that the data disk expansion is successful. If the expansion is successful, the virtual machine automatically completes the expansion of the file system according to the value of the current capacity.

[0039] In the solution provided by the embodiment of the present application, during the process of expanding the system capacity of the file system of the virtual machine, the real-time capacity of the data disk can be monitored by the virtual machine. If the real-time capacity of the data disk becomes larger, the system capacity of the file system is automatically expanded, achieving the purpose of automatically expanding the file system of the virtual machine.

[0040] As an optional example, as Figure 3 shown, when receiving an operation request to perform an expansion operation on the target data disk, monitoring the real-time capacity of the target data disk includes:

[0041] S302, obtaining the data disk identifier in the operation request;

[0042] S304, determining the target data disk in the data disks of the virtual machine according to the data disk identifier;

[0043] S306. Start the monitoring script of the virtual machine. The monitoring script obtains the data disk capacity of the target data disk once every predetermined time period.

[0044] S308. Determine the obtained data disk capacity as the real-time capacity.

[0045] In this embodiment, a monitoring script for obtaining the data disk capacity is installed on the virtual machine. Before monitoring the real-time capacity of the target data disk, first determine which data disk is the target data disk to be monitored, which can be determined according to the data disk identifier. Obtain the data disk identifier from the operation request, determine the target data disk, and then start the monitoring script to obtain the real-time capacity once. Then, according to the predetermined time period in the monitoring script, obtain it once every predetermined time period, so as to record the fluctuation of the real-time capacity of the data disk.

[0046] As an optional example, in the process of the monitoring script obtaining the data disk capacity of the target data disk once every predetermined time period, the method further includes: when the sizes of the data disk capacities obtained continuously for multiple times are the same, increase the value of the predetermined time period; when the sizes of the data disk capacities obtained continuously twice are different, determine the latter data disk capacity among the data disk capacities obtained continuously twice, and restore the value of the predetermined time period to the initial value; when the sizes of multiple data disk capacities obtained in continuous monitoring are the same as the latter data disk capacity, stop monitoring the data disk capacity of the target data disk. After performing the capacity expansion operation on the target data disk, determine the latter data disk capacity as the current capacity.

[0047] In the process of real-time monitoring of the data disk capacity, if the data disk is not expanded, the data disk capacity does not change. Therefore, the fluctuation of the data disk capacity is a parallel line parallel to the X-axis. At this time, the time interval between obtaining the real-time capacity twice can be appropriately lengthened, that is, the value of the predetermined time period is increased, so as to avoid obtaining the same real-time capacity frequently. If the real-time capacities obtained before and after are different, it means that the data disk capacity has changed. At this time, monitor the changed data disk capacity, and restore the monitoring time interval to the initial value. If the changed real-time capacity remains the same for multiple times, it means that the capacity expansion operation is completed and the capacity expansion is successful. At this time, the last real-time capacity can be determined as the current capacity after the data disk capacity expansion.

[0048] As an optional example, as Figure 4 shown, when the current capacity is greater than the historical capacity before the capacity expansion operation of the target data disk, adjusting the system capacity of the file system of the virtual machine according to the value of the current capacity includes:

[0049] S402. Adjust the system capacity to the first capacity, where the first capacity is greater than the historical capacity and less than or equal to the current capacity.

[0050] In this embodiment, after the data disk is expanded, the capacity of the data disk changes from the historical capacity to the current capacity, and the capacity increases. At this time, the virtual machine can automatically expand the file system. For example, if the original capacity of the data disk is 10G and it becomes 20G after expansion, and the original file system is 10G, then when expanding the file system, the file system can be expanded to any value between 10G and 20G, but cannot exceed 20G. The capacity of the expanded file system is greater than 10G.

[0051] As an alternative example, as Figure 5 shown, before adjusting the system capacity to the first capacity, the method further includes:

[0052] S502, determining the required capacity of the file system;

[0053] S504, determining the sum of the system capacity and the required capacity of the file system as the first capacity.

[0054] The above-mentioned required capacity is the capacity that the file system needs to expand in addition to its current own capacity. Continuing with the above example, in this embodiment, when expanding the capacity of the file system from the original 10G to any value between 10G and 20G, specifically how much to expand can be determined according to the required capacity of the file system. For example, if the original capacity of the file system is 10G and the required capacity is 5G, then the expanded capacity is at least 15G. If the required capacity is 3G, then the system capacity of the expanded file system is at least 13G.

[0055] As an alternative example, determining the required capacity of the file system includes: estimating the change of the system capacity of the file system within a predetermined time period starting from the current moment; determining the difference between the maximum value in the change and the current value as the required capacity.

[0056] In this embodiment, the required capacity of the file system can be estimated. The estimation method can be to estimate the system capacity of the file system within a certain period of time in the future. For example, within one day in the future, the system capacity of the file system has a certain fluctuation. Subtracting the current value from the maximum value in the fluctuation, the obtained difference is determined as the required capacity.

[0057] As Figure 6 is the system schematic diagram of this embodiment. The user is the user side, and nova-api and nova-compute are the core components of the nova service. Nova is a component responsible for the computing part in the open-source cloud operating system. Cinder is a component responsible for the storage part in the open-source cloud operating system.

[0058] First, according to step A, the user initiates a request to expand the data disk. After receiving the request, nova-api checks the legality of the request through step B. If the request is legal, it initiates a Remote Procedure Call (RPC) to expand the data disk to nova-compute through step C. nova-compute initiates a compute.instance.extend_volume.start notification to start the expansion through step D, then changes the status of the expansion task to the extend_volume status, updates the expansion size bdm.volume_size, updates the claim resource, and initiates a request to expand to cinder through step E. After initiating the request, nova-compute checks whether the expansion is successful in a loop from step F to step H. If the expansion is not successful within 20 seconds, it determines that the expansion has failed and executes step L. cinder performs the action of expanding the data disk at the data bottom layer. nova-compute obtains the message of whether the expansion is successful from cinder to determine whether the data bottom layer has successfully expanded. If cinder returns a message indicating that the expansion is successful, nova-compute executes the command to expand through steps I to K and tries multiple times. This step is for nova-compute to expand the data disk of the virtual machine (actually, after the bottom layer expansion is completed, it synchronizes the expansion message to the data disk of the virtual machine to prevent the virtual machine from being unaware that the bottom layer data has been expanded and the data disk has not been expanded). If the expansion is successful, it sets the two parameters iops / bps of the virtual machine and sends a compute.instance.extend_volume.end message to indicate the end of the expansion. If the expansion fails three times, it sends a compute.instance.extend_volume.failed message indicating that the expansion has failed and releases the resources. If cinder fails to expand within the specified time, it also sends a compute.instance.extend_volume.failed message indicating that the expansion has failed and releases the resources.

[0059] The entire above process is to expand the data disk of the virtual machine by calling the application programming interface nova. First, expand the bottom layer of the data disk through the cinder service and record the expanded data disk in the database. Then, by calling the virtualization service of the virtual machine, synchronously expand the data disk of the virtual machine with the bottom layer so that the virtual machine can dynamically perceive that the bottom layer has been expanded. After the data disk of the virtual machine is expanded, the script deployed inside the virtual machine detects that the capacity of the data disk of the virtual machine has increased, and then synchronously adjusts the system capacity of the file system to achieve the expansion of the file system.

[0060] For example, if the data disk capacity of a virtual machine is 10G (which means the underlying capacity of the data disk is 10G) and the file system capacity is 10G, when expanding the data disk, nova will call cinder to expand the underlying capacity of the storage data disk. For example, after expansion, the underlying capacity of the data disk is 20G. At this time, it is necessary to ensure that the data disk of the virtual machine expands synchronously with the underlying layer. Through nova calling libvirt to simulate the expansion of the data disk of the virtual machine: #virsh blockresize <domain_id> / dev / vdb 20G (otherwise, from the perspective of the virtual machine, the capacity is still 10G and needs to be synchronized to 20G). After simulation, when checking the data disk capacity in the virtual machine, it has changed to 20G, and the file system capacity is still 10G. Finally, by pre-installing a script agent in the virtual machine to monitor the capacity of each data disk, if the data disk capacity changes, the file system is automatically expanded: #growpart / dev / vdb 1 - format the partition; #resize2fs / dev / vdb1 - expand the file system. At this time, the data disk capacity in the virtual machine is 20G, and the file system capacity is 20G. The full name of the expansion is that the business of the virtual machine is not interrupted.

[0061] Figure 7 This is a schematic structural diagram of a file system expansion device for a virtual machine provided by an embodiment of the present application. As Figure 7 shown, the above-mentioned file system expansion device for a virtual machine includes:

[0062] A monitoring module 702, configured to monitor the real-time capacity of a target data disk when receiving an operation request to perform an expansion operation on the target data disk;

[0063] An obtaining module 704, configured to obtain the current capacity of the target data disk after performing an expansion operation on the target data disk;

[0064] An adjustment module 706, configured to adjust the system capacity of the file system of the virtual machine according to the value of the current capacity when the current capacity is greater than the historical capacity before the expansion operation of the target data disk.

[0065] The disks of the virtual machine are divided into a system disk and a data disk. The system disk is used to install the operating system of the virtual machine, and the data disk is used to store the customer data of the virtual machine, that is, the file system. The system disk and the data disk can be cloud disks or local disks. Figure 2 This is a schematic diagram of the system disk and data disk of the virtual machine in this embodiment. The virtual machine system of the virtual machine is located in the system disk, and the file system is located in the data disk. The system disk and the data disk can be cloud disks or local disks or a combination of both.

[0066] The above-mentioned target data disk can be a disk of the storage file system of the virtual machine. Since the storage space occupied by the file system fluctuates as the virtual machine runs, if the system capacity of the file system is insufficient, it will affect the execution of the tasks of the virtual machine. Therefore, it is necessary to expand the capacity of the file system. If the capacity of the file system is to be expanded, the data disk where the file system is located needs to be expanded first. When expanding the system disk, an operation request can be used to request the expansion. The operation request can include the identifier of the system disk to be expanded, the size after expansion, the expansion time period, etc.

[0067] The real-time capacity of the above-mentioned target data disk can be the data obtained each time the data disk capacity of the target data disk is detected during the process of performing the expansion operation on the target data disk. For example, during the process of expanding the data disk, the data disk capacity is detected 10 times, and 10 real-time capacities of the data disk are obtained. After the data disk is expanded, the current capacity after expansion is obtained. The current capacity is the real-time capacity obtained after the data disk is expanded.

[0068] The operation of obtaining the real-time capacity is executed by the virtual machine. The virtual machine can insert a monitoring script, and the monitoring script obtains the real-time capacity of the data disk.

[0069] The above-mentioned historical capacity is the capacity of the data disk of the virtual machine before the expansion operation is performed. If the current capacity is greater than the historical capacity, it means that the data disk expansion is successful. If the expansion is successful, the virtual machine automatically completes the expansion of the file system according to the value of the current capacity.

[0070] In the solution provided by the embodiment of the present application, during the process of expanding the system capacity of the file system of the virtual machine, the real-time capacity of the data disk can be monitored by the virtual machine. If the real-time capacity of the data disk becomes larger, the system capacity of the file system is automatically expanded, achieving the purpose of automatically expanding the file system of the virtual machine.

[0071] For other examples of this embodiment, please refer to the above examples and will not be elaborated here.

[0072] As Figure 8 shown, the embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114. Among them, the processor 111, the communication interface 112, and the memory 113 complete communication with each other through the communication bus 114.

[0073] The memory 113 is used to store a computer program.

[0074] In an embodiment of the present application, when the processor 111 executes the program stored on the memory 113, it implements the method for expanding the file system of the virtual machine provided by any one of the foregoing method embodiments.

[0075] The embodiments of the present application also provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for expanding the file system of a virtual machine provided in any of the foregoing method embodiments are implemented.

[0076] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0077] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the essence of the above technical solution, or the part that contributes to the related technology, can be embodied in the form of a software product. The 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 for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0078] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" as used herein may also include the plural forms. The terms "include", "comprise", "contain", and "have" are inclusive and thus specify the presence of the stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or their combinations. The method steps, processes, and operations described herein are not to be construed as necessarily requiring them to be executed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps can be used.

[0079] The above are only specific embodiments of the present invention, enabling those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but will be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for expanding the file system of a virtual machine, characterized in that, it includes: When receiving an operation request to perform an expansion operation on a target data disk, monitor the real-time capacity of the target data disk; After performing the expansion operation on the target data disk, obtain the current capacity of the target data disk; When the current capacity is greater than the historical capacity before the expansion operation of the target data disk, adjust the system capacity of the file system of the virtual machine according to the value of the current capacity.

2. The method according to claim 1, characterized in that, The step of monitoring the real-time capacity of the target data disk when receiving an operation request to perform an expansion operation on the target data disk includes: Obtain the data disk identifier in the operation request; Determine the target data disk among the data disks of the virtual machine according to the data disk identifier; Start the monitoring script of the virtual machine, and the monitoring script obtains the data disk capacity of the target data disk every predetermined time period; Determine the obtained data disk capacity as the real-time capacity.

3. The method according to claim 2, characterized in that, During the process that the monitoring script obtains the data disk capacity of the target data disk every predetermined time period, the method further includes: When the sizes of the data disk capacities obtained continuously for multiple times are the same, increase the value of the predetermined time period; When the sizes of the data disk capacities obtained continuously twice are different, determine the latter data disk capacity among the data disk capacities obtained continuously twice, and restore the value of the predetermined time period to the initial value; When the sizes of multiple data disk capacities obtained by continuous monitoring are the same as the latter data disk capacity, stop monitoring the data disk capacity of the target data disk.

4. The method according to claim 3, characterized in that, The step of obtaining the current capacity of the target data disk after performing the expansion operation on the target data disk includes: Determine the latter data disk capacity as the current capacity.

5. The method according to claim 1, characterized in that, The step of adjusting the system capacity of the file system of the virtual machine according to the value of the current capacity when the current capacity is greater than the historical capacity before the expansion operation of the target data disk includes: Adjust the system capacity to a first capacity, where the first capacity is greater than the historical capacity and less than or equal to the current capacity.

6. The method according to claim 5, characterized in that, Before adjusting the system capacity to the first capacity, the method further includes: Determine the required capacity of the file system; Determine the sum of the system capacity of the file system and the required capacity as the first capacity.

7. The method according to claim 6, characterized in that, The step of determining the required capacity of the file system includes: Estimate the change of the system capacity of the file system within a predetermined time period starting from the current moment; Determine the difference between the maximum value and the current value in the change as the required capacity.

8. A device for expanding the file system of a virtual machine, characterized in that, it includes: A monitoring module, configured to monitor the real-time capacity of the target data disk when an operation request for performing a capacity expansion operation on the target data disk is received; An obtaining module, configured to obtain the current capacity of the target data disk after the capacity expansion operation is performed on the target data disk; An adjustment module, configured to adjust the system capacity of the file system of the virtual machine according to the value of the current capacity when the current capacity is greater than the historical capacity of the target data disk before the capacity expansion operation is performed on the target data disk.

9. An electronic device, characterized in that it includes: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; at least one memory connected to the at least one bus, wherein computer programs are stored in the memory, and when the processor executes the computer programs, the method described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, the storage medium stores computer-executable instructions, and the computer-executable instructions are used to execute the method described in any one of claims 1 to 7 of the present application.