乐闻世界logo
搜索文章和话题

How can you increase the size of LVM partition ?

1个答案

1

In the Linux environment, LVM (Logical Volume Management) provides highly flexible disk management capabilities. Increasing the size of an LVM logical volume can be done through the following steps:

Step 1: Check the Existing Volume Group Space

First, confirm whether the existing Volume Group (VG) has sufficient unallocated space to extend the Logical Volume (LV). Use the following command to view:

bash
vgdisplay

Step 2: Extend the Logical Volume (LV)

If the volume group has sufficient space, directly extend the logical volume using the lvextend command. For example, to add 10GB of space to the logical volume, run:

bash
lvextend -L +10G /dev/VolGroup00/LogVol00

Here, /dev/VolGroup00/LogVol00 is the path to the logical volume, and the -L parameter specifies the additional space.

Step 3: Adjust the File System Size

After extending the logical volume, adjust the file system size to utilize the new space. The command varies based on the file system:

  • For ext4, use resize2fs:
bash
resize2fs /dev/VolGroup00/LogVol00
  • For XFS, use xfs_growfs:
bash
xfs_growfs /dev/VolGroup00/LogVol00

Step 4: Verify the New Space

Finally, check if the new disk space is available using the df command:

bash
df -h

This will display disk usage, and you should see the logical volume size increased.

Practical Application Example

In my previous work experience, we managed a log server where disk space frequently reached its limit. By leveraging LVM to extend capacity, we could rapidly increase storage without downtime, significantly enhancing server stability and availability.

2024年8月14日 17:56 回复

你的答案