The method of expanding the Linux root directory system with insufficient space __linux

Source: Internet
Author: User
Tags new set
I. Purpose

When using the CentOS6.3 version Linux system, found that the root directory (/) of the space is not sufficient, and other directory space has a lot of free, so this article is mainly for the existing space to adjust. First, let's look at the space allocation of the system:




[Plain] View plaincopyprint?
01.[root@centos-78/]# df-h
02.Filesystem Size Used avail use% mounted on
03./dev/mapper/vg_centos-lv_root
50G 14G 34G 30%/
05.tmpfs 1.9G 0 1.9G 0%/dev/shm
06./DEV/SDA1 485M 37M 423M 8%/boot
07./dev/mapper/vg_centos-lv_home
404G 670M 382G 1%/home
The following detailed steps section will remove 100G of space from the Vg_centos-lv_home partition and add it to the/vg_centos-lv_root partition.

Second, detailed steps

1. Uninstall Vg_centos-lv_home partition




[Plain] View plaincopyprint?
01.[root@centos-78/]# Umount/home
At this point in the DF command to see that the/home directory has been seen, as follows:




[Plain] View plaincopyprint?
01.[root@centos-78/]# df-h
02.Filesystem Size Used avail use% mounted on
03./dev/mapper/vg_centos-lv_root
50G 14G 34G 30%/
05.tmpfs 1.9G 0 1.9G 0%/dev/shm
06./DEV/SDA1 485M 37M 423M 8%/boot


2, the new set Vg_home-lv_home size




[Plain] View plaincopyprint?
01.[root@centos-78/]# resize2fs-p/dev/mapper/vg_centos-lv_home 282G
02.RESIZE2FS 1.41.12 (17-may-2010)
03.Please Run ' e2fsck-f/dev/mapper/vg_centos-lv_home '.
This step to set the Vg_home-lv_home size did not succeed, the system prompts us to run the following command, the operation is as follows:




[Plain] View plaincopyprint?
01.[root@centos-78/]# e2fsck-f/dev/mapper/vg_centos-lv_home
02.e2fsck 1.41.12 (17-may-2010)
03.Pass 1:checking inodes, blocks, and sizes
04.Pass 2:checking directory structure
05.Pass 3:checking Directory Connectivity
06.Pass 4:checking Reference counts
07.Pass 5:checking Group summary Information
08./dev/mapper/vg_centos-lv_home:1386/26836992 files (0.9% non-contiguous), 1855856/107344896 blocks
To reset the Vg_home-lv_home size:




[Plain] View plaincopyprint?
01.[root@centos-78/]# resize2fs-p/dev/mapper/vg_centos-lv_home 282G
02.RESIZE2FS 1.41.12 (17-may-2010)
03.Resizing the filesystem on/dev/mapper/vg_centos-lv_home to 73924608 (4k) blocks.
04.Begin Pass 2 (max = 43)
05.Relocating blocks Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
06.Begin Pass 3 (max = 3276)
07.Scanning inode Table Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
08.Begin Pass 4 (max = 266)
09.Updating Inode References Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
10.The filesystem On/dev/mapper/vg_centos-lv_home is now 73924608 blocks long.
Check for success:




[Plain] View plaincopyprint?
01.[root@centos-78/]# Mount/home
02.[root@centos-78/]#
03.[root@centos-78/]# df-h
04.Filesystem Size Used avail use% mounted on
05./dev/mapper/vg_centos-lv_root
50G 14G 34G 30%/
07.tmpfs 1.9G 0 1.9G 0%/dev/shm
08./DEV/SDA1 485M 37M 423M 8%/boot
09./dev/mapper/vg_centos-lv_home
278G 663M 263G 1%/home
11.[root@centos-78/]#
3, reduce the lv_home logical partition to the specified size




[Plain] View plaincopyprint?
01.[root@centos-78/]# lvreduce-l 282g/dev/mapper/vg_centos-lv_home
Warning:reducing Active and open logical volume to 282.00 GiB
This May DESTROY YOUR DATA (filesystem etc.)
04.Do you really want to reduce lv_home? [y/n]: Y
Reducing logical volume Lv_home to 282.00 GiB
Logical Volume Lv_home successfully resized
07.[root@centos-78/]#
I think this command is to take the reduced 100G space to the system public area, can be loaded and used by other partitions.


To query the volume Group for information:




[Plain] View plaincopyprint?
01.[root@centos-78/]# Vgdisplay
---Volume Group---
, VG Name Vg_centos
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 465.27 GiB
PE Size 4.00 MiB
Total PE 119109
Alloc pe/size 86472/337.78 GiB
Free Pe/size 32637/127.49 GiB
VG UUID 1k4oon-rfv9-uyf1-umyf-aerg-yags-znosd6


The free pe/size designation should be now available in the allocated space.
4, increase the size of the Vg_centos-lv_root partition
Add the available space to the Vg_centos-lv_root partition:




[Plain] View plaincopyprint?
01.[root@centos-78/]# lvextend-l +127.40g/dev/mapper/vg_centos-lv_root
Rounding up size to full physical extent 127.40 GiB
Extending logical Volume Lv_root to 177.40 GiB
Logical Volume Lv_root successfully resized
05.[root@centos-78/]#
To reset the size of the partition:



[Plain] View plaincopyprint?
01.[root@centos-78/]# resize2fs-p/dev/mapper/vg_centos-lv_root
02.RESIZE2FS 1.41.12 (17-may-2010)
03.Filesystem at/dev/mapper/vg_centos-lv_root is mounted on/; On-line resizing required
04.old desc_blocks = 4, new_desc_blocks = 12
05.Performing a on-line resize of/dev/mapper/vg_centos-lv_root to 46504960 (4k) blocks.

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.