CentOS resize VolGroup-lv_root and VolGroup-lv_home Partition

Source: Internet
Author: User

CentOS resize VolGroup-lv_root and VolGroup-lv_home Partition

The APP and background services suddenly fail to upload images and browse images. After checking, the root partition is already 100%


Solve the Problem of adjusting the size of home and root partitions in CentOS.

Goal: scale down the VolGroup-lv_home to 20 GB and add the remaining space to the VolGroup-lv_root

1. First check the disk usage

[Root @ localhost ~] # Df-h

Filesystem Size Used Avail Use % Mounted on

/Dev/mapper/VolGroup-lv_root 7.6G 2.7G 4.6G 37%/

Tmpfs 932 M 76 K 932 M 1%/dev/shm

/Dev/sda1 477 M 42 M 410 M 10%/boot

/Dev/mapper/VolGroup-lv_home 9.5G 22 M 9.0G 1%/home

2. Uninstall/home

[Root @ localhost ~] # Umount/home

Note: umount/home: if the system prompts that the process cannot be uninstalled, the process occupies/home. Run the following command to terminate the process: [root @ localhost ~] # Fuser-m/home

3. Adjust the partition size

[Root @ localhost ~] # Resize2fs-p/dev/mapper/VolGroup-lv_home 2G

If you are prompted to run e2fsck-f/dev/mapper/VolGroup-lv_home, execute the related command:

[Root @ localhost ~] # E2fsck-f/dev/mapper/VolGroup-lv_home

[Root @ localhost ~] # Resize2fs-p/dev/mapper/VolGroup-lv_home 2G

Note: In order to reset the disk size, resize2fs only re-specifies the disk size, which does not affect the result. The following lvreduce operations are required.

4. Mount/home to view disk usage

[Root @ localhost ~] # Mount/home

[Root @ localhost ~] # Df-h

5. Set Free Space

Use the lvreduce command to reduce the space occupied by the LVM logical volume. The existing data on the logical volume may be deleted, so you must confirm before performing the operation. Remember to enter "y"

[Root @ localhost ~] # Lvreduce-L 2G/dev/mapper/VolGroup-lv_home

Note: lvreduce-L 2G indicates that the current file system is set to 2G. If lvreduce-l 2G indicates that the current file system is reduced by 2G.

Use lvreduce to reduce the logical volume size. Note: The reduced size cannot be smaller than the file size. Otherwise, data will be lost.

You can use the vgdisplay command to check the size of the operation. You can also run the fdisk-l command to view details.
[Root @ localhost ~] # Vgdisplay
Note: vgdisplay displays the metadata of an LVM volume group.

6. Hanging idle space in the root directory

[Root @ localhost ~] # Lvextend-L + 8G/dev/mapper/VolGroup-lv_root

Note: lvextend-L + 8 GB is added to the file system by 8 GB.

[Root @ localhost ~] # Resize2fs-p/dev/mapper/VolGroup-lv_root

7. Check the Adjustment Result

[Root @ localhost ~] # Df-h

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.