[go: up one dir, main page]

CN106126115A - A kind of method and device of the disk of EVM(extended virtual machine) - Google Patents

A kind of method and device of the disk of EVM(extended virtual machine) Download PDF

Info

Publication number
CN106126115A
CN106126115A CN201610431234.0A CN201610431234A CN106126115A CN 106126115 A CN106126115 A CN 106126115A CN 201610431234 A CN201610431234 A CN 201610431234A CN 106126115 A CN106126115 A CN 106126115A
Authority
CN
China
Prior art keywords
disk
extended
expanded
extension
configuration information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610431234.0A
Other languages
Chinese (zh)
Inventor
潘峰
唐晓东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
IEIT Systems Co Ltd
Original Assignee
Inspur Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Electronic Information Industry Co Ltd filed Critical Inspur Electronic Information Industry Co Ltd
Priority to CN201610431234.0A priority Critical patent/CN106126115A/en
Publication of CN106126115A publication Critical patent/CN106126115A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • G06F3/0607Improving or facilitating administration, e.g. storage management by facilitating the process of upgrading existing storage systems, e.g. for improving compatibility between host and storage device
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明提供了一种扩展虚拟机的磁盘的方法及装置,该方法,包括:获取虚拟机中的待扩展磁盘的扩展配置信息;根据所述扩展配置信息,确定所述待扩展磁盘;根据所述扩展配置信息,确定扩展后的目标容量;将所述待扩展磁盘的容量扩展为所述目标容量,生成扩展后的磁盘;识别所述扩展后的磁盘。本发明提供了一种扩展虚拟机的磁盘的方法及装置,能够更加简单地实现虚拟机的磁盘的扩展。

The present invention provides a method and device for expanding a disk of a virtual machine. The method includes: obtaining the expansion configuration information of the disk to be expanded in the virtual machine; determining the disk to be expanded according to the expansion configuration information; The expansion configuration information is used to determine the expanded target capacity; the capacity of the disk to be expanded is expanded to the target capacity to generate an expanded disk; and the expanded disk is identified. The present invention provides a method and device for expanding the disk of a virtual machine, which can realize the expansion of the disk of the virtual machine more simply.

Description

一种扩展虚拟机的磁盘的方法及装置A method and device for extending a disk of a virtual machine

技术领域technical field

本发明涉及计算机技术领域,特别涉及一种扩展虚拟机的磁盘的方法及装置。The invention relates to the field of computer technology, in particular to a method and device for extending a disk of a virtual machine.

背景技术Background technique

随着日益增长的磁盘容量需求,虚拟化环境中的各种功能的虚拟机的磁盘已经不能满足更多的数据存储需求。如何对虚拟机的磁盘进行扩展成为急需解决的问题。With the increasing demand for disk capacity, the disks of virtual machines with various functions in the virtualization environment cannot meet more data storage requirements. How to expand the disk of the virtual machine has become an urgent problem to be solved.

现有技术中,在扩展虚拟机的磁盘时,一般是首先将待扩展的磁盘中的系统业务进行迁移,然后,对待扩展的磁盘进行物理扩展,扩展完成后,再将迁移出去的系统业务迁移到扩展后的磁盘中。In the prior art, when expanding the disk of a virtual machine, the system business in the disk to be expanded is generally first migrated, and then the disk to be expanded is physically expanded, and after the expansion is completed, the migrated system business is migrated to the expanded disk.

通过上述描述可见,现有技术中在进行磁盘扩展时,需要对磁盘中的系统业务进行迁移,过程比较复杂。It can be seen from the above description that in the prior art, when performing disk expansion, system services in the disk need to be migrated, and the process is relatively complicated.

发明内容Contents of the invention

本发明实施例提供了一种扩展虚拟机的磁盘的方法及装置,能够更加简单地实现虚拟机的磁盘的扩展。Embodiments of the present invention provide a method and device for extending a disk of a virtual machine, which can more simply realize the expansion of the disk of the virtual machine.

第一方面,本发明实施例提供了一种扩展虚拟机的磁盘的方法,包括:In a first aspect, an embodiment of the present invention provides a method for extending a disk of a virtual machine, including:

获取虚拟机中的待扩展磁盘的扩展配置信息;Obtain the extended configuration information of the disk to be extended in the virtual machine;

根据所述扩展配置信息,确定所述待扩展磁盘;Determine the disk to be expanded according to the expansion configuration information;

根据所述扩展配置信息,确定扩展后的目标容量;Determine the expanded target capacity according to the expanded configuration information;

将所述待扩展磁盘的容量扩展为所述目标容量,生成扩展后的磁盘;expanding the capacity of the disk to be expanded to the target capacity to generate an expanded disk;

识别所述扩展后的磁盘。Identify the expanded disk.

进一步地,所述扩展配置信息中包括:所述待扩展磁盘的标识;Further, the expansion configuration information includes: the identification of the disk to be expanded;

所述根据所述扩展配置信息,确定所述待扩展磁盘,包括:The determining the disk to be expanded according to the expansion configuration information includes:

根据所述扩展配置信息中的所述待扩展磁盘的标识,确定所述待扩展磁盘。Determine the disk to be expanded according to the identifier of the disk to be expanded in the expansion configuration information.

进一步地,所述将所述待扩展磁盘的容量扩展为所述目标容量,生成扩展后的磁盘,包括:Further, the expanding the capacity of the disk to be expanded to the target capacity to generate the expanded disk includes:

调用growpart,利用growpart将所述待扩展磁盘的容量扩展为所述目标容量,生成所述扩展后的磁盘。call growpart, use growpart to expand the capacity of the disk to be expanded to the target capacity, and generate the expanded disk.

进一步地,在执行所述识别所述扩展后的磁盘之前,还包括:Further, before performing the identifying the expanded disk, it also includes:

确定所述待扩展磁盘的文件系统类型;Determine the file system type of the disk to be expanded;

所述识别所述扩展后的磁盘,包括:The identifying the expanded disk includes:

当确定出所述待扩展磁盘的文件系统类型为ext2、ext3或ext4时,调用resize2fs,利用所述resize2fs识别所述扩展后的磁盘;When it is determined that the file system type of the disk to be expanded is ext2, ext3 or ext4, call resize2fs, and use the resize2fs to identify the expanded disk;

当确定出所述待扩展磁盘的文件系统类型为XFS时,调用xfs_grow,利用所述xfs_grow识别所述扩展后的磁盘。When it is determined that the file system type of the disk to be expanded is XFS, call xfs_grow, and use the xfs_grow to identify the expanded disk.

进一步地,所述将所述待扩展磁盘的容量扩展为所述目标容量,生成扩展后的磁盘,包括:Further, the expanding the capacity of the disk to be expanded to the target capacity to generate the expanded disk includes:

根据所述目标容量,修改所述待扩展磁盘对应的分区表中的起始扇区的地址和终止扇区的地址,生成所述扩展后的磁盘。According to the target capacity, the address of the start sector and the address of the end sector in the partition table corresponding to the disk to be expanded are modified to generate the expanded disk.

第二方面,本发明实施例提供了一种扩展虚拟机的磁盘的装置,包括:In a second aspect, an embodiment of the present invention provides an apparatus for extending a disk of a virtual machine, including:

获取单元,用于获取虚拟机中的待扩展磁盘的扩展配置信息;An acquisition unit, configured to acquire extended configuration information of the disk to be expanded in the virtual machine;

第一确定单元,用于根据所述扩展配置信息,确定所述待扩展磁盘;A first determination unit, configured to determine the disk to be expanded according to the expansion configuration information;

第二确定单元,用于根据所述扩展配置信息,确定扩展后的目标容量;The second determining unit is configured to determine the expanded target capacity according to the expanded configuration information;

生成单元,用于将所述待扩展磁盘的容量扩展为所述目标容量,生成扩展后的磁盘;a generating unit, configured to expand the capacity of the disk to be expanded to the target capacity, and generate an expanded disk;

识别单元,用于识别所述扩展后的磁盘。An identifying unit, configured to identify the expanded disk.

进一步地,所述扩展配置信息中包括:所述待扩展磁盘的标识;Further, the expansion configuration information includes: the identification of the disk to be expanded;

所述第一确定单元,用于根据所述扩展配置信息中的所述待扩展磁盘的标识,确定所述待扩展磁盘。The first determining unit is configured to determine the disk to be expanded according to the identifier of the disk to be expanded in the expansion configuration information.

进一步地,所述生成单元,用于调用growpart,利用growpart将所述待扩展磁盘的容量扩展为所述目标容量,生成所述扩展后的磁盘。Further, the generating unit is configured to call growpart, and use growpart to expand the capacity of the disk to be expanded to the target capacity, and generate the expanded disk.

进一步地,还包括:第三确定单元,用于确定所述待扩展磁盘的文件系统类型;Further, it also includes: a third determining unit, configured to determine the file system type of the disk to be expanded;

所述识别单元,用于当确定出所述待扩展磁盘的文件系统类型为ext2、ext3或ext4时,调用resize2fs,利用所述resize2fs识别所述扩展后的磁盘,当确定出所述待扩展磁盘的文件系统类型为XFS时,调用xfs_grow,利用所述xfs_grow识别所述扩展后的磁盘。The identifying unit is configured to call resize2fs when it is determined that the file system type of the disk to be expanded is ext2, ext3 or ext4, and use the resize2fs to identify the expanded disk, and when it is determined that the disk to be expanded When the file system type is XFS, call xfs_grow, and use the xfs_grow to identify the expanded disk.

进一步地,所述生成单元,用于根据所述目标容量,修改所述待扩展磁盘对应的分区表中的起始扇区的地址和终止扇区的地址,生成所述扩展后的磁盘。Further, the generating unit is configured to modify the address of the start sector and the address of the end sector in the partition table corresponding to the disk to be expanded according to the target capacity to generate the expanded disk.

在本发明实施例中,根据扩展配置信息,确定扩展后的目标容量,直接对虚拟机的待扩展磁盘进行扩展,无需对物理硬盘进行处理,将待扩展磁盘的容量扩展为目标容量,识别出扩展后的磁盘,能够直接使用扩展后的磁盘,待扩展磁盘中的系统业务能够直接运行,无需进行迁移,更加简单地实现虚拟机的磁盘的扩展。In the embodiment of the present invention, according to the expansion configuration information, the target capacity after expansion is determined, and the disk to be expanded of the virtual machine is directly expanded without processing the physical hard disk, and the capacity of the disk to be expanded is expanded to the target capacity. The expanded disk can directly use the expanded disk, and the system business on the disk to be expanded can run directly without migration, which makes it easier to expand the disk of the virtual machine.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are For some embodiments of the present invention, those skilled in the art can also obtain other drawings based on these drawings without creative work.

图1是本发明一实施例提供的一种扩展虚拟机的磁盘的方法的流程图;FIG. 1 is a flowchart of a method for extending a disk of a virtual machine according to an embodiment of the present invention;

图2是本发明一实施例提供的另一种扩展虚拟机的磁盘的方法的流程图;FIG. 2 is a flowchart of another method for extending a disk of a virtual machine provided by an embodiment of the present invention;

图3是本发明一实施例提供的一种扩展虚拟机的磁盘的装置的示意图;FIG. 3 is a schematic diagram of an apparatus for extending a disk of a virtual machine according to an embodiment of the present invention;

图4是本发明一实施例提供的另一种扩展虚拟机的磁盘的装置的示意图。FIG. 4 is a schematic diagram of another device for extending a disk of a virtual machine provided by an embodiment of the present invention.

具体实施方式detailed description

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例,基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments It is a part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts belong to the protection of the present invention. scope.

如图1所示,本发明实施例提供了一种扩展虚拟机的磁盘的方法,该方法可以包括以下步骤:As shown in FIG. 1, an embodiment of the present invention provides a method for extending a disk of a virtual machine, and the method may include the following steps:

步骤101:获取虚拟机中的待扩展磁盘的扩展配置信息;Step 101: Obtain the extended configuration information of the disk to be extended in the virtual machine;

步骤102:根据所述扩展配置信息,确定所述待扩展磁盘;Step 102: Determine the disk to be expanded according to the expansion configuration information;

步骤103:根据所述扩展配置信息,确定扩展后的目标容量;Step 103: Determine the expanded target capacity according to the expanded configuration information;

步骤104:将所述待扩展磁盘的容量扩展为所述目标容量,生成扩展后的磁盘;Step 104: expand the capacity of the disk to be expanded to the target capacity, and generate an expanded disk;

步骤105:识别所述扩展后的磁盘。Step 105: Identify the expanded disk.

在本发明实施例中,根据扩展配置信息,确定扩展后的目标容量,直接对虚拟机的待扩展磁盘进行扩展,无需对物理硬盘进行处理,将待扩展磁盘的容量扩展为目标容量,识别出扩展后的磁盘,能够直接使用扩展后的磁盘,待扩展磁盘中的系统业务能够直接运行,无需进行迁移,更加简单地实现虚拟机的磁盘的扩展。In the embodiment of the present invention, according to the expansion configuration information, the target capacity after expansion is determined, and the disk to be expanded of the virtual machine is directly expanded without processing the physical hard disk, and the capacity of the disk to be expanded is expanded to the target capacity. The expanded disk can directly use the expanded disk, and the system business on the disk to be expanded can run directly without migration, which makes it easier to expand the disk of the virtual machine.

在本发明一实施例中,所述扩展配置信息中包括:所述待扩展磁盘的标识;In an embodiment of the present invention, the expansion configuration information includes: the identifier of the disk to be expanded;

所述根据所述扩展配置信息,确定所述待扩展磁盘,包括:The determining the disk to be expanded according to the expansion configuration information includes:

根据所述扩展配置信息中的所述待扩展磁盘的标识,确定所述待扩展磁盘。Determine the disk to be expanded according to the identifier of the disk to be expanded in the expansion configuration information.

在本发明实施例中,用户可以通过配置待扩展磁盘的扩展配置信息来指定待扩展磁盘。举例来说,在扩展配置信息中设置待扩展磁盘的名称,根据该名称找到对应的待扩展磁盘。In the embodiment of the present invention, the user can specify the disk to be expanded by configuring the expansion configuration information of the disk to be expanded. For example, the name of the disk to be expanded is set in the expansion configuration information, and the corresponding disk to be expanded is found according to the name.

在本发明一实施例中,所述将所述待扩展磁盘的容量扩展为所述目标容量,生成扩展后的磁盘,包括:In an embodiment of the present invention, expanding the capacity of the disk to be expanded to the target capacity and generating the expanded disk includes:

调用growpart,利用growpart将所述待扩展磁盘的容量扩展为所述目标容量,生成所述扩展后的磁盘。call growpart, use growpart to expand the capacity of the disk to be expanded to the target capacity, and generate the expanded disk.

growpart为一种扩展磁盘分区的工具,在本发明实施例中,利用growpart对待扩展磁盘进行扩展。举例来说,目标容量为100G,待扩展磁盘的容量为50G。利用growpart,在待扩展磁盘的50G容量的基础上,再划分50G容量,将新划分的50G容量合并到待扩展磁盘中,得到扩展后的磁盘,扩展后的磁盘的容量为100G,达到目标容量。growpart is a tool for expanding a disk partition. In the embodiment of the present invention, growpart is used to expand the disk to be expanded. For example, the target capacity is 100G, and the capacity of the disk to be expanded is 50G. Use growpart to divide the 50G capacity of the disk to be expanded based on the 50G capacity of the disk to be expanded, and merge the newly divided 50G capacity into the disk to be expanded to obtain the expanded disk. The capacity of the expanded disk is 100G, reaching the target capacity .

在本发明一实施例中,所述将所述待扩展磁盘的容量扩展为所述目标容量,生成扩展后的磁盘,包括:In an embodiment of the present invention, expanding the capacity of the disk to be expanded to the target capacity and generating the expanded disk includes:

根据所述目标容量,修改所述待扩展磁盘对应的分区表中的起始扇区的地址和终止扇区的地址,生成所述扩展后的磁盘。According to the target capacity, the address of the start sector and the address of the end sector in the partition table corresponding to the disk to be expanded are modified to generate the expanded disk.

在本发明实施例中,可以通过修改扇区的地址来实现对待扩展磁盘的扩展。举例来说,目标容量为100G,待扩展磁盘的容量为50G,待扩展磁盘的起始扇区的地址为1,终止扇区的地址为50,为了扩展到100G,可以将终止扇区的地址修改为100,使得分区表中的起始扇区的地址为1,终止扇区的地址为100,使得扩展后的磁盘的容量为100G。In the embodiment of the present invention, the expansion of the disk to be expanded can be realized by modifying the address of the sector. For example, if the target capacity is 100G, the capacity of the disk to be expanded is 50G, the address of the start sector of the disk to be expanded is 1, and the address of the end sector is 50. In order to expand to 100G, the address of the end sector can be Change it to 100, so that the address of the start sector in the partition table is 1, and the address of the end sector is 100, so that the capacity of the expanded disk is 100G.

在得到扩展后的磁盘后,虚拟机的操作系统内部并没有同步生效,用户无法真正有效使用扩展的磁盘空间,为了使得扩展后的磁盘能够生效,在本发明一实施例中,在执行所述识别所述扩展后的磁盘之前,还包括:After obtaining the expanded disk, the operating system of the virtual machine does not take effect synchronously, and the user cannot really effectively use the expanded disk space. In order to make the expanded disk take effect, in an embodiment of the present invention, when executing the Before identifying the expanded disk, also include:

确定所述待扩展磁盘的文件系统类型;Determine the file system type of the disk to be expanded;

所述识别所述扩展后的磁盘,包括:The identifying the expanded disk includes:

当确定出所述待扩展磁盘的文件系统类型为ext2、ext3或ext4时,调用resize2fs,利用所述resize2fs识别所述扩展后的磁盘;When it is determined that the file system type of the disk to be expanded is ext2, ext3 or ext4, call resize2fs, and use the resize2fs to identify the expanded disk;

当确定出所述待扩展磁盘的文件系统类型为XFS时,调用xfs_grow,利用所述xfs_grow识别所述扩展后的磁盘。When it is determined that the file system type of the disk to be expanded is XFS, call xfs_grow, and use the xfs_grow to identify the expanded disk.

在本发明实施例中,通过对扩展后的磁盘进行识别,使得扩展后的磁盘能够在操作系统中生效,用户能够直接使用扩展后的磁盘。resize2fs和XFS均为扩展文件系统分区的工具,针对不同的文件系统类型需要选用不同的工具进行识别。当待扩展磁盘的文件系统类型为ext2、ext3和ext4中的任意一种时,选择resize2fs进行识别;当待扩展磁盘的文件系统类型为XFS时,选择xfs_grow进行识别。In the embodiment of the present invention, by identifying the expanded disk, the expanded disk can take effect in the operating system, and the user can directly use the expanded disk. Both resize2fs and XFS are tools for expanding file system partitions. Different tools need to be selected for different file system types to identify them. When the file system type of the disk to be expanded is any one of ext2, ext3, and ext4, select resize2fs for identification; when the file system type of the disk to be expanded is XFS, select xfs_grow for identification.

如图2所示,本发明实施例提供了一种扩展虚拟机的磁盘的方法,在本发明实施例中,虚拟机为vmware和openstack等环境中的虚拟机,待扩展磁盘为虚拟机中的磁盘A,该方法可以包括以下步骤:As shown in Figure 2, the embodiment of the present invention provides a method for expanding the disk of a virtual machine. In the embodiment of the present invention, the virtual machine is a virtual machine in environments such as vmware and openstack, and the disk to be expanded is a virtual machine in the virtual machine. disk A, the method may include the following steps:

步骤201:预先设置虚拟机中的磁盘A的扩展配置信息,扩展配置信息包括:磁盘A的名称、目标容量。Step 201: preset extended configuration information of disk A in the virtual machine, the extended configuration information includes: name of disk A and target capacity.

可以预先设置用户配置项,用户可以通过用户配置项来设置扩展配置信息,用户可以通过设置扩展配置信息来指定需要扩展的磁盘,以及需要达到的容量,另外,还可以通过用户配置项来配置磁盘的文件系统类型,磁盘的挂载路径。对应新的磁盘,用户可以根据需要将该磁盘格式化为用户配置项中指定的文件系统类型,也可以指定该磁盘的挂载点、分区方式等。User configuration items can be set in advance. Users can set extended configuration information through user configuration items. Users can specify the disk to be expanded and the capacity to be achieved by setting extended configuration information. In addition, the disk can also be configured through user configuration items. The type of the file system and the mounting path of the disk. Corresponding to a new disk, the user can format the disk as the file system type specified in the user configuration item as needed, and can also specify the mount point and partition mode of the disk.

举例来说,目标容量为100G。也就是说,用户需要将磁盘A扩展到100G。For example, the target capacity is 100G. That is to say, the user needs to expand disk A to 100G.

步骤202:根据扩展配置信息中磁盘A的名称,确定待扩展磁盘为磁盘A。Step 202: Determine that the disk to be expanded is disk A according to the name of disk A in the expansion configuration information.

磁盘A的名称为磁盘A的标识的一种,可以通过名称找到对应的磁盘。也可以通过磁盘A的地址、编号等标识找到对应的磁盘,以便后续对该磁盘进行操作。The name of disk A is a kind of identifier of disk A, and the corresponding disk can be found through the name. The corresponding disk can also be found through the address, serial number, and other identifiers of disk A, so that the disk can be operated on later.

步骤203:根据扩展配置信息中的目标容量,确定扩展后的磁盘的目标容量。Step 203: Determine the target capacity of the expanded disk according to the target capacity in the expansion configuration information.

举例来说,目标容量为100G,则扩展后的磁盘的容量为100G。For example, if the target capacity is 100G, then the capacity of the expanded disk is 100G.

步骤204:确定磁盘A的文件系统类型。Step 204: Determine the file system type of disk A.

文件系统类型包括:ext2、ext3、ext4、XFS等。File system types include: ext2, ext3, ext4, XFS, etc.

步骤205:调用growpart,利用growpart将磁盘A的容量扩展为目标容量,生成扩展后的磁盘。Step 205: call growpart, use growpart to expand the capacity of disk A to the target capacity, and generate the expanded disk.

具体地,可以利用growpart,根据所述目标容量,修改所述待扩展磁盘对应的分区表中的起始扇区的地址和终止扇区的地址,生成所述扩展后的磁盘。Specifically, growpart may be used to modify the address of the start sector and the address of the end sector in the partition table corresponding to the disk to be expanded according to the target capacity to generate the expanded disk.

举例来说,目标容量为100G,利用growpart,将磁盘A的容量扩展为100G。For example, if the target capacity is 100G, use growpart to expand the capacity of disk A to 100G.

步骤206:当确定出磁盘A的文件系统类型为ext2、ext3或ext4时,调用resize2fs,利用resize2fs识别扩展后的磁盘,当确定出磁盘A的文件系统类型为XFS时,调用xfs_grow,利用xfs_grow识别扩展后的磁盘。Step 206: When it is determined that the file system type of disk A is ext2, ext3 or ext4, call resize2fs, and use resize2fs to identify the expanded disk; when it is determined that the file system type of disk A is XFS, call xfs_grow, and use xfs_grow to identify Expanded disk.

由于对磁盘A进行扩展后,随意容量增加为目标容量,但是,增加的容量无法被操作系统识别,不能被操作系统有效使用。为了使得增加的容量能够被操作系统使用,需要对扩展后的磁盘进行识别。针对不同的文件系统类型采用不同的工具进行识别。举例来说,当磁盘A的文件系统类型为ext2、ext3或ext4时,采用resize2fs进行识别,当磁盘A的文件系统类型为XFS时,采用xfs_grow进行识别。After disk A is expanded, the random capacity is increased to the target capacity, but the increased capacity cannot be recognized by the operating system and cannot be effectively used by the operating system. In order to enable the increased capacity to be used by the operating system, it is necessary to identify the expanded disk. Different tools are used to identify different file system types. For example, when the file system type of disk A is ext2, ext3 or ext4, resize2fs is used for identification; when the file system type of disk A is XFS, xfs_grow is used for identification.

在本发明实施例中,可以实现对新建虚拟机的磁盘扩展处理以及对已存在的虚拟机的磁盘扩展的需求处理,可以在vmware和openstack等环境中实现。In the embodiment of the present invention, the processing of disk expansion of a new virtual machine and the demand processing of disk expansion of an existing virtual machine can be realized, which can be realized in environments such as vmware and openstack.

在本发明实施例中,当对从虚拟机模板或镜像创建出的虚拟机主磁盘大小不满足时,在本发明实施例中,能够扩展主磁盘大小,创建虚拟机后能自动扩展到主分区,可以直接使用扩展后的磁盘,保证虚拟机的正常运行。In the embodiment of the present invention, when the size of the primary disk of the virtual machine created from the virtual machine template or image is not satisfied, in the embodiment of the present invention, the size of the primary disk can be expanded, and the virtual machine can be automatically extended to the primary partition after the virtual machine is created , you can directly use the expanded disk to ensure the normal operation of the virtual machine.

当对已存在的虚拟机磁盘需求不满足,需要挂载新的磁盘时,在本发明实施例中,能够挂载磁盘后自动进行磁盘分区,并挂载到指定目录。When the existing virtual machine disk requirements are not met and a new disk needs to be mounted, in the embodiment of the present invention, after the disk is mounted, the disk partition can be automatically performed and mounted to a specified directory.

当对已经挂载到虚拟机的磁盘大小不满足时,在本发明实施例中,能够扩展已经挂载的磁盘的大小,自动修改磁盘的分区信息,并保证原有文件不出问题,新扩展的磁盘可以使用。When the size of the disk that has been mounted to the virtual machine is not satisfied, in the embodiment of the present invention, the size of the disk that has been mounted can be expanded, the partition information of the disk can be automatically modified, and the original file is guaranteed to be free of problems. disk can be used.

在本发明实施例中,避免了扩展磁盘导致的系统业务迁移或者调整,可以保证在系统业务无需变动的情况下完成磁盘自动扩展,支持将磁盘挂载到不同的路径,能够指的磁盘的不同的分区大小和文件系统类型。In the embodiment of the present invention, the migration or adjustment of system services caused by disk expansion is avoided, and the automatic disk expansion can be completed without changing the system services. partition size and file system type.

在本发明实施例中,能够根据场景需求自动化扩展磁盘,使得用户更方便快捷地实现对虚拟机的磁盘的扩展,不仅能够对主磁盘进行扩展,还能对主磁盘外的各种磁盘进行扩展。In the embodiment of the present invention, the disk can be automatically expanded according to the scene requirements, so that the user can expand the disk of the virtual machine more conveniently and quickly, not only the main disk can be expanded, but also various disks other than the main disk can be expanded. .

如图3、图4所示,本发明实施例提供了一种扩展虚拟机的磁盘的装置。装置实施例可以通过软件实现,也可以通过硬件或者软硬件结合的方式实现。从硬件层面而言,如图3所示,为本发明实施例提供的一种扩展虚拟机的磁盘的装置所在设备的一种硬件结构图,除了图3所示的处理器、内存、网络接口、以及非易失性存储器之外,实施例中装置所在的设备通常还可以包括其他硬件,如负责处理报文的转发芯片等等。以软件实现为例,如图4所示,作为一个逻辑意义上的装置,是通过其所在设备的CPU将非易失性存储器中对应的计算机程序指令读取到内存中运行形成的。本实施例提供的一种扩展虚拟机的磁盘的装置,包括:As shown in FIG. 3 and FIG. 4 , an embodiment of the present invention provides an apparatus for extending a disk of a virtual machine. The device embodiments can be implemented by software, or by hardware or a combination of software and hardware. From the hardware level, as shown in Figure 3, it is a hardware structure diagram of the device where the device for expanding the disk of the virtual machine provided by the embodiment of the present invention, except for the processor, memory, and network interface shown in Figure 3 , and non-volatile memory, the device where the device in the embodiment is located may generally include other hardware, such as a forwarding chip responsible for processing packets, and the like. Taking software implementation as an example, as shown in Figure 4, as a device in a logical sense, it is formed by reading the corresponding computer program instructions in the non-volatile memory into the memory for operation by the CPU of the device where it is located. An apparatus for extending a disk of a virtual machine provided in this embodiment includes:

获取单元401,用于获取虚拟机中的待扩展磁盘的扩展配置信息;An obtaining unit 401, configured to obtain extended configuration information of a disk to be extended in the virtual machine;

第一确定单元402,用于根据所述扩展配置信息,确定所述待扩展磁盘;The first determining unit 402 is configured to determine the disk to be expanded according to the expansion configuration information;

第二确定单元403,用于根据所述扩展配置信息,确定扩展后的目标容量;The second determining unit 403 is configured to determine the expanded target capacity according to the expanded configuration information;

生成单元404,用于将所述待扩展磁盘的容量扩展为所述目标容量,生成扩展后的磁盘;A generating unit 404, configured to expand the capacity of the disk to be expanded to the target capacity, and generate an expanded disk;

识别单元405,用于识别所述扩展后的磁盘。The identifying unit 405 is configured to identify the expanded disk.

在本发明一实施例中,所述扩展配置信息中包括:所述待扩展磁盘的标识;In an embodiment of the present invention, the expansion configuration information includes: the identifier of the disk to be expanded;

所述第一确定单元,用于根据所述扩展配置信息中的所述待扩展磁盘的标识,确定所述待扩展磁盘。The first determining unit is configured to determine the disk to be expanded according to the identifier of the disk to be expanded in the expansion configuration information.

在本发明一实施例中,所述生成单元,用于调用growpart,利用growpart将所述待扩展磁盘的容量扩展为所述目标容量,生成所述扩展后的磁盘。In an embodiment of the present invention, the generating unit is configured to call growpart, and use growpart to expand the capacity of the disk to be expanded to the target capacity, and generate the expanded disk.

在本发明一实施例中,还包括:第三确定单元,用于确定所述待扩展磁盘的文件系统类型;In an embodiment of the present invention, it further includes: a third determining unit, configured to determine the file system type of the disk to be expanded;

所述识别单元,用于当确定出所述待扩展磁盘的文件系统类型为ext2、ext3或ext4时,调用resize2fs,利用所述resize2fs识别所述扩展后的磁盘,当确定出所述待扩展磁盘的文件系统类型为XFS时,调用xfs_grow,利用所述xfs_grow识别所述扩展后的磁盘。The identifying unit is configured to call resize2fs when it is determined that the file system type of the disk to be expanded is ext2, ext3 or ext4, and use the resize2fs to identify the expanded disk, and when it is determined that the disk to be expanded When the file system type is XFS, call xfs_grow, and use the xfs_grow to identify the expanded disk.

在本发明一实施例中,所述生成单元,用于根据所述目标容量,修改所述待扩展磁盘对应的分区表中的起始扇区的地址和终止扇区的地址,生成所述扩展后的磁盘。In an embodiment of the present invention, the generating unit is configured to modify the address of the start sector and the address of the end sector in the partition table corresponding to the disk to be expanded according to the target capacity, and generate the extended after the disk.

上述装置内的各单元之间的信息交互、执行过程等内容,由于与本发明方法实施例基于同一构思,具体内容可参见本发明方法实施例中的叙述,此处不再赘述。The information exchange and execution process among the units in the above-mentioned device are based on the same concept as the method embodiment of the present invention, and the specific content can refer to the description in the method embodiment of the present invention, and will not be repeated here.

本发明各个实施例至少具有如下有益效果:Various embodiments of the present invention have at least the following beneficial effects:

1、在本发明实施例中,根据扩展配置信息,确定扩展后的目标容量,直接对虚拟机的待扩展磁盘进行扩展,无需对物理硬盘进行处理,将待扩展磁盘的容量扩展为目标容量,识别出扩展后的磁盘,能够直接使用扩展后的磁盘,待扩展磁盘中的系统业务能够直接运行,无需进行迁移,更加简单地实现虚拟机的磁盘的扩展。1. In the embodiment of the present invention, according to the expansion configuration information, the target capacity after expansion is determined, and the disk to be expanded of the virtual machine is directly expanded without processing the physical hard disk, and the capacity of the disk to be expanded is expanded to the target capacity, After the expanded disk is identified, the expanded disk can be used directly, and the system business on the disk to be expanded can be run directly without migration, and the disk expansion of the virtual machine can be realized more simply.

2、在本发明实施例中,能够需求对虚拟机的磁盘进行自动化扩展,使得用户更方便快捷地实现对虚拟机的磁盘的扩展,能够在系统业务无需变动的情况下完成磁盘自动扩展,能够直接使用扩展后的磁盘,保证虚拟机的正常运行。2. In the embodiment of the present invention, it may be required to automatically expand the disk of the virtual machine, so that the user can more conveniently and quickly realize the expansion of the disk of the virtual machine, and the automatic expansion of the disk can be completed without changing the system business. Use the expanded disk directly to ensure the normal operation of the virtual machine.

需要说明的是,在本文中,诸如第一和第二之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个〃·····”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同因素。It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is a relationship between these entities or operations. There is no such actual relationship or sequence. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements of or also include elements inherent in such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.

本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储在计算机可读取的存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质中。Those of ordinary skill in the art can understand that all or part of the steps for realizing the above-mentioned method embodiments can be completed by hardware related to program instructions, and the aforementioned programs can be stored in a computer-readable storage medium. When the program is executed, the It includes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.

最后需要说明的是:以上所述仅为本发明的较佳实施例,仅用于说明本发明的技术方案,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所做的任何修改、等同替换、改进等,均包含在本发明的保护范围内。Finally, it should be noted that: the above descriptions are only preferred embodiments of the present invention, and are only used to illustrate the technical solutions of the present invention, and are not used to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present invention are included in the protection scope of the present invention.

Claims (10)

1. the method for the disk of an EVM(extended virtual machine), it is characterised in that including:
The expanded configuration information of the disk to be extended in acquisition virtual machine;
According to described expanded configuration information, determine described in disk to be extended;
According to described expanded configuration information, determine the target capacity after extension;
It is described target capacity by the capacity extension of described disk to be extended, generates the disk after extension;
Identify the disk after described extension.
Method the most according to claim 1, it is characterised in that
Described expanded configuration information includes: described in the mark of disk to be extended;
Described according to described expanded configuration information, determine described in disk to be extended, including:
According to the mark of disk to be extended described in described expanded configuration information, determine described in disk to be extended.
Method the most according to claim 1, it is characterised in that the described capacity extension by described disk to be extended is described Target capacity, generates the disk after extension, including:
Calling growpart, utilizing growpart is described target capacity by the capacity extension of described disk to be extended, and generates institute State the disk after extension.
Method the most according to claim 1, it is characterised in that
Before disk after performing the described extension of described identification, also include:
The file system type of disk to be extended described in determining;
Disk after the described extension of described identification, including:
When described in determining wait extend disk file system type be ext2, ext3 or ext4 time, call resize2fs, profit The disk after described extension is identified with described resize2fs;
When described in determining wait extend disk file system type be XFS time, call xfs_grow, utilize described xfs_grow Identify the disk after described extension.
5. according to described method arbitrary in claim 1-4, it is characterised in that
The described capacity extension by described disk to be extended is described target capacity, generates the disk after extension, including:
According to described target capacity, the address of the initial sector in the partition table that disk to be extended described in amendment is corresponding and terminate fan The address in district, generates the disk after described extension.
6. the device of the disk of an EVM(extended virtual machine), it is characterised in that including:
Acquiring unit, for obtaining the expanded configuration information of the disk to be extended in virtual machine;
First determines unit, for according to described expanded configuration information, determine described in disk to be extended;
Second determines unit, for according to described expanded configuration information, determines the target capacity after extension;
Signal generating unit, for being described target capacity by the capacity extension of described disk to be extended, generates the disk after extension;
Recognition unit, the disk after identifying described extension.
Device the most according to claim 6, it is characterised in that
Described expanded configuration information includes: described in the mark of disk to be extended;
Described first determines unit, for the mark according to disk to be extended described in described expanded configuration information, determines institute State disk to be extended.
Device the most according to claim 6, it is characterised in that described signal generating unit, is used for calling growpart, utilizes The capacity extension of described disk to be extended is described target capacity by growpart, generates the disk after described extension.
Device the most according to claim 6, it is characterised in that
Also include: the 3rd determines unit, be used for the file system type of disk to be extended described in determining;
Described recognition unit, for when described in determining wait extend disk file system type be ext2, ext3 or ext4 time, Call resize2fs, utilize described resize2fs to identify the disk after described extension, disk to be extended described in determine When file system type is XFS, call xfs_grow, the disk after utilizing described xfs_grow to identify described extension.
10. according to described device arbitrary in claim 6-9, it is characterised in that
Described signal generating unit, for according to described target capacity, initiateing in the partition table that disk extend described in amendment is corresponding The address of sector and the address of termination sector, generate the disk after described extension.
CN201610431234.0A 2016-06-15 2016-06-15 A kind of method and device of the disk of EVM(extended virtual machine) Pending CN106126115A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610431234.0A CN106126115A (en) 2016-06-15 2016-06-15 A kind of method and device of the disk of EVM(extended virtual machine)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610431234.0A CN106126115A (en) 2016-06-15 2016-06-15 A kind of method and device of the disk of EVM(extended virtual machine)

Publications (1)

Publication Number Publication Date
CN106126115A true CN106126115A (en) 2016-11-16

Family

ID=57469731

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610431234.0A Pending CN106126115A (en) 2016-06-15 2016-06-15 A kind of method and device of the disk of EVM(extended virtual machine)

Country Status (1)

Country Link
CN (1) CN106126115A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106815024A (en) * 2017-01-12 2017-06-09 惠州Tcl移动通信有限公司 A kind of method and system for optimizing starting time of mobile terminal
CN107861790A (en) * 2017-10-27 2018-03-30 新华三云计算技术有限公司 Magnetic disk of virtual machine Extend Methods of Spatial Distribution, device, host and readable storage medium storing program for executing
CN108388468A (en) * 2018-01-26 2018-08-10 杨立群 A kind of Flase File System dispatching method and device
CN109614053A (en) * 2018-12-17 2019-04-12 郑州云海信息技术有限公司 A method and device for extending KVM virtual machine disk partition
CN111708612A (en) * 2020-08-18 2020-09-25 南京赛宁信息技术有限公司 Network shooting range cloud platform data disk management system and method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103440111A (en) * 2013-08-05 2013-12-11 北京京东尚科信息技术有限公司 Method for expanding disk space of virtual machines, host machines and platform
CN103513940A (en) * 2013-10-21 2014-01-15 北京华胜天成科技股份有限公司 Method for on-line extension of disk size of virtual machine and virtual system console
CN103927122A (en) * 2013-01-11 2014-07-16 中兴通讯股份有限公司 Method and device for extending redundant array of independent disks
CN104572242A (en) * 2013-10-24 2015-04-29 华为技术有限公司 Method and device for expanding disk space of virtual machine and virtual machine system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103927122A (en) * 2013-01-11 2014-07-16 中兴通讯股份有限公司 Method and device for extending redundant array of independent disks
CN103440111A (en) * 2013-08-05 2013-12-11 北京京东尚科信息技术有限公司 Method for expanding disk space of virtual machines, host machines and platform
CN103513940A (en) * 2013-10-21 2014-01-15 北京华胜天成科技股份有限公司 Method for on-line extension of disk size of virtual machine and virtual system console
CN104572242A (en) * 2013-10-24 2015-04-29 华为技术有限公司 Method and device for expanding disk space of virtual machine and virtual machine system

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106815024A (en) * 2017-01-12 2017-06-09 惠州Tcl移动通信有限公司 A kind of method and system for optimizing starting time of mobile terminal
CN106815024B (en) * 2017-01-12 2021-03-23 惠州Tcl移动通信有限公司 Method and system for optimizing starting time of mobile terminal
CN107861790A (en) * 2017-10-27 2018-03-30 新华三云计算技术有限公司 Magnetic disk of virtual machine Extend Methods of Spatial Distribution, device, host and readable storage medium storing program for executing
CN108388468A (en) * 2018-01-26 2018-08-10 杨立群 A kind of Flase File System dispatching method and device
CN108388468B (en) * 2018-01-26 2022-02-22 杨立群 Fast file system scheduling method and device
CN109614053A (en) * 2018-12-17 2019-04-12 郑州云海信息技术有限公司 A method and device for extending KVM virtual machine disk partition
CN111708612A (en) * 2020-08-18 2020-09-25 南京赛宁信息技术有限公司 Network shooting range cloud platform data disk management system and method
CN111708612B (en) * 2020-08-18 2020-12-01 南京赛宁信息技术有限公司 Network shooting range cloud platform data disk management system and method

Similar Documents

Publication Publication Date Title
CN107729083B (en) Method for loading driver and embedded device
WO2021082157A1 (en) Methods, systems and devices for data sharing, and data and metadata storage
CN109634718B (en) Method and system for creating mirror image by cloud platform
US20230409182A1 (en) Rule-based user interface layout rearrangement
CN103544077B (en) Data processing method and device, shared storage device
CN106126115A (en) A kind of method and device of the disk of EVM(extended virtual machine)
US11036535B2 (en) Data storage method and apparatus
CN108073423B (en) An accelerator loading method, system and accelerator loading device
CN103970908A (en) Virtual machine template IVF storage method
CN110908609B (en) Method, system and equipment for processing disk and readable storage medium
CN106873970B (en) Installation method and device of operating system
CN106201648A (en) A kind of virtual machine creation method and device
CN105718272B (en) Method and terminal for restoring factory settings of a terminal
CN112052000A (en) Component multiplexing and rendering method and device
CN109995814A (en) Moving method and device, communication equipment, the storage medium of cloud host resource
WO2021226822A1 (en) Log write method and apparatus, electronic device, and storage medium
CN107329792A (en) A kind of Docker containers start method and device
CN109426513A (en) A kind of processing method and equipment of view component
CN114640678A (en) Pod management method, device and medium based on SR-IOV
WO2014190700A1 (en) Method of memory access, buffer scheduler and memory module
CN111414168A (en) Web application development method and device and electronic device based on mind map
CN117271440A (en) File information storage method, reading method and related equipment based on freeRTOS
CN107148612A (en) A method and device for expanding user partitions
CN110290172B (en) Container application cloning method and device, computer equipment and storage medium
CN112235132A (en) Method, device, medium and server for dynamically configuring service

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20161116