Adjust the size of home and root partitions in CentOS, centoshome

Source: Internet
Author: User

Adjust the size of home and root partitions in CentOS, centoshome

Sometimes, when we cannot predict or incorrectly partition the drive letters, it will often cause great inconvenience in subsequent operations, here I will record the entire process of adjusting the size of the home and root partition buckets after the next wrong partition!
  
① View the partition status of our existing machine

Centos download: http://www.gooln.com/other/8820.html

[root@weidianserver2 ~]# df -hFilesystem                             Size  Used Avail Use% Mounted on/dev/mapper/vg_weidianserver2-lv_root   50G   44G  2.8G  95% /tmpfs                                  7.8G   72K  7.8G   1% /dev/shm/dev/sda1                              485M   39M  421M   9% /boot/dev/mapper/vg_weidianserver2-lv_home  860G  4.4G  812G   1% /home

We can find that the root partition and home partition are extremely unreasonable, so here we will narrow down the storage of the home partition and add the Compressed Storage to the root!
  
② First unload our home partition and compress the size of our home Partition

[Root @ weidianserver2 ~] # Umount/home [root @ weidianserver2 ~] # Df-hFilesystem Size Used Avail Use % Mounted on/dev/mapper/vg_weidianserver2-lv_root 50G 44G 2.8G 95%/tmpfs 7.8G 72 K 7.8G 1%/dev/shm/dev/ sda1 485 M 39 M 421 M 9%/boot [root @ weidianserver2 ~] # Resize2fs-p/dev/mapper/vg_weidianserver2-lv_home 20Gresize2fs 1.41.12 (17-May-2010) Run 'e2fsck-f/dev/er ER/vg_weidianserver2-lv_home 'first. [root @ weidianserver2 ~] # E2fsck-f/dev/mapper/vg_weidianserver2-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/vg_weidianserver2-lv_home: 330/57229312 files (3.9% non-contiguous), 4737926/228899840 blocks [root @ weidianserver2 ~] # Resize2fs-p/dev/mapper/vg_weidianserver2-lv_home 20Gresize2fs 1.41.12 (17-May-2010) Resizing the filesystem on/dev/mapper/vg_weidianserver2-lv_home to 5242880 (4 k) blocks. begin pass 2 (max = 33784) is re-locating block xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxbegin pass 3 (max = 6986) is scanning inode table partition pass 4 (max = 147) updating inode reference xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxthe filesystem on/dev/mapper/vg_weidianserver2-lv_home is now 5242880 blocks long.

③ We can see from the running results that our home is compressed to 20 GB. At this time, we can re-load our home directory.

[root@weidianserver2 ~]# mount /home[root@weidianserver2 ~]# df -hFilesystem                             Size  Used Avail Use% Mounted on/dev/mapper/vg_weidianserver2-lv_root   50G   44G  2.8G  95% /tmpfs                                  7.8G   72K  7.8G   1% /dev/shm/dev/sda1                              485M   39M  421M   9% /boot/dev/mapper/vg_weidianserver2-lv_home   20G  4.4G   15G  24% /home

In this way, the home is compressed and reloaded, for example:

④ We processed the home block in the above three steps, but our idle hard disk was not added to the root, so we will add the compressed disk to the root:

[Root @ localhost ~] # Lvextend-L + 812G/dev/mapper/vg_weidianserver2-lv_root Note: lvextend-L + 283G for adding 283G to the file system [root @ localhost ~] # Resize2fs-p/dev/mapper/vg_weidianserver2-lv_root

It takes a little time to reload and mount the disk, but we can also continuously check the size of the drive letter during this time, at this time, we will find that the size of the root drive letter will increase a little bit, such:

From the final result, we can see that we compress the free drive letter in the home to GB and add it to the root, so our root Space will increase instantly. Finally, thank you for reading it, if you have any questions, please leave a message for discussion. Thank you!

 

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.