搜索

第 4 章 用​​​​​​​ CLI 命​​​​​​​令​​​​​​​管​​​​​​​理​​​​​​​ LVM

download PDF
本​​​​​​​章​​​​​​​总​​​​​​​结​​​​​​​了​​​​​​​您​​​​​​​可​​​​​​​使​​​​​​​用​​​​​​​ 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 see 第 3.1 节 “在​​​​​​​群​​​​​​​集​​​​​​​中​​​​​​​创​​​​​​​建​​​​​​​ LVM 卷​​​​​​​”.

4.1. 使​​​​​​​用​​​​​​​ CLI 命​​​​​​​令​​​​​​​

LVM CLI 命​​​​​​​令​​​​​​​有​​​​​​​一​​​​​​​些​​​​​​​通​​​​​​​用​​​​​​​的​​​​​​​特​​​​​​​性​​​​​​​。​​​​​​​
当​​​​​​​在​​​​​​​命​​​​​​​令​​​​​​​行​​​​​​​中​​​​​​​需​​​​​​​要​​​​​​​容​​​​​​​量​​​​​​​参​​​​​​​数​​​​​​​时​​​​​​​,可​​​​​​​以​​​​​​​明​​​​​​​确​​​​​​​指​​​​​​​定​​​​​​​单​​​​​​​位​​​​​​​。​​​​​​​如​​​​​​​果​​​​​​​您​​​​​​​不​​​​​​​指​​​​​​​定​​​​​​​单​​​​​​​位​​​​​​​,那​​​​​​​么​​​​​​​就​​​​​​​使​​​​​​​用​​​​​​​默​​​​​​​认​​​​​​​的​​​​​​​ KB 或​​​​​​​者​​​​​​​ MB。​​​​​​​LVM CLI 不​​​​​​​接​​​​​​​受​​​​​​​分​​​​​​​数​​​​​​​。​​​​​​​
在​​​​​​​命​​​​​​​令​​​​​​​行​​​​​​​参​​​​​​​数​​​​​​​中​​​​​​​为​​​​​​​ LVM 指​​​​​​​定​​​​​​​单​​​​​​​位​​​​​​​时​​​​​​​要​​​​​​​无​​​​​​​需​​​​​​​区​​​​​​​分​​​​​​​大​​​​​​​小​​​​​​​写​​​​​​​,比​​​​​​​如​​​​​​​ M 或​​​​​​​者​​​​​​​ m 的​​​​​​​效​​​​​​​果​​​​​​​是​​​​​​​一​​​​​​​样​​​​​​​的​​​​​​​,且​​​​​​​使​​​​​​​用​​​​​​​ 2 的​​​​​​​乘​​​​​​​方​​​​​​​(乘​​​​​​​ 1024)。​​​​​​​但​​​​​​​是​​​​​​​,在​​​​​​​某​​​​​​​个​​​​​​​命​​​​​​​令​​​​​​​中​​​​​​​指​​​​​​​定​​​​​​​ --units 参​​​​​​​数​​​​​​​时​​​​​​​,小​​​​​​​写​​​​​​​表​​​​​​​示​​​​​​​该​​​​​​​单​​​​​​​位​​​​​​​乘​​​​​​​ 1024,而​​​​​​​大​​​​​​​写​​​​​​​表​​​​​​​示​​​​​​​该​​​​​​​单​​​​​​​位​​​​​​​乘​​​​​​​ 1000。​​​​​​​
在​​​​​​​命​​​​​​​令​​​​​​​使​​​​​​​用​​​​​​​卷​​​​​​​组​​​​​​​或​​​​​​​者​​​​​​​逻​​​​​​​辑​​​​​​​卷​​​​​​​名​​​​​​​称​​​​​​​作​​​​​​​为​​​​​​​参​​​​​​​数​​​​​​​时​​​​​​​,完​​​​​​​整​​​​​​​路​​​​​​​径​​​​​​​名​​​​​​​称​​​​​​​是​​​​​​​可​​​​​​​选​​​​​​​项​​​​​​​。​​​​​​​卷​​​​​​​组​​​​​​​ vg0 中​​​​​​​的​​​​​​​逻​​​​​​​辑​​​​​​​卷​​​​​​​ lvol0 可​​​​​​​被​​​​​​​指​​​​​​​定​​​​​​​为​​​​​​​ vg0/lvol0。​​​​​​​如​​​​​​​果​​​​​​​空​​​​​​​置​​​​​​​需​​​​​​​要​​​​​​​指​​​​​​​定​​​​​​​卷​​​​​​​组​​​​​​​的​​​​​​​地​​​​​​​方​​​​​​​,就​​​​​​​会​​​​​​​代​​​​​​​入​​​​​​​所​​​​​​​有​​​​​​​列​​​​​​​出​​​​​​​的​​​​​​​卷​​​​​​​组​​​​​​​。​​​​​​​在​​​​​​​需​​​​​​​要​​​​​​​指​​​​​​​定​​​​​​​一​​​​​​​组​​​​​​​逻​​​​​​​辑​​​​​​​卷​​​​​​​的​​​​​​​地​​​​​​​方​​​​​​​给​​​​​​​出​​​​​​​了​​​​​​​卷​​​​​​​组​​​​​​​,就​​​​​​​会​​​​​​​代​​​​​​​入​​​​​​​那​​​​​​​个​​​​​​​卷​​​​​​​组​​​​​​​中​​​​​​​的​​​​​​​列​​​​​​​出​​​​​​​的​​​​​​​逻​​​​​​​辑​​​​​​​卷​​​​​​​。​​​​​​​例​​​​​​​如​​​​​​​:lvdisplay vg0 命​​​​​​​令​​​​​​​将​​​​​​​显​​​​​​​示​​​​​​​卷​​​​​​​组​​​​​​​ vg0 中​​​​​​​的​​​​​​​所​​​​​​​有​​​​​​​逻​​​​​​​辑​​​​​​​卷​​​​​​​。​​​​​​​
所​​​​​​​有​​​​​​​ LVM 命​​​​​​​令​​​​​​​都​​​​​​​接​​​​​​​受​​​​​​​ -v 参​​​​​​​数​​​​​​​,它​​​​​​​可​​​​​​​多​​​​​​​次​​​​​​​输​​​​​​​入​​​​​​​来​​​​​​​提​​​​​​​高​​​​​​​输​​​​​​​出​​​​​​​的​​​​​​​详​​​​​​​细​​​​​​​程​​​​​​​度​​​​​​​。​​​​​​​例​​​​​​​如​​​​​​​:以​​​​​​​下​​​​​​​示​​​​​​​例​​​​​​​显​​​​​​​示​​​​​​​的​​​​​​​是​​​​​​​ lvcreate 命​​​​​​​令​​​​​​​的​​​​​​​默​​​​​​​认​​​​​​​输​​​​​​​出​​​​​​​。​​​​​​​
# lvcreate -L 50MB new_vg
  Rounding up size to full physical extent 52.00 MB
  Logical volume "lvol0" created
下​​​​​​​面​​​​​​​是​​​​​​​ 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
您​​​​​​​还​​​​​​​可​​​​​​​以​​​​​​​使​​​​​​​用​​​​​​​ -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
...
您​​​​​​​可​​​​​​​以​​​​​​​用​​​​​​​命​​​​​​​令​​​​​​​的​​​​​​​ --help 参​​​​​​​数​​​​​​​来​​​​​​​显​​​​​​​示​​​​​​​任​​​​​​​意​​​​​​​ LVM CLI 命​​​​​​​令​​​​​​​的​​​​​​​帮​​​​​​​助​​​​​​​信​​​​​​​息​​​​​​​。​​​​​​​
commandname --help
要​​​​​​​显​​​​​​​示​​​​​​​某​​​​​​​个​​​​​​​命​​​​​​​令​​​​​​​的​​​​​​​ man page,请​​​​​​​执​​​​​​​行​​​​​​​ man 命​​​​​​​令​​​​​​​:
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 see 第 6.4 节 “修​​​​​​​复​​​​​​​物​​​​​​​理​​​​​​​卷​​​​​​​元​​​​​​​数​​​​​​​据​​​​​​​”.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.