Original
First, the purpose
When using the CentOS6.3 version of the Linux system, found that the root directory (/) is not enough space, and other directory space is very free, so this article is mainly for the existing space to adjust. First, let's look at the spatial distribution of the system:
- [Email protected]/]# df-h
- Filesystem Size used Avail use% mounted on
- /dev/mapper/vg_centos-lv_root
- 50G 14G 34G 30%/
- Tmpfs 1.9G 0 1.9G 0%/dev/shm
- /DEV/SDA1 485M 37M 423M 8%/boot
- /dev/mapper/vg_centos-lv_home
- 404G 670M 382G 1%/Home
The detailed steps section below will take 100G of space from the Vg_centos-lv_home partition and add it to the/vg_centos-lv_root partition.
Second, detailed steps
1. Uninstalling the Vg_centos-lv_home partition
- [Email protected]/]# Umount/home
At this point in the DF command, you will see that the/home directory is missing, as shown below:
- [Email protected]/]# df-h
- Filesystem Size used Avail use% mounted on
- /dev/mapper/vg_centos-lv_root
- 50G 14G 34G 30%/
- Tmpfs 1.9G 0 1.9G 0%/dev/shm
- /DEV/SDA1 485M 37M 423M 8%/boot
2, the new setting vg_home-lv_home size
- [Email protected]/]# resize2fs-p/dev/mapper/vg_centos-lv_home 282G
- RESIZE2FS 1.41.12 (17-may-2010)
- Please run ' e2fsck-f/dev/mapper/vg_centos-lv_home ' first.
This step set Vg_home-lv_home size is not successful, the system prompts us to run the following command, the operation is as follows:
- [Email protected]/]# e2fsck-f/dev/mapper/vg_centos-lv_home
- E2fsck 1.41.12 (17-may-2010)
- Pass 1:checking inodes, blocks, and sizes
- Pass 2:checking directory structure
- Pass 3:checking Directory Connectivity
- Pass 4:checking Reference counts
- Pass 5:checking Group summary Information
- /dev/mapper/vg_centos-lv_home:1386/26836992 files (0.9% non-contiguous), 1855856/107344896 blocks
From the new setting Vg_home-lv_home size:
- [Email protected]/]# resize2fs-p/dev/mapper/vg_centos-lv_home 282G
- RESIZE2FS 1.41.12 (17-may-2010)
- Resizing the filesystem on/dev/mapper/vg_centos-lv_home to 73924608 (4k) blocks.
- Begin Pass 2 (max = 43)
- Relocating blocks Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Begin Pass 3 (max = 3276)
- Scanning Inode Table Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Begin Pass 4 (max = 266)
- Updating Inode References Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- The filesystem on/dev/mapper/vg_centos-lv_home is now 73924608 blocks long.
Check for success:
- [Email protected]/]# Mount/home
- [Email protected]/]#
- [Email protected]/]# df-h
- Filesystem Size used Avail use% mounted on
- /dev/mapper/vg_centos-lv_root
- 50G 14G 34G 30%/
- Tmpfs 1.9G 0 1.9G 0%/dev/shm
- /DEV/SDA1 485M 37M 423M 8%/boot
- /dev/mapper/vg_centos-lv_home
- 278G 663M 263G 1%/Home
- [Email protected]/]#
3. Reduce the Lv_home logical partition to the specified size
- [Email protected]/]# 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)
- Does really want to reduce lv_home? [y/n]: Y
- Reducing logical volume Lv_home to 282.00 GiB
- Logical Volume Lv_home successfully resized
- [Email protected]/]#
I think this command is to take the reduced 100G space to the public areas of the system, can be loaded and used by other partitions.
To query volume group information:
- [Email protected]/]# 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
Free pe/size Specifies that the allocated space should now be available.
4, increase the size of the Vg_centos-lv_root partition
Add the available space to the Vg_centos-lv_root partition:
- [Email protected]/]# 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
- [Email protected]/]#
Size the partition from the new setting:
- [Email protected]/]# resize2fs-p/dev/mapper/vg_centos-lv_root
- RESIZE2FS 1.41.12 (17-may-2010)
- Filesystem at/dev/mapper/vg_centos-lv_root is mounted on/; On-line resizing required
- Old desc_blocks = 4, new_desc_blocks = 12
- Performing an on-line resize of/dev/mapper/vg_centos-lv_root to 46504960 (4k) blocks.
- The filesystem on/dev/mapper/vg_centos-lv_root is now 46504960 blocks long.
5. Check the partition size again
- [Email protected]/]# df-h
- Filesystem Size used Avail use% mounted on
- /dev/mapper/vg_centos-lv_root
- 175G 14G 153G 9%/
- Tmpfs 1.9G 0 1.9G 0%/dev/shm
- /DEV/SDA1 485M 37M 423M 8%/boot
- /dev/mapper/vg_centos-lv_home
- 278G 663M 263G 1%/Home
We found that the space in the Vg_centos-lv_root partition has increased by 125G, and the reason for the reduction in space compared to Lv_home 25G is mainly due to the fact that we have added all the available space in the system to the Lv_root partition.
Third, the problems encountered
1. Failed while uninstalling the/home directory
You can do the following Fuser command first, and then Umount:
- [Email protected]/]# fuser-m/Home
- [Email protected]/]#
2, set the size of the lv_home, again mount the partition, found with the DF command can not see to the partition, at this time as long as the mount can be
3, in the setting lv_root size, do not put free pe/size space all use, this is likely to appear free PE space is not enough, it is recommended to keep a little free pe space.
==================================================================
Reference:
Http://hi.baidu.com/%B7%E7%B6%C0/blog/item/c4aa9a81b204dbc89023d956.html
http://qianxunniao.iteye.com/blog/1393726
Adjust the size of the root directory under Linux