Linux (centos6) to adjust the size of the mounted partition

Source: Internet
Author: User
In linux (centos6), you can adjust the size of the Mount partition and install centos6. we recommend that you use auto-recommended partitions. in this case, the/home partition is too large. Target:/home is 20 GB, and the remaining value is added to the/Directory. 1. View partition mode [root @ localhost ~] # Df-H file system capacity has been available... linux (centos 6) adjust the Mount partition size install centos6 use auto recommended partition, found a problem/home partition is too large. Target:/home is 20 GB, and the remaining value is added to the/Directory. 1. View partition mode [root @ localhost ~] # Df-H file system capacity available in use % mount point/dev/mapper/VolGroup-lv_root50G 2.9G 44G 7%/tmpfs 5.9G 100 K 5.9G 1%/dev/shm/dev /sda1 485 M 37 M 423 M 8%/boot/dev/mapper/VolGroup-lv_home1.1T 200 M 988G 1%/home 2. detach a Mount partition [root @ localhost ~] # Umount/home 3. check the error of the VolGroup-lv_home file,-f forcibly checks correctness even if the file system shows no signs of errors. [Root @ localhost ~] # E2fsck-f/dev/mapper/VolGroup-lv_homee2fsck 1.41.12 (17-May-2010) Step 1: Check inode, block, and size Step 2: Check the directory structure Step 2: check Directory connectivity Pass 4: Checking reference counts step 5th: check cluster profile information/dev/mapper/VolGroup-lv_home: 27/69304320 files (0.0% non-contiguous), 4400705/277215232 blocks 4. change/home to 20 GB, [root @ localhost ~] # Resize2fs-p/dev/mapper/VolGroup-lv_home 20Gresize2fs 1.41.12 (17-May-2010) Resizing the filesystem on/dev/mapper/VolGroup-lv_home to 5242880 (4 k) blocks. begin pass 2 (max = 32784) is redeploying the block into pass 3 (max = 8460) is scanning inode table into pass 4 (max = 15) is updating inode reference xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxthe filesystem on/d Ev/mapper/VolGroup-lv_home is now 5242880 blocks long. 5. remount and view [root @ localhost ~] # Mount/home [root @ localhost ~] # Df-H file system capacity available in use % mount point/dev/mapper/VolGroup-lv_root50G 2.9G 44G 7%/tmpfs 5.9G 100 K 5.9G 1%/dev/shm/dev /sda1 485 M 37 M 423 M 8%/boot/dev/mapper/VolGroup-lv_home20G 172 M 19G 1%/home 6. divide the remaining space outside 20 GB. Use the lvreduce command to reduce the space occupied by the LVM Logical Volume. The existing data on the logical volume may be deleted, so you must confirm before performing the operation. Remember to enter "y" [root @ localhost ~] # Lvreduce-L 20G/dev/mapper/VolGroup-lv_homeWARNING: variable active and open logical volume to 20.00 GiBTHIS may destroy your data (filesystem etc.) Do you really want to reduce lv_home? [Y/n]: ycing Cing logical volume lv_home to 20.00 GiBLogical volume lv_home successfully resized [root @ localhost ~] # Df-H file system capacity available in use % mount point/dev/mapper/VolGroup-lv_root50G 2.9G 44G 7%/tmpfs 5.9G 100 K 5.9G 1%/dev/shm/dev /sda1 485 M 37 M 423 M 8%/boot/dev/mapper/VolGroup-lv_home20G 172 M 19G 1%/home 7. view "Free PE/Size" remaining space [root @ localhost ~] # Vgdisplay --- Volume group --- VG Name VolGroupSystem IDFormat lvm2Metadata Areas 1 Metadata Sequence No 5VG Access read/writeVG Status resizableMAX LV 0Cur LV 3 Open LV 3Max PV 0Cur PV 1Act PV 1VG Size 1.09 TiBPE Size 4.00 MiBTotal PE 285022 Alloc PE/Size 19424/75 .88 GiBFree PE/Size 265598/1 .01 TiBVG UUID nSbflh-J7fN-xDvf-zLjL-tFcu-Y5Tm-ybnDk0 8. use the lvextend command: extend logical volume space to/dev/mapper/VolGroup-lv_ro The ot Directory, that is, the "/" directory. [Root @ localhost ~] # Lvextend-L + 1.01 T/dev/mapper/VolGroup-lv_rootRounding size to boundary between physical extents: 1.01 TiBExtending logical volume lv_root to 1.06 TiBLogical volume lv_root successfully resized 9. wait patiently to make the operation take effect. [Root @ localhost ~] # Resize2fs-p/dev/mapper/VolGroup-lv_rootresize2fs 1.41.12 (17-May-2010) Filesystem at/dev/mapper/VolGroup-lv_root is mounted on/; on-line resizing requiredold desc_blocks = 4, new_desc_blocks = 68 specify Ming an on-line resize of/dev/mapper/VolGroup-lv_root to 284227584 (4 k) blocks. the filesystem on/dev/mapper/VolGroup-lv_root is now 284227584 blocks long. 10. check that the partition is successful. [root @ localhost ~] # Df-H file system capacity available in use % mount point/dev/mapper/VolGroup-lv_root1.1T 2.9G 1011G 1%/tmpfs 5.9G 100 K 5.9G 1%/dev/shm/dev /sda1 485 M 37 M 423 M 8%/boot/dev/mapper/VolGroup-lv_home20G 172 M 19G 1%/home11. restart [root @ localhost ~] # Shutdown-r now
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.