CN109739437A - A method of based on cloud platform Linux virtual machine dilatation root partition - Google Patents

A method of based on cloud platform Linux virtual machine dilatation root partition Download PDF

Info

Publication number
CN109739437A
CN109739437A CN201811555009.3A CN201811555009A CN109739437A CN 109739437 A CN109739437 A CN 109739437A CN 201811555009 A CN201811555009 A CN 201811555009A CN 109739437 A CN109739437 A CN 109739437A
Authority
CN
China
Prior art keywords
partition
sector
subregion
root
root partition
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.)
Granted
Application number
CN201811555009.3A
Other languages
Chinese (zh)
Other versions
CN109739437B (en
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.)
G Cloud Technology Co Ltd
Original Assignee
G Cloud Technology 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 G Cloud Technology Co Ltd filed Critical G Cloud Technology Co Ltd
Priority to CN201811555009.3A priority Critical patent/CN109739437B/en
Publication of CN109739437A publication Critical patent/CN109739437A/en
Application granted granted Critical
Publication of CN109739437B publication Critical patent/CN109739437B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

The present invention relates to field of cloud computer technology, especially a kind of method based on cloud platform Linux virtual machine dilatation root partition.Method of the present invention includes the following steps: 1, virtual machine system disk dilatation;2, the partition table of guiding system disk;3, the root partition of partition table and the beginning sector of each subregion are changed and always fans number;4, modified system disk partition table is imported;5, restart virtual machine;6, expand root partition file system.The present invention does not need then to rebuild subregion progress root partition dilatation by each subregion of deletion system disk;If partition table modification is incorrect, the risk of loss of data will not be led to because of subregion is accidentally deleted.

Description

A method of based on cloud platform Linux virtual machine dilatation root partition
Technical field
It is especially a kind of based on cloud platform Linux virtual machine dilatation root partition the present invention relates to field of cloud computer technology Method.
Background technique
With the continuous development of client traffic, it is not enough that virtual machine system disk is frequently resulted in using the rapid growth of data, It is frequently necessary to carry out dilatation to the system disk of virtual machine.However after the system disk of Linux virtual machine increases space, can't be System root partition uses.It is empty using newly-increased disk if root partition is LVM subregion when the root partition deficiency of system Between increase newly a subregion, remerge lvm volumes where root partition.If root partition is not LVM subregion, newly-increased magnetic is utilized Disk space increases a subregion newly and formats, then the data copy of former catalogue is come out, and copies to newly-increased subregion, then newly-increased Subregion be mounted to former catalogue.
In the case where the root partition of virtual machine is not LVM subregion, if the data occupied space of multiple catalogues is got over simultaneously Come it is bigger, need to each catalogue carry out data copy, the new subregion of independent carry, then original file copy to originally Catalogue.If virtual machine does not distribute extension subregion when filling system, default most 4 main partitions, can not realize increase newly it is multiple Subregion.
When the root partition of virtual machine is not LVM subregion, it is more time-consuming that the prior art needs to copy data, inflexible, It is complicated for operation, and copy risk of the data there are loss of data.
When some schemes are for non-LVM subregion dilatation, each subregion is directly deleted, does not save partition table number subsequently temporarily According to, then program and district again, finally save subregion.When the partition table finally saved is incorrect, there is the risk for losing data.
Summary of the invention
Present invention solves the technical problem that being to provide a kind of side based on cloud platform Linux virtual machine dilatation root partition Method does not need then to rebuild subregion progress root partition dilatation by each subregion of deletion system disk;If partition table is modified not Correctly, the risk of loss of data will not be led to because of subregion is accidentally deleted.
The technical solution that the present invention solves above-mentioned technical problem is:
The method includes the following steps:
Step 1: virtual machine system disk dilatation;
Step 2: the partition table of guiding system disk;
Step 3: changing the root partition of partition table and the beginning sector of each subregion and always fan number;
Step 4: importing modified system disk partition table;
Step 5: restarting virtual machine;
Step 6: expanding root partition file system.
The partition table of the step 2 refers to that number is fanned with total in the beginning sector for being stored in hard disk for defining data, is that master draws A part in sector is led, in total 64 bytes;
The master boot sector, i.e. MBR are 0 cylinder, 0 magnetic head, first 1 sectors of hard disk, in total 512 bytes;It is Code to be run after bios Power-On Self-Test, master boot sector include three parts:
(1) Bootloader, main bootstrap program --- 446 bytes;
(2) Dpt, hard disk partition table --- 64 bytes;
(3) sector ending mark -- 2 bytes;
It is exported using order dd if=/dev/sda of=dpt.bak bs=1skip=446count=64.
In the step 3,
When root partition is the last one subregion, total fan number of root partition in regeneration block table is only needed;Wherein, root partition Total fan number that total fan number is equal to system disk subtracts the beginning sector of root partition;
When root partition is not the last one subregion, and when without extension subregion, following specific steps are executed:
A, in regeneration block table root partition total fan number, at this point, root partition after total fan number=dilatation of root partition Blocks is multiplied by 1024 product again divided by 512;
B, the new end sector of root partition after dilatation is calculated, the blocks- for newly terminating root partition after sector=dilatation starts Sector+1;
C, the beginning sector of the subsequent subregion of root partition is changed to the end sector+1 of a upper subregion, end sector=be somebody's turn to do Subregion starts the total fan number -1 of the sector+subregion;
When root partition is not the last one subregion, and has extension subregion, following specific steps are executed:
A, in regeneration block table root partition total fan number, at this point, root partition after total fan number=dilatation of root partition Blocks is multiplied by 1024 product again divided by 512;
B, the new end sector of root partition after dilatation is calculated, the blocks- for newly terminating root partition after sector=dilatation starts Sector+1;
C, the beginning sector in main partition behind root partition is changed to the end sector+1 of a upper subregion, end sector=be somebody's turn to do Subregion starts the total fan number -1 of the sector+subregion;
D, the beginning sector for extending subregion is changed to the end sector+1 of a subregion, terminates the sector=extension subregion and opens Total fan number -1 of the beginning sector+extension subregion;
E, the beginning sector of first logical partition is changed to the beginning sector+2048 of extension subregion, end sector=be somebody's turn to do Logical partition starts the total fan number -1 of the sector+logical partition;
F, the beginning sector of remaining logical partition is changed to the beginning sector+2048 an of logical partition, terminates fan Area=the logical partition starts the total fan number -1 of the sector+logical partition.
The sector refers to several segmental arcs that each magnetic track on disk is divided, these segmental arcs are disks Sector;Using sector as basic unit, each sector is 512 bytes for the read-write of hard disk;
The blocks is the size of subregion, and in blocks, each piece of default size is 1024 bytes, i.e. 1KB;
The fdisk is respectively main partition, extension subregion, logical partition;
The main partition, at least 1, each hard disk is up to 4, can be without extension subregion;
The logical partition needs to create extension subregion from main partition, then establishes logical partition in extension subregion;
The extension subregion capacity is equal to the sum of the capacity of logical partition in extension partition creating.
In the step 6,
If it is xfs file system, then order xfs_growfs is executed, root partition file system is made to be expanded to entire root point The maximum available space in area;
If it is ext2, ext3 or ext4 file system, then order resize2fs is executed, makes root partition file system It is expanded to the maximum available space of entire root partition;
The xfs_growfs is that xfs file system redefines big small tool;
The resize2fs is that ext2/ext3/ext4 file system redefines big small tool.
Method of the invention does not need then to rebuild subregion progress root partition expansion by each subregion of deletion system disk Hold;It only needs the partition table of guiding system disk to modify, then imports modified partition table.If partition table modification is incorrect, Again export modification again, does not influence the data of each subregion, will not lead to the risk of loss of data because of subregion is accidentally deleted.
Detailed description of the invention
The following further describes the present invention with reference to the drawings:
Fig. 1 is flow chart of the present invention.
Specific embodiment
As shown in Figure 1, Linux secure virtual machine dilatation root partition method of the invention includes:
Step 1: virtual machine system disk dilatation;
Step 2: the partition table of guiding system disk;
Because partition table is a part of master boot sector, 64 bytes are only accounted for, so using order dd if=/dev/ Sda of=dpt.bak bs=1skip=446count=64 export.
The partition table refers to that number is fanned with total in the beginning sector for being stored in hard disk for defining data, is main boot fan A part in area, in total 64 bytes.
The master boot sector, i.e. MBR (main boot record) are 0 cylinder, 0 magnetic head first 1 fans of hard disk Area, 512 bytes, are code to be run after bios Power-On Self-Test in total, and master boot sector includes 3 parts:
(1) Bootloader, main bootstrap program --- 446 bytes;
(2) Dpt (Disk Partition table), hard disk partition table --- 64 bytes;
(3) sector ending mark (55aa) -- 2 bytes;
Step 3: changing the root partition of partition table and the beginning sector of each subregion and always fan number;
Derived partition table is a binary file, is edited using binary tools.
The structure of hard disk partition table is as follows:
Shown in change partition table refer to the beginning logic sector and total sector number for changing each subregion;
(1) when root partition is the last one subregion, total fan number of root partition in regeneration block table is only needed, wherein root point Total fan number that total fan number in area is equal to system disk subtracts the beginning sector of root partition;
(2) when root partition is not the last one subregion, and when without extension subregion,
Its step specifically:
A, in regeneration block table root partition total fan number, total fan number of root partition is equal to root partition after dilatation at this time Blocks, multiplied by 1024, finally except in 512;
B, the new end sector of root partition after dilatation is calculated, the blocks- for newly terminating root partition after sector=dilatation starts Sector+1;
C, the beginning sector of the subsequent subregion of root partition is changed to the end sector+1 of a upper subregion, and terminates sector etc. Start the total fan number -1 of the sector+subregion in the subregion;
(3) when root partition is not the last one subregion, and there is extension subregion;
A, in regeneration block table root partition total fan number, total fan number of root partition is equal to root partition after dilatation at this time Blocks, multiplied by 1024, finally except in 512;
B, the new end sector of root partition after dilatation is calculated, the blocks- for newly terminating root partition after sector=dilatation starts Sector+1;
C, the beginning sector in main partition behind root partition is changed to the end sector+1 of a upper subregion, and terminates sector etc. Start the total fan number -1 of the sector+subregion in the subregion;
D, the beginning sector for extending subregion is changed to the end sector+1 of a subregion, and terminates sector equal to the extension point Area starts the total fan number -1 of the sector+extension subregion;
E, the beginning sector of first logical partition is changed to extend the beginning sector+2048 of subregion, and terminate sector etc. Start the total fan number -1 of the sector+logical partition in the logical partition;
F, the beginning sector of remaining logical partition is changed to the beginning sector+2048 an of logical partition, and terminates Sector is equal to the logical partition and starts the total fan number -1 of the sector+logical partition;
The sector refers to that each magnetic track on disk is divided into several segmental arcs, these segmental arcs are disks Sector, using sector as basic unit, each sector is 512 bytes for the read-write of hard disk.
The blocks is the size of subregion, and in blocks, each piece of default size is 1024 bytes, i.e. 1KB, If after root partition dilatation being 60G, blocks=60x1024x1024 byte.
There are three types of the fdisks, respectively main partition, extension subregion, logical partition.
The main partition, at least 1, each hard disk is up to 4, can be without extension subregion;
The logical partition needs to create extension subregion from main partition, then establishes logical partition in extension subregion;
The extension subregion capacity is equal to the sum of the capacity of logical partition in extension partition creating.
Step 4: importing modified system disk partition table;
It specifically refers to
Dd if=dpt.bak of=/dev/sda seek=446bs=1count=64
Step 5: restarting virtual machine;
Step 6: expanding root partition file system;
If it is xfs file system, then order xfs_growfs is executed, root partition file system is made to be expanded to entire root point The maximum available space in area.
If it is ext2, ext3 or ext4 file system, then order resize2fs is executed, makes root partition file system It is expanded to the maximum available space of entire root partition.
The resize2fs is that ext2/ext3/ext4 file system redefines big small tool.
The xfs_growfs is that xfs file system redefines big small tool.

Claims (5)

1. a kind of method based on cloud platform Linux virtual machine dilatation root partition, it is characterised in that: the method includes as follows Step:
Step 1: virtual machine system disk dilatation;
Step 2: the partition table of guiding system disk;
Step 3: changing the root partition of partition table and the beginning sector of each subregion and always fan number;
Step 4: importing modified system disk partition table;
Step 5: restarting virtual machine;
Step 6: expanding root partition file system.
2. according to the method described in claim 1, it is characterized by:
The partition table of the step 2 refers to that number is fanned with total in the beginning sector for being stored in hard disk for defining data, is main boot fan A part in area, in total 64 bytes;
The master boot sector, i.e. MBR are 0 cylinder, 0 magnetic head, first 1 sectors of hard disk, in total 512 bytes;It is bios Code to be run after Power-On Self-Test, master boot sector include three parts:
(1) Bootloader, main bootstrap program --- 446 bytes;
(2) Dpt, hard disk partition table --- 64 bytes;
(3) sector ending mark -- 2 bytes;
It is exported using order dd if=/dev/sda of=dpt.bak bs=1skip=446count=64.
3. according to the method described in claim 1, it is characterized by:
In the step 3,
When root partition is the last one subregion, total fan number of root partition in regeneration block table is only needed;Wherein, total fan of root partition Total fan number that number is equal to system disk subtracts the beginning sector of root partition;
When root partition is not the last one subregion, and when without extension subregion, following specific steps are executed:
A, in regeneration block table root partition total fan number, at this point, the blocks of root partition multiplies after total fan number=dilatation of root partition With 1024 product again divided by 512;
B, calculate the new end sector of root partition after dilatation, newly terminate root partition after sector=dilatation blocks- start sector+ 1;
C, the beginning sector of the subsequent subregion of root partition is changed to the end sector+1 of a upper subregion, terminates the sector=subregion Start the total fan number -1 of the sector+subregion;
When root partition is not the last one subregion, and has extension subregion, following specific steps are executed:
A, in regeneration block table root partition total fan number, at this point, the blocks of root partition multiplies after total fan number=dilatation of root partition With 1024 product again divided by 512;
B, calculate the new end sector of root partition after dilatation, newly terminate root partition after sector=dilatation blocks- start sector+ 1;
C, the beginning sector in main partition behind root partition is changed to the end sector+1 of a upper subregion, terminates the sector=subregion Start the total fan number -1 of the sector+subregion;
D, the beginning sector for extending subregion is changed to the end sector+1 of a subregion, terminates the sector=extension subregion and starts to fan The total fan number -1 of the area+extension subregion;
E, the beginning sector of first logical partition is changed to the beginning sector+2048 of extension subregion, terminates the sector=logic Subregion starts the total fan number -1 of the sector+logical partition;
F, the beginning sector of remaining logical partition is changed to the beginning sector+2048 an of logical partition, terminate sector= The logical partition starts the total fan number -1 of the sector+logical partition.
4. according to the method described in claim 2, it is characterized by:
The sector refers to several segmental arcs that each magnetic track on disk is divided, these segmental arcs are the sectors of disk; Using sector as basic unit, each sector is 512 bytes for the read-write of hard disk;
The blocks is the size of subregion, and in blocks, each piece of default size is 1024 bytes, i.e. 1KB;
The fdisk is respectively main partition, extension subregion, logical partition;
The main partition, at least 1, each hard disk is up to 4, can be without extension subregion;
The logical partition needs to create extension subregion from main partition, then establishes logical partition in extension subregion;
The extension subregion capacity is equal to the sum of the capacity of logical partition in extension partition creating.
5. according to the method described in claim 1, it is characterized by:
In the step 6,
If it is xfs file system, then order xfs_growfs is executed, root partition file system is made to be expanded to entire root partition Maximum available space;
If it is ext2, ext3 or ext4 file system, then order resize2fs is executed, expands root partition file system To the maximum available space of entire root partition;
The xfs_growfs is that xfs file system redefines big small tool;
The resize2fs is that ext2/ext3/ext4 file system redefines big small tool.
CN201811555009.3A 2018-12-19 2018-12-19 Method for expanding root partition based on cloud platform Linux virtual machine Active CN109739437B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811555009.3A CN109739437B (en) 2018-12-19 2018-12-19 Method for expanding root partition based on cloud platform Linux virtual machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811555009.3A CN109739437B (en) 2018-12-19 2018-12-19 Method for expanding root partition based on cloud platform Linux virtual machine

Publications (2)

Publication Number Publication Date
CN109739437A true CN109739437A (en) 2019-05-10
CN109739437B CN109739437B (en) 2022-04-01

Family

ID=66360601

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811555009.3A Active CN109739437B (en) 2018-12-19 2018-12-19 Method for expanding root partition based on cloud platform Linux virtual machine

Country Status (1)

Country Link
CN (1) CN109739437B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7454516B1 (en) * 2000-08-03 2008-11-18 Microsoft Corporation Scalable virtual partitioning of resources
CN102135926A (en) * 2011-03-18 2011-07-27 浪潮电子信息产业股份有限公司 Data storing method capable of protecting hard disc from clearing or low level
CN103455348A (en) * 2013-08-27 2013-12-18 小米科技有限责任公司 Subarea adjustment method, device, terminal, server and system
CN103984571A (en) * 2014-05-21 2014-08-13 华为技术有限公司 Method and device for uprating operating system partition
CN107844260A (en) * 2016-09-19 2018-03-27 深圳市深信服电子科技有限公司 A kind of method and device of magnetic disk of virtual machine space dilatation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7454516B1 (en) * 2000-08-03 2008-11-18 Microsoft Corporation Scalable virtual partitioning of resources
CN102135926A (en) * 2011-03-18 2011-07-27 浪潮电子信息产业股份有限公司 Data storing method capable of protecting hard disc from clearing or low level
CN103455348A (en) * 2013-08-27 2013-12-18 小米科技有限责任公司 Subarea adjustment method, device, terminal, server and system
CN103984571A (en) * 2014-05-21 2014-08-13 华为技术有限公司 Method and device for uprating operating system partition
CN107844260A (en) * 2016-09-19 2018-03-27 深圳市深信服电子科技有限公司 A kind of method and device of magnetic disk of virtual machine space dilatation

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
王海燕: "《计算机组装与维护实训教程》", 31 August 2008 *
豆芽炒粉丝: "详解Linux 虚拟机根分区磁盘扩充空间记录", 《网站:脚本之家,网址:HTTPS://WWW.JB51.NET/ARTICLE/116327.HTM》 *

Also Published As

Publication number Publication date
CN109739437B (en) 2022-04-01

Similar Documents

Publication Publication Date Title
US9311375B1 (en) Systems and methods for compacting a virtual machine file
US20170109057A1 (en) System and Method for Reversibly and Transparently Increasing the Disk Storage Capacity of Desktop Microsoft Windows Operating Systems, Including Free Disk Space and Total Disk Capacity Projection at an Operator Customizable Compression Ratio
EP1192547A1 (en) Manipulation of computer volume segments
CN102521289B (en) File synchronization method, device and system
KR20110097609A (en) Capturing and naming dynamic storage tiering configurations to support data pre-staging
JPH06208467A (en) Computer system and method for backup memory
KR20000022716A (en) Efficient volume copy using pre-configuration of log structured target storage
CN102591797A (en) Auxiliary storage device and processing method thereof
CN104156175B (en) Virtual disk size smooth expansion method
CN106709014A (en) File system conversion method and apparatus
CN117112304A (en) Disk cloning method and system
CN104572492A (en) Method and apparatus of burning data to FAT (File Allocation Table)32 partition
CN101246534B (en) Method for making U disk with autorun virus immunity
CN104808953A (en) Device and method for controlling data storage and mobile terminal
CN109739437A (en) A method of based on cloud platform Linux virtual machine dilatation root partition
US6035396A (en) Method for sharing a storage medium between computers having disparate operating systems
CN105993002B (en) In-place disk deformatting
CN100419760C (en) File segmenting method and device for FAT file system
US20180157425A1 (en) Storage control apparatus, storage apparatus, and non-transitory computer-readable recording medium having control program stored therein
KR20100011137A (en) Data processing apparatus and data procssing method, using fat file system capable of fast file recovery
CN112416657A (en) System cloning method
JP2005506632A (en) Security device for mass storage devices
JP5500201B2 (en) Information processing apparatus and program
CN105354294A (en) Nested file management system and method
CN100389396C (en) FAT file system error treating method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant