5.4.14. 增大逻辑卷


要增大逻辑卷的大小,请使用 lvextend 命令。
当您扩展逻辑卷时,您可以指定您想要增大的量,或者在您扩展它之后,它应该是多大。
下面的命令将逻辑卷 /dev/myvg/homevol 增大到 12GB。
# 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
Copy to Clipboard Toggle word wrap
下面的命令为逻辑卷 /dev/myvg/homevol 添加了另一个 GB。
# 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
Copy to Clipboard Toggle word wrap
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
  Extending logical volume testlv to 68.59 GB
  Logical volume testlv successfully resized
Copy to Clipboard Toggle word wrap
在您扩展完逻辑卷后,有必要增大文件系统的大小与之进行匹配。
在默认情况下,大多数重新定义文件系统大小的工具都会将文件系统的大小增加到基本逻辑卷的大小,这样您就不必担心为两个命令指定相同的容量了。

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
  VG   #PV #LV #SN Attr   VSize   VFree
  vg     2   0   0 wz--n- 271.31G 271.31G
Copy to Clipboard Toggle word wrap
您可以使用整个卷组空间创建一个条带。
# lvcreate -n stripe1 -L 271.31G -i 2 vg
  Using default stripesize 64.00 KB
  Rounding up size to full physical extent 271.31 GB
  Logical volume "stripe1" created
# lvs -a -o +devices
  LV      VG   Attr   LSize   Origin Snap%  Move Log Copy%  Devices
  stripe1 vg   -wi-a- 271.31G                               /dev/sda1(0),/dev/sdb1(0)
Copy to Clipboard Toggle word wrap
注意:那个卷组中已经没有剩余空间了。
# vgs
  VG   #PV #LV #SN Attr   VSize   VFree
  vg     2   1   0 wz--n- 271.31G    0
Copy to Clipboard Toggle word wrap
下面的命令在卷组中添加了另一个物理卷,那么就有了 135G 的额外空间。
# vgextend vg /dev/sdc1
  Volume group "vg" successfully extended
# vgs
  VG   #PV #LV #SN Attr   VSize   VFree
  vg     3   1   0 wz--n- 406.97G 135.66G
Copy to Clipboard Toggle word wrap
此时您不能扩展条状逻辑卷来充满卷组,因为需要两个基本设备来将数据按条状保存。
# lvextend vg/stripe1 -L 406G
  Using stripesize of last segment 64.00 KB
  Extending logical volume stripe1 to 406.00 GB
  Insufficient suitable allocatable extents for logical volume stripe1: 34480 
more required
Copy to Clipboard Toggle word wrap
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.
# vgextend vg /dev/sdd1
  Volume group "vg" successfully extended
# vgs
  VG   #PV #LV #SN Attr   VSize   VFree
  vg     4   1   0 wz--n- 542.62G 271.31G
# lvextend vg/stripe1 -L 542G
  Using stripesize of last segment 64.00 KB
  Extending logical volume stripe1 to 542.00 GB
  Logical volume stripe1 successfully resized
Copy to Clipboard Toggle word wrap
如果您没有足够的基本物理设备来扩展条状逻辑卷,那么在扩展不是条状的情况下也可能扩大卷,但可能导致性能不平衡。当为逻辑卷添加空间时,默认操作是使用与现有逻辑卷最新片段相同的条状参数,但您可覆盖那些参数。下面的例子是在启动 lvextend 命令失败后,使用剩余的可用空间扩大了条状逻辑卷。
# lvextend vg/stripe1 -L 406G
  Using stripesize of last segment 64.00 KB
  Extending logical volume stripe1 to 406.00 GB
  Insufficient suitable allocatable extents for logical volume stripe1: 34480 
more required
# lvextend -i1 -l+100%FREE vg/stripe1
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat