第 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
# lvcreate -L 50MB new_vg
Rounding up size to full physical extent 52.00 MB
Logical volume "lvol0" created
下面是
lvcreate 命令带 -v 参数的输出。
您还可以使用
-vv、-vvv 或者 -vvvv 参数来提高命令执行的详细程度。-vvvv 参数可以提供最多的信息。以下是 lvcreate 命令带 -vvvv 参数时给出的输出的前几行。
您可以用命令的
--help 参数来显示任意 LVM CLI 命令的帮助信息。
commandname --help
# commandname --help
要显示某个命令的 man page,请执行
man 命令:
man commandname
# man commandname
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 节 “修复物理卷元数据”.