Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of adjusting the size of home and root partition under linux system CentOS

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to solve the problem of resizing home and root partition under linux system CentOS". In daily operation, it is believed that many people have doubts about how to solve the problem of resizing home and root partition under linux system CentOS. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful to answer the question of "how to solve the problem of resizing home and root partition under linux system CentOS"! Next, please follow the editor to study!

After the xxx/data/ path of owncloud is modified, there is no write permission for the web server, so the capacity of the excess home partition is adjusted to the root folder, so the related problem is solved. The next problem is to solve the problem of external hard drive.

Goal: reduce the VolGroup-lv_home to 20g and add the remaining space to VolGroup-lv_root

1. Check the disk usage first.

[root@jb51.net~] # df-h

File system capacity used available used% mount point

Filesystem Size Used Avail Use% Mounted on

/ dev/mapper/VolGroup-lv_root 154G 7.9G 139G 6% /

Tmpfs 1.9G 100K 1.9G 1% / dev/shm

/ dev/sda1 485M 69m 391M 15% / boot

/ dev/mapper/VolGroup-lv_home 299G 984M 283G 1% / home goal: reduce the VolGroup-lv_home to 20G and add the remaining space to VolGroup-lv_root

2. Uninstall / home

[root@jb51.net~] # umount / home

Umount / home if prompted that it cannot be uninstalled, the / home is occupied by a process. Use the following command to terminate the occupied process:

[root@jb51.net~] # fuser-m / home

3. Resize the partition

[root@jb51.net~] # resize2fs-p / dev/mapper/VolGroup-lv_home 20g

If prompted to run "e2fsck-f / dev/mapper/VolGroup-lv_home", execute the command:

[root@jb51.net~] # e2fsck-f / dev/mapper/VolGroup-lv_home then re-execute the command:

[root@jb51.net~] # resize2fs-p / dev/mapper/VolGroup-lv_home 20g Note: in order to resize the disk, resize2fs only re-specifies the size, which does not affect the result. The cooperation of the following lvreduce is required.

4. Mount / home to check the disk usage

[root@jb51.net~] # mount / home

[root@jb51.net~] # df-h

5. Set up free space

Use the lvreduce directive to reduce the amount of space consumed by LVM logical volumes. Data that already exists on the logical volume may be deleted, so confirmation must be made before the operation. Remember to enter "y"

[root@jb51.net~] # lvreduce-L 20g / dev/mapper/VolGroup-lv_home Note: lvreduce-L 20g means to set the current file system to 20g, if lvreduce-l 20g means to reduce 20g from the current file system

Use lvreduce to reduce the size of logical volumes.

Note: the reduced size cannot be less than the size of the file, otherwise data will be lost.

You can use the vgdisplay command and so on to see how much you can manipulate. You can also use the fdisk-l command to view the details.

[root@jb51.net~] # vgdisplay Note: vgdisplay is the metadata information that displays the LVM volume group

6. Hang the idle space in the root directory

[root@jb51.net~] # lvextend-L + 283G / dev/mapper/VolGroup-lv_root

Note: lvextend-L + 283G adds 283G to the file system

[root@jb51.net~] # resize2fs-p / dev/mapper/VolGroup-lv_root7, finally check the adjustment result

[root@jb51.net~] # df-h

At this point, the study on "how to solve the problem of resizing home and root partition under linux system CentOS" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report