Menu Close

Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

章 4. 透​​​​​​​過​​​​​​​ 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 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, “復​​​​​​​原​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​ Metadata”.