An example of Linux Virtual Machine disk and partition Expansion

Source: Internet
Author: User
Article Title: Linux Virtual Machine disk and partition expansion example. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

When deploying a Linux virtual machine for a customer, I usually create a separate partition to store all the data of the customer and name it data. The default size of/data partitions is 35 GB. As time goes on, some customers may need to expand/data partitions. The following are my implementation steps on ESX4.0:

Note: In the production environment, you must back up the data before proceeding!

1) Turn off the Linux Virtual Machine and run the vmkfstools command to expand the vmdk file. The original size is 50 GB and is now 65 GB.

Vmkfstools-X 65G CentOS53.vmdk

2) to enable the Linux virtual machine, run the following command to view the new available space.

[Root @ CentOS53 ~] # Parted

GNU Parted 1.8.1

Using/dev/sda

Welcome to GNU Parted! Type 'help' to view a list of commands.

(Parted) print free

Model: VMware Virtual disk (scsi)

Disk/dev/sda: 69.8 GB

Sector size (logical/physical): 512B/512B

Partition Table: msdos

Number Start End Size Type File system Flags

1 32.3kB 107 MB 107 MB primary ext3 boot
2 107 MB 4401 MB 4294 MB primary ext3
3 4401 MB 6547 MB 2147 MB primary linux-swap
4 6547 MB 53.7 GB 47.1 GB extended
5 6547 MB 8694 MB 2147 MB logical ext3
6 8694 MB 10.8 GB 2147 MB logical ext3
7 10.8 GB 11.9 GB 1077 MB logical ext3
8 11.9 GB 13.0 GB 1077 MB logical ext3
9 13.0 GB 53.7 GB 40.7 GB logical ext3
53.7 GB 69.8 GB 16.1 GB Free Space

 

3) run disk/dev/sda and input P to view the partition result as follows, and record it (/dev/sda9 is loaded on/data Partition ). It can be seen that there are a total of 8485 cylinder, but the last partition only ends at 6527. This indicates that there is still hard disk space.

Disk/dev/sda: 69.7 GB, 69793218560 bytes

255 heads, 63 sectors/track, 8485 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System
/Dev/sda1*1 13 104391 83 Linux
/Dev/sda2 14 535 4192965 83 Linux
/Dev/sda3 536 796 2096482 + 82 Linux swap/Solaris
/Dev/sda4 797 6527 46034257 + 5 Extended
/Dev/sda5 797 1057 2096451 83 Linux
/Dev/sda6 1058 1318 2096451 83 Linux
/Dev/sda7 1319 1449 1052226 83 Linux
/Dev/sda8 1450 1580 1052226 83 Linux
/Dev/sda9 1581 6527 39736746 83 Linux

4) Input d to delete the extended partition/dev/sda4, so that all the logical partitions will disappear from the Partition Table (Don't be afraid, haha ).

5) Input n to create a new extended partition, and create all the original logical partitions (except/dev/sda9) and keep the original starting and ending cylinder address unchanged. The start address of/dev/sda9 remains unchanged, and the end address is changed to 8485. The new partition table is as follows. Enter w to save the settings.

Command (m for help): p

Disk/dev/sda: 69.7 GB, 69793218560 bytes

255 heads, 63 sectors/track, 8485 cylinders

Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sda1*1 13 104391 83 Linux
/Dev/sda2 14 535 4192965 83 Linux
/Dev/sda3 536 796 2096482 + 82 Linux swap/Solaris
/Dev/sda4 797 8485 61761892 + 5 Extended
/Dev/sda5 797 1057 2096451 83 Linux
/Dev/sda6 1058 1318 2096451 83 Linux
/Dev/sda7 1319 1449 1052226 83 Linux
/Dev/sda8 1450 1580 1052226 83 Linux
/Dev/sda9 1581 8485 55464381 83 Linux

 

[1] [2] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.