--linux root partition disk expansion under VM

Source: Internet
Author: User

Reprint please indicate source: http://www.cnblogs.com/lighten/p/6825938.html

1. Reason

Due to the need to upgrade the software in the virtual machine, when performing yum update, the whole update package is above 800MB, but the size of the root partition is only less than 400MB, when it was created only to allocate 10G of space. Therefore, the size of the root partition must be expanded to find a lot of methods on the Internet, but because my situation is more special, toss to toss to finally is ready, so record, share.

Before installing the virtual machine is allocated 20G space, but divided into two mount points/and/home, so the first idea is to be able to the home/home space to/, think about it, want to expand 10G space,/home and not so much, it is intended to add a disk to the virtual machine operation. The trouble is:

Virtual machine in the D drive, D disk The entire space is not enough, so need to use the space C, because it has been done, the following demonstration of the steps to expand 1GB.

2. Steps

1. Select the virtual machine first, right-click Settings

2. Select Add, hard drive, next

3. One value point next, to set the capacity size, enter 1, then next, select the storage location, here I will choose the space in the C drive.

4. Finalize and enter the system. Df-h view current system file System status

5. Using Fdisk-l to see the hard drive, you can see my new drive range

6. Partition the newly added hard drive, format it because my disk name is/DEV/SDC, so enter the FDISK/DEV/SDC command:

Input: M

n Add a new partition

P Create primary partition, enter using default partition number

Enter two times use default start sector and last sector

Here you can see that the type of Setup is Linux type, which is actually less than 1GB in size. But my root partition is Linux LVM type, so I need to convert it again.

Continue typing T, enter 8e, return. Enter W to save the exit.

When you enter fdisk-l at this time, you can see the partition you created.

7. Be careful not to mount the newly created disk partition to a Linux file system, we are going to expand/scale instead of adding a zone. By the way, the Mount command is a MOUNT/DEV/SDC1/specified location empty folder/. If you want to automatically mount the boot, you need to modify the contents of the/etc/fstab file, add a line:/DEV/SDC1/Mount folder ext4 defaults 0 0. Before mounting, you need to format the disk first: MKFS.EXT4/DEV/SDC1 format it to Ext4, The same ext3,2 is to modify the numbers.

Back to the chase.

To create a physical volume: PVCREATE/DEV/SDC1

View current Volume group condition: Vgdisplay

Extended Volume Group: CENTOS:VGEXTEND/DEV/CENTOS/DEV/SDC1

You can see that the size of the VG has increased:

Finally, we want to expand our root directory Capacity:

Root partition is called root, the last level, CentOS is the volume group name, the command is as follows:

Capacity of the extended logical volume Centos-root: Lvextend-l +1024m/dev/centos/root

There may be a situation where the size is not enough and the 1024 will be slightly smaller.

Reset the capacity of the root partition: Resize2fs/dev/centos/root.

Then use Df-h to view the file system, you can see the size after the expansion.

3. References

Linux Root partition expansion

VM Virtual machines increase disk space expansion operations (little by Little)

--linux root partition disk expansion under VM

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.