5.4.14. 增大逻辑卷
要增大逻辑卷的大小,请使用
lvextend 命令。
当您扩展逻辑卷时,您可以指定您想要增大的量,或者在您扩展它之后,它应该是多大。
下面的命令将逻辑卷
/dev/myvg/homevol 增大到 12GB。
lvextend -L12G /dev/myvg/homevol
# lvextend -L12G /dev/myvg/homevol
lvextend -- extending logical volume "/dev/myvg/homevol" to 12 GB
lvextend -- doing automatic backup of volume group "myvg"
lvextend -- logical volume "/dev/myvg/homevol" successfully extended
下面的命令为逻辑卷
/dev/myvg/homevol 添加了另一个 GB。
lvextend -L+1G /dev/myvg/homevol
# lvextend -L+1G /dev/myvg/homevol
lvextend -- extending logical volume "/dev/myvg/homevol" to 13 GB
lvextend -- doing automatic backup of volume group "myvg"
lvextend -- logical volume "/dev/myvg/homevol" successfully extended
As with the
lvcreate command, you can use the -l argument of the lvextend command to specify the number of extents by which to increase the size of the logical volume. You can also use this argument to specify a percentage of the volume group, or a percentage of the remaining free space in the volume group. The following command extends the logical volume called testlv to fill all of the unallocated space in the volume group myvg.
lvextend -l +100%FREE /dev/myvg/testlv
# lvextend -l +100%FREE /dev/myvg/testlv
Extending logical volume testlv to 68.59 GB
Logical volume testlv successfully resized
在您扩展完逻辑卷后,有必要增大文件系统的大小与之进行匹配。
在默认情况下,大多数重新定义文件系统大小的工具都会将文件系统的大小增加到基本逻辑卷的大小,这样您就不必担心为两个命令指定相同的容量了。
5.4.14.1. 扩展条状卷 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
要增加条状逻辑卷的大小,基本物理卷中必须有足够的可用空间,以便让卷组支持它。例如,如果您有一个使用了这个卷组的双向条带,那么在卷组中添加一个物理卷将会使您无法扩展条带,反之,您必须在卷组中添加至少两个物理卷。
For example, consider a volume group
vg that consists of two underlying physical volumes, as displayed with the following vgs command.
vgs
# vgs
VG #PV #LV #SN Attr VSize VFree
vg 2 0 0 wz--n- 271.31G 271.31G
您可以使用整个卷组空间创建一个条带。
注意:那个卷组中已经没有剩余空间了。
vgs
# vgs
VG #PV #LV #SN Attr VSize VFree
vg 2 1 0 wz--n- 271.31G 0
下面的命令在卷组中添加了另一个物理卷,那么就有了 135G 的额外空间。
此时您不能扩展条状逻辑卷来充满卷组,因为需要两个基本设备来将数据按条状保存。
To extend the striped logical volume, add another physical volume and then extend the logical volume. In this example, having added two physical volumes to the volume group we can extend the logical volume to the full size of the volume group.
如果您没有足够的基本物理设备来扩展条状逻辑卷,那么在扩展不是条状的情况下也可能扩大卷,但可能导致性能不平衡。当为逻辑卷添加空间时,默认操作是使用与现有逻辑卷最新片段相同的条状参数,但您可覆盖那些参数。下面的例子是在启动
lvextend 命令失败后,使用剩余的可用空间扩大了条状逻辑卷。