This article was sponsored by Xiuyi linfeng and first launched in the dark world.
The previous article introduces the basic LVM knowledge. This article describes how to expand the logical Volume LV and volume group VG of LVM.
We know that the logical volume of LVM is equivalent to a partition. Since it is a partition, it has a distinction between the size and space. What should I do if the current logical volume space is insufficient?
Don't worry. LVM provides a logical volume expansion method. We can use the lvextend command to implement it.
Before resizing a logical volume, let's take a look at the current logical volume/dev/vg1/data size, as shown below:
We can set the logical volume/dev/vg1/data to 500 mb and resize it now. Scale to 800 mb and run the lvextend command as follows:
Lvextend-l 800 m/dev/vg1/Data
Note that the size of the logical volume after expansion must be smaller than that of the volume group.
After resizing, run the DF command to view the/testlvm directory size, as shown below:
We found that although the logical volume has been expanded. However, logical volumes indicate that the mounted partitions are not resized.
In fact, we only need to execute the Code with resize2fs, as shown below:
Resize2fs/dev/vg1/Data
The above is logical volume expansion. Next we will resize the volume group.
You can use the vgextend command to resize a volume group.
Before resizing the volume group, let's first check the size of the volume group space, as shown below:
We can see that the current size of the volume group vg1 is 1000 MB, and now we resize it by 1000 MB.
It is relatively simple to expand a volume group. We only need to add the new PV physical volume to the volume group.
View the physical volume space as follows:
DF-H/dev/sda6
View the volume group space
Use the vgextend command for volume group expansion, as shown below:
Vgextend vg1/dev/sda6
View the expanded volume group space as follows:
With the above operations, we can easily resize logical volumes and volume groups.