The size of the CentOS extension root partition

Source: Internet
Author: User
Tags disk usage

Goal: Reduce the volgroup-lv_home to 125G 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/vg_hostname-lv_root
20G 8.7G 9.6G 48%/
Tmpfs 6.9G 72K 6.9G 1%/DEV/SHM
/DEV/SDA1 485M 38M 422M 9%/boot
/dev/mapper/vg_hostname-lv_home
171G 110G 53G 68%/Home
/DEV/SDB5 2.0T 805G 1.1T 43%/XXXX_SDB5
/DEV/SDC5 1.7T 197M 1.6T 1%/XXXX_SDC5


2. Uninstall/Home
[Email protected] ~]# Umount/home
Umount:/home:device is busy.
(In some cases useful info about processes
The device is found by lsof (8) or fuser (1))

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
/home:31112m
Top
Kill-9 31112

3. Adjust the partition size
[Email protected] ~]# resize2fs-p/dev/mapper/vg_hostname-lv_home 125G
RESIZE2FS 1.41.12 (17-may-2010)
Please run ' e2fsck-f/dev/mapper/vg_hostname-lv_home ' first.

If you are prompted to run "E2fsck-f/dev/mapper/volgroup-lv_home", execute the relevant command:
[[email protected] ~]# e2fsck-f/dev/mapper/vg_hostname-lv_home and then re-execute the command:
[Email protected] ~]# resize2fs-p/dev/mapper/vg_hostname-lv_home 125G
RESIZE2FS 1.41.12 (17-may-2010)
Resizing the filesystem on/dev/mapper/vg_hostname-lv_home to 32768000 (4k) blocks.
Begin Pass 2 (max = 7110485)
Relocating blocks Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Begin Pass 3 (max = 1385)
Scanning Inode Table Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Begin Pass 4 (max = 3237)
Updating Inode References Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The filesystem on/dev/mapper/vg_hostname-lv_home is now 32768000 blocks long.

Note: resize2fs to reset the disk size, just re-specify the size, do not affect the results, requires the following lvreduce mates

4. Mount Home/home to view disk usage
[Email protected] ~]# Mount/home
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/vg_hostname-lv_root
20G 8.7G 9.6G 48%/
Tmpfs 6.9G 72K 6.9G 1%/DEV/SHM
/DEV/SDA1 485M 38M 422M 9%/boot
/DEV/SDB5 2.0T 805G 1.1T 43%/XXXX_SDB5
/DEV/SDC5 1.7T 197M 1.6T 1%/XXXX_SDC5
/dev/mapper/vg_hostname-lv_home
124G 110G 7.4G 94%/Home


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 125g/dev/mapper/vg_hostname-lv_home
Warning:reducing Active and open logical volume to 125.00 GiB
This May DESTROY YOUR DATA (filesystem etc)
Does really want to reduce lv_home? [y/n]: Y
Reducing logical volume Lv_home to 125.00 GiB
Logical Volume Lv_home successfully resized

Note: lvreduce-l 125G means to set the current file system to 125G if lvreduce-l 125G means to reduce 125G 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
---Volume Group---
VG Name Vg_hostname
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access Read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
ACT PV 1
VG Size 199.51 GiB
PE Size 4.00 MiB
Total PE 51074
Alloc pe/size 38758/151.40 GiB
Free Pe/size 12316/48.11 GiB
VG UUID ZK1EHH-QXE8-SDM8-CKFF-STSL-YFFZ-DFE9SF
Note: Vgdisplay is the metadata information for displaying LVM volume groups

6. Hang the unused space in the root directory
[Email protected] ~]# lvextend-l +48g/dev/mapper/vg_hostname-lv_root
Extending logical Volume Lv_root to 67.53 GiB
Logical Volume Lv_root successfully resized
Note: lvextend-l +48g adds 48G to the file system
[Email protected] ~]# resize2fs-p/dev/mapper/vg_hostname-lv_root
RESIZE2FS 1.41.12 (17-may-2010)
Filesystem at/dev/mapper/vg_hostname-lv_root is mounted on/; On-line resizing required
Old desc_blocks = 2, new_desc_blocks = 5
Performing an on-line resize of/dev/mapper/vg_hostname-lv_root to 17702912 (4k) blocks.
The filesystem on/dev/mapper/vg_hostname-lv_root is now 17702912 blocks long.

7. Check the adjustment results
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/vg_hostname-lv_root
67G 8.7G 55G 14%/
Tmpfs 6.9G 72K 6.9G 1%/DEV/SHM
/DEV/SDA1 485M 38M 422M 9%/boot
/DEV/SDB5 2.0T 805G 1.1T 43%/XXXX_SDB5
/DEV/SDC5 1.7T 197M 1.6T 1%/XXXX_SDC5
/dev/mapper/vg_hostname-lv_home
124G 110G 7.4G 94%/Home

The size of the CentOS extension root partition

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.