How to adjust the home and root partition size under CentOS

Source: Internet
Author: User
Tags disk usage

Solve the problem of external hard disk.

goal: reduce the volgroup-lv_home to 20G and add the remaining space to the Volgroup-lv_root

1. Check disk usage First
[[Email protected]~]# df-h
File system capacity has been used with available% mount points
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root 154G 7.9G 139G 6%/
Tmpfs 1.9G 100K 1.9G 1%/DEV/SHM
/DEV/SDA1 485M 69M 391M 15%/boot
/dev/mapper/volgroup-lv_home 299G 984M 283G 1%/home target: Reduce the volgroup-lv_home to 20G and add the remaining space to the Volgroup-lv_root

2. Uninstall/Home
[[Email protected]~]# umount/home
Umount/home If the prompt cannot be uninstalled, a process consumes/home and uses the following command to terminate the consuming process:
[[Email protected]~]# fuser-m/Home

3. Adjust the partition size
[Email protected]~]# resize2fs-p/dev/mapper/volgroup-lv_home 20G
If you are prompted to run "E2fsck-f/dev/mapper/volgroup-lv_home", execute the relevant command:
[[Email protected]~]# e2fsck-f/dev/mapper/volgroup-lv_home then re-execute the command:
[[Email protected]~]# resize2fs-p/dev/mapper/volgroup-lv_home 20G Note: resize2fs to reset the size of the disk, just re-specify the size, does not affect the results, The following lvreduce need to be matched
4. Mount Home/home to view disk usage
[[Email protected]~]# mount/home
[[Email protected]~]# df-h

5. Set free space
Use the Lvreduce directive to reduce the amount of space that LVM logical volumes occupy. The data already on the logical volume may be deleted, so you must confirm it before the operation. Remember to enter "Y"
[[Email protected]~]# lvreduce-l 20g/dev/mapper/volgroup-lv_home Note: lvreduce-l 20G means to set the current file system to 20G if lvreduce-l 20G refers to the reduction of 20G from the current file system
Use Lvreduce to reduce the size of the logical volume.

Note: The reduced size cannot be less than the size of the file, otherwise the data will be lost.

You can use the Vgdisplay command to see what size you can manipulate. You can also use the FDISK-L command to view detailed information.
[[Email protected]~]# vgdisplay Note: vgdisplay to display metadata information for LVM volume groups

6, the idle space hanging in the root directory
[Email protected]~]# lvextend-l +283g/dev/mapper/volgroup-lv_root
Note: lvextend-l +283g adds 283G to the file system
[[Email protected]~]# resize2fs-p/dev/mapper/volgroup-lv_root7, final check adjustment results
[[Email protected]~]# df-h

How to adjust the home and root partition size under CentOS

Related Article

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.