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

LVM disk capacity expansion of Centos7 in linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

The system reminds me that the capacity is insufficient, so use the way of LVM to expand it.

The system is RHEL7 (centos7 is almost the same)

Check the disk information and root directory first

Fdisk-l

Note: sda is a hard disk. It is the root directory of the system that needs to be expanded. Here, the root directory of RHEL is / dev/mapper/rhel-root (if the system is different, the root directory is also different)

To close the system, go to vmware- > Settings-> hard disk-> expand-> enter a number greater than the current system memory-> Click expand.

Turn on the computer and check the disk information.

Fdisk-l

Note: you can see that the sda disk has increased, but the root directory has not, that is, the added space has not been partitioned and has not been partitioned to the root directory.

Create a new zone for the new space

Fdisk / dev/sdan / / add new partition p / / create primary partition 3 / / partition number 3 (1, 2 already have) press enter / / start sector to select default carriage return default / / in order not to waste space t / / change partition format 8e / change partition format to LVM p / / View finished partition (blocks is partition size unit is kb) w / save partition and exit

The partition has been built, but it needs to be rebooted to take effect.

Reboot

Convert a partition to a physical volume

Pvcreat / dev/sda3

View existing volume group names

Vgdisplay

Note: the volume group name is after VG Name, and the volume group name here is rhel,VG Size, which is the volume group size. Pay attention to the comparison later.

Start to extend / dev/sda3 to the volume group rhel

Vgextend rhel / dev/sda3 / / rhel is the volume group name

Check the volume group again

Vgdisplay

Note: the size of the VG Size has changed

Look at the logical volume and remember his LV Path path

Lvdisplay / / the LV Path path here is / dev/rhel/root

Expand the space for logical volumes

The lvextend / dev/rhel/root / dev/sda3 / / lvextend parameter-L is the specified size. If you do not enter-L + 10G, all space is used by default.

Use the resize2fs command to update the system-recognized file system size

Resize2fs / dev/mapper/rhel-root

Resize2fs may report an error due to a problem with the system version and change the command xfs_growfs

Xfs_growfs / dev/mapper/rhel-root

Finally, check

Df-h

Note: you can see that the root directory (dev/mapper/rhel-root) has been increased

Of course, you can also expand the capacity by adding a hard disk.

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