Adjust the space size of the directory under Linux __linux

Source: Internet
Author: User

I. Purpose

When using the CentOS6.5 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: [Root@innoplay01 ~]# lsb_release-a
LSB Version:: base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64: Graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor Id:centos
Description:centos Release 6.5 (Final)
release:6.5

Codename:final


[Root@innoplay01 java]# Df-h
FileSystem Size Used Avail use% mounted on
/dev/mapper/vg_innoplay01-lv_root 50G 2.0G 45G 5%/
Tmpfs 3.9G 0 3.9G 0%/dev/shm
/DEV/SDA1 485M 40M 421M 9%/boot
/dev/mapper/vg_innoplay01-lv_home 860G 200M 816G 1%/home


The following detailed steps section will remove 661G of space from the/dev/mapper/vg_innoplay01-lv_home partition and add it to the/dev/mapper/vg_innoplay01-lv_root partition.

Uninstall the/dev/mapper/vg_innoplay01-lv_home partition:


[Root@innoplay01 java]# Umount/home


At this point in the DF command to see that the/home directory has been seen, as follows:


[Root@innoplay01 java]# Df-h
FileSystem Size Used Avail use% mounted on
/dev/mapper/vg_innoplay01-lv_root 50G 2.0G 45G 5%/
Tmpfs 3.9G 0 3.9G 0%/dev/shm
/DEV/SDA1 485M 40M 421M 9%/boot



To reset the/dev/mapper/vg_innoplay01-lv_home size:


Resize2fs-p/dev/mapper/vg_innoplay01-lv_home 210G

[Root@innoplay01 java]# resize2fs-p/dev/mapper/vg_innoplay01-lv_home 210G
RESIZE2FS 1.41.12 (17-may-2010)
Please run ' e2fsck-f/dev/mapper/vg_innoplay01-lv_home '.

Follow the prompts:

E2fsck-f/dev/mapper/vg_innoplay01-lv_home

[Root@innoplay01 java]# e2fsck-f/dev/mapper/vg_innoplay01-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_innoplay01-lv_home:11/57237504 files (0.0% non-contiguous), 3643567/228918272 blocks
[Root@innoplay01 java]# resize2fs-p/dev/mapper/vg_innoplay01-lv_home 210G
RESIZE2FS 1.41.12 (17-may-2010)
Resizing the filesystem on/dev/mapper/vg_innoplay01-lv_home to 55050240 (4k) blocks.
Begin Pass 2 (max = 32768)
Relocating blocks Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Begin Pass 3 (max = 6987)
Scanning Inode Table Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The filesystem on/dev/mapper/vg_innoplay01-lv_home is now 55050240 blocks long.






Check for success:


[Root@innoplay01 java]# Mount/home
[Root@innoplay01 java]# Df-h
FileSystem Size Used Avail use% mounted on
/dev/mapper/vg_innoplay01-lv_root 50G 2.0G 45G 5%/
Tmpfs 3.9G 0 3.9G 0%/dev/shm
/DEV/SDA1 485M 40M 421M 9%/boot
/dev/mapper/vg_innoplay01-lv_home 207G 188M 197G 1%/home

To reduce the/dev/mapper/vg_innoplay01-lv_home logical partition to a specified size:

Lvreduce-l 210g/dev/mapper/vg_innoplay01-lv_home

[Root@innoplay01 java]# lvreduce-l 210g/dev/mapper/vg_innoplay01-lv_home
Warning:reducing Active and open logical volume to 210.00 GiB
This May DESTROY YOUR DATA (filesystem etc.)
Do your really want to reduce lv_home? [y/n]: Y
Reducing logical volume Lv_home to 210.00 GiB
Logical Volume Lv_home successfully resized

To query the volume Group for information:
Vgdisplay

[Root@innoplay01 java]# Vgdisplay
---Volume Group---
VG Name Vg_innoplay01
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 931.02 GiB
PE Size 4.00 MiB
Total PE 238341
Alloc pe/size 68548/267.77 GiB
Free Pe/size 169793/663.25 GiB
VG UUID Symjnp-igwm-mkt1-ubum-rsx8-hviz-eztuer

The free pe/size designation should be now available in the allocated space.

Increase the size of the/dev/mapper/vg_innoplay01-lv_root partition:

Lvextend-l +661.00g/dev/mapper/vg_innoplay01-lv_root

[Root@innoplay01 java]# lvextend-l +661.00g/dev/mapper/vg_innoplay01-lv_root
Extending logical Volume Lv_root to 711.00 GiB
Logical Volume Lv_root successfully resized


To reset the size of the partition:
Resize2fs-p/dev/mapper/vg_innoplay01-lv_root

[Root@innoplay01 java]# resize2fs-p/dev/mapper/vg_innoplay01-lv_root
RESIZE2FS 1.41.12 (17-may-2010)
FileSystem at/dev/mapper/vg_innoplay01-lv_root is mounted on/; On-line resizing required
Old desc_blocks = New_desc_blocks = 45
Performing a on-line resize of/dev/mapper/vg_innoplay01-lv_root to 186384384 (4k) blocks.
The filesystem on/dev/mapper/vg_innoplay01-lv_root is now 186384384 blocks long.


To view the partition size again:
[Root@innoplay01 java]# Df-h
FileSystem Size Used Avail use% mounted on
/dev/mapper/vg_innoplay01-lv_root 700G 2.0G 663G 1%/
Tmpfs 3.9G 0 3.9G 0%/dev/shm
/DEV/SDA1 485M 40M 421M 9%/boot
/dev/mapper/vg_innoplay01-lv_home 207G 188M 197G 1%/home

Note the point:

1, uninstall the/home directory when the failure, you can first execute the following Fuser command, and then Umount can be: fuser-m/home;

2, set the size of the lv_home, again mount the partition, found with DF command can not see to the partition, at this time as long as the mount once;

3, in setting the size of lv_root, do not put free pe/size space all use, this is likely to appear free PE space shortage, it is recommended to retain a little free PE space.

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.