resizing hard disk partitions
To increase the root space, reduce the home space.
1. Check your hard drive usage.
[root@npm ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 48G 45G 17M 100% /tmpfs 246M 0 246M 0% /dev/shm/dev/sda1 485M 33M 427M 8% /boot/dev/mapper/VolGroup-lv_home 50G 180M 47G 1% /home
2. Adjust the home partition size
[[Email protected] ~]# Umount/home[[Email protected] ~]# e2fsck-f/dev/mapper/volgroup-lv_homee2fsck1.41.12(17-may-2010) First step: Check Inode, block, and size step two: Check the directory structure 3rd step: Check the directory Connectivity Pass4:checking reference counts 5th step: Check Cluster summary information/dev/mapper/volgroup-lv_home:11/3303104 files(0.0% non-contiguous),253351/13207552 blocks[[Email protected] ~]# resize2fs-p/dev/mapper/volgroup-lv_home2gresize2fs1.41.12(17-may-2010) Resizing the filesystem on/dev/mapper/volgroup-lv_home to524288(4k) blocks. Begin Pass2(Max =32768) re-locating block Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxbegin Pass3(Max =404) Scanning Inode table xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxthe filesystem On/dev/mapper/volgroup-lv_home is now 524288 blocks long. [[email protected] ~]# mount/home [[email protected] ~]# df-hfilesystem Size Used Avail Use% Mounted On/dev/mapper/volgroup-lv_root 48g 45G 17m 100%/tmpfs 246m 0 Span class= "Hljs-number" >246m 0%/dev/shm/dev/sda1 485M 33m 427m 8%/boot/dev/mapper/volgroup-lv_ Home 2.0g 152m 1.8G 8%/home
3. Free up space
[Email protected] ~]# lvreduce-l 2g/dev/mapper/volgroup-lv_home warning:reducing Active and open logical volume to 2. GiB This May DESTROY YOUR DATA (filesystem etc)Do you really wantTo reduce lv_home? [y/n]: Y reducing Logical volume Lv_homeTo2.00 GiB Logical Volume lv_home successfully resized[[email protected] ~]# Df-hfilesystemSize used AvailUse% MountedOn/dev/mapper/volgroup-lv_root48G45G16M100%/TMPFS246M0246M0%/dev/shm/dev/sda1485M33M427M8%/boot/dev/mapper/volgroup-lv_home2.0G152M1.8G8%/home[[email protected] ~]# Vgdisplay---Volume Group---VG Name VolGroup System IDFormat lvm2 Metadata Areas1 Metadata SequenceNo5 VG Accessread/Write VGStatus resizableMAX LV 0 Cur LV 3 Open LV 3 MAX PV 0 Cur PV 1 Act PV 1 VG Size 99.51 GiB PE C11>size 4.00 MiB Total pe 25474 Alloc PE/ size 13088/ 51.12 GiB free PE/ size 12386 / 48.38 GiB VG UUID illwio-pq0o-2ayw-fycp-qhcw-a1id-sozp1f
4. Add free space to root
[[Email protected] ~]# lvextend-l +48.38g/dev/mapper/volgroup-lv_root Rounding Sizeto boundaryBetween physical extents:48.38 GiB extending Logical Volume Lv_rootTo96.54 GiB Logical Volume lv_root successfully resized[[email protected] ~]# resize2fs-p/DEV/MAPPER/VOLGROUP-LV_ROOTRESIZE2FS1.41.12 (17-may-) FilesystemAt/dev/mapper/volgroup-lv_rootis mountedOn/;On-line resizing Requiredold desc_blocks =4, New_desc_blocks =7Performing anOn-line ResizeOf/dev/mapper/volgroup-lv_rootTo25307136 (4k) blocks. The filesystemOn/dev/mapper/volgroup-lv_rootis now25307136 blocks long. [[email protected] ~] # df-hfilesystem Size used Avail use% mounted on/dev/mapper/volgroup-lv_root 96g 45G 46g 50%/tmpfs 246M 0 246m 0%/dev/shm/dev/sda1 485m 33m 427m 8 %/boot/dev/mapper/volgroup-lv_home 2.0g 152M 1.8g 8%/Home
reprinted to: http://my.oschina.net/shanhe/blog/296735
CentOS 6.5 64-bit, resize partition