第 5 章 用 CLI 命令管理 LVM


本章总结了您可使用 LVM 命令行界面(CLI)来创建和维护逻辑卷的独立管理任务。

注意

If you are creating or modifying an LVM volume for a clustered environment, you must ensure that you are running the clvmd daemon. For information, see 第 4.1 节 “在群集中创建 LVM 卷”.

5.1. 使用 CLI 命令

LVM CLI 命令有一些通用的特性。
当在命令行中需要容量参数时,可以明确指定单位。如果您不指定单位,那么就使用默认的 KB 或者 MB。LVM CLI 不接受分数。
在命令行参数中为 LVM 指定单位时要无需区分大小写,比如 M 或者 m 的效果是一样的,且使用 2 的乘方(乘 1024)。但是,在某个命令中指定 --units 参数时,小写表示该单位乘 1024,而大写表示该单位乘 1000。
Where commands take volume group or logical volume names as arguments, the full path name is optional. A logical volume called lvol0 in a volume group called vg0 can be specified as vg0/lvol0. Where a list of volume groups is required but is left empty, a list of all volume groups will be substituted. Where a list of logical volumes is required but a volume group is given, a list of all the logical volumes in that volume group will be substituted. For example, the lvdisplay vg0 command will display all the logical volumes in volume group vg0.
所有 LVM 命令都接受 -v 参数,它可多次输入来提高输出的详细程度。例如:以下示例显示的是 lvcreate 命令的默认输出。
# lvcreate -L 50MB new_vg
  Rounding up size to full physical extent 52.00 MB
  Logical volume "lvol0" created
Copy to Clipboard Toggle word wrap
下面是 lvcreate 命令带 -v 参数的输出。
# lvcreate -v -L 50MB new_vg
    Finding volume group "new_vg"
  Rounding up size to full physical extent 52.00 MB
    Archiving volume group "new_vg" metadata (seqno 4).
    Creating logical volume lvol0
    Creating volume group backup "/etc/lvm/backup/new_vg" (seqno 5).
    Found volume group "new_vg"
    Creating new_vg-lvol0
    Loading new_vg-lvol0 table
    Resuming new_vg-lvol0 (253:2)
    Clearing start of logical volume "lvol0"
    Creating volume group backup "/etc/lvm/backup/new_vg" (seqno 5).
  Logical volume "lvol0" created
Copy to Clipboard Toggle word wrap
您还可以使用 -vv-vvv 或者 -vvvv 参数来提高命令执行的详细程度。-vvvv 参数可以提供最多的信息。以下是 lvcreate 命令带 -vvvv 参数时给出的输出的前几行。
# lvcreate -vvvv -L 50MB new_vg
#lvmcmdline.c:913         Processing: lvcreate -vvvv -L 50MB new_vg
#lvmcmdline.c:916         O_DIRECT will be used
#config/config.c:864       Setting global/locking_type to 1
#locking/locking.c:138       File-based locking selected.
#config/config.c:841       Setting global/locking_dir to /var/lock/lvm
#activate/activate.c:358       Getting target version for linear
#ioctl/libdm-iface.c:1569         dm version   OF   [16384]
#ioctl/libdm-iface.c:1569         dm versions   OF   [16384]
#activate/activate.c:358       Getting target version for striped
#ioctl/libdm-iface.c:1569         dm versions   OF   [16384]
#config/config.c:864       Setting activation/mirror_region_size to 512
...
Copy to Clipboard Toggle word wrap
您可以用命令的 --help 参数来显示任意 LVM CLI 命令的帮助信息。
# commandname --help
Copy to Clipboard Toggle word wrap
要显示某个命令的 man page,请执行 man 命令:
# man commandname
Copy to Clipboard Toggle word wrap
man lvm 命令提供有关 LVM 的常规在线信息。
All LVM objects are referenced internally by a UUID, which is assigned when you create the object. This can be useful in a situation where you remove a physical volume called /dev/sdf which is part of a volume group and, when you plug it back in, you find that it is now /dev/sdk. LVM will still find the physical volume because it identifies the physical volume by its UUID and not its device name. For information on specifying the UUID of a physical volume when creating a physical volume, see 第 7.4 节 “修复物理卷元数据”.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat