卷组配置备份
root@king:~# vgcfgbackup --help
vgcfgbackup: Backup volume group configuration(s)
vgcfgbackup
[-d|--debug]
[-f|--file filename]
[-h|-?|--help]
[--ignorelockingfailure]
[-P|--partial]
[-v|--verbose]
[--version]
[VolumeGroupName...]
#备份卷组的元数据,如果不指定卷组,那么将备份全部。备份将生成文件到/etc/lvm/backup,也可以用-f指定文件。
卷组配置恢复
root@king:~# vgcfgrestore --help
vgcfgrestore: Restore volume group configuration
vgcfgrestore
[-d|--debug]
[-f|--file filename]
[-l[l]|--list [--list]]
[-M|--metadatatype 1|2] #元数据类型lvm1或者lvm2
[-h|--help]
[-t|--test]
[-v|--verbose]
[--version]
VolumeGroupName
# 从文件中恢复卷组
root@king:/etc/lvm/backup# vgdisplay --partial --verbose
#显示缺失的PV的大小和UUID。
root@king:/etc/lvm/backup#pvcreate --restorefile filename --uuid uuid
#创建PV利用restorefile中的指定UUID。
创建卷组
root@king:~# vgcreate --help
vgcreate: Create a volume group
vgcreate
[-A|--autobackup {y|n}]
[--addtag Tag]
[--alloc AllocationPolicy]
[-c|--clustered {y|n}] #在集群上其它节点可见
[-d|--debug]
[-h|--help]
[-l|--maxlogicalvolumes MaxLogicalVolumes] #卷组内逻辑卷最大数目,可有vgchange修改。LVM1最大255,LVM2默认为0,即没有限制。
[-M|--metadatatype 1|2] #元数据格式类型LVM1,LVM2
[--[vg]metadatacopies #copies] #卷组内元数据拷贝份数
[-p|--maxphysicalvolumes MaxPhysicalVolumes] #卷组内物理卷最大数据,
[-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE]] #卷组内物理卷物理块大小,默认4MB,最小1KB
[-t|--test]
[-v|--verbose]
[--version]
[ PHYSICAL DEVICE OPTIONS ]
VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]
# 内核2.4最大块设备大小2TB。LVM1最大PE256GB。
删除卷组
root@king:~# vgremove --help
vgremove: Remove volume group(s)
vgremove
[-d|--debug]
[-f|--force]
[-h|--help]
[--noudevsync] #禁用udev同步,进程将不等待udev的通知。
[-t|--test]
[-v|--verbose]
[--version]
VolumeGroupName [VolumeGroupName...]
修改卷组
root@king:~# vgchange --help
vgchange: Change volume group attributes
vgchange
[-A|--autobackup {y|n}] #元数据修改后,自动备份元数据
[--alloc AllocationPolicy] #控制卷组内的逻辑卷是否可以输入输出,或者说是内核是否能看到逻辑卷。
[-P|--partial]
[-d|--debug]
[-h|--help]
[--ignorelockingfailure]
[--ignoremonitoring]
[--monitor {y|n}]
[--[vg]metadatacopies #copies]
[--poll {y|n}] #y,重启崩溃之前的pvmove和lvconvert。
[--noudevsync]
[--refresh]
[--sysinit] #声明命令是系统初始化时调用的
[-t|--test]
[-u|--uuid]
[-v|--verbose]
[--version]
{-a|--activate [a|e|l]{y|n} | #激活
-c|--clustered {y|n} | #集群
-x|--resizeable {y|n} | #禁用扩展和缩减
-l|--logicalvolume MaxLogicalVolumes | #最大逻辑卷数
-p|--maxphysicalvolumes MaxPhysicalVolumes | #物理卷限制
-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE] | #物理块大小
--addtag Tag |
--deltag Tag}
[VolumeGroupName...]
#卷组改名
root@king:~# vgrename --help
vgrename: Rename a volume group
vgrename
[-A|--autobackup y|n]
[-d|--debug]
[-h|--help]
[-t|--test]
[-v|--verbose]
[--version]
OldVolumeGroupPath NewVolumeGroupPath |
OldVolumeGroupName NewVolumeGroupName
卷组转换
root@king:~# vgconvert --help
vgconvert: Change volume group metadata format
vgconvert
[-d|--debug]
[-h|--help]
[--labelsector sector]
[-M|--metadatatype 1|2] #元数据格式LVM1,LVM2
[--pvmetadatacopies #copies]
[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]
[-t|--test]
[-v|--verbose]
[--version]
VolumeGroupName [VolumeGroupName...]
显示卷组信息
root@king:~# vgdisplay --help
vgdisplay: Display volume group information
vgdisplay
[-A|--activevolumegroups]
[-c|--colon | -s|--short | -v|--verbose] #显示卷组信息-c 多列,-s简写
[-d|--debug]
[-h|--help]
[--ignorelockingfailure]
[--nosuffix]
[-P|--partial]
[--units hHbBsSkKmMgGtTpPeE]
[--version]
[VolumeGroupName [VolumeGroupName...]]
vgdisplay --columns|-C
[--aligned]
[-d|--debug]
[-h|--help]
[--ignorelockingfailure]
[--noheadings]
[--nosuffix]
[-o|--options [+]Field[,Field]]
[-O|--sort [+|-]key1[,[+|-]key2[,...]]]
[-P|--partial]
[--separator Separator]
[--unbuffered]
[--units hHbBsSkKmMgGtTpPeE]
[--verbose]
[--version]
[VolumeGroupName [VolumeGroupName...]]
扩展卷组
#新增物理卷到卷组
root@king:~# vgextend --help
vgextend: Add physical volumes to a volume group
vgextend
[-A|--autobackup y|n]
[--restoremissing] #增加之前丢失的物理卷PV
[-d|--debug]
[-f|--force]
[-h|--help]
[-t|--test]
[-v|--verbose]
[--version]
[ PHYSICAL DEVICE OPTIONS ]
VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]
缩减卷组
#从卷组中移除物理卷
root@king:~# vgreduce --help
vgreduce: Remove physical volume(s) from a volume group
vgreduce
[-a|--all]
[-A|--autobackup y|n]
[-d|--debug]
[-h|--help]
[--mirrorsonly]
[--removemissing]
[-f|--force]
[-t|--test]
[-v|--verbose]
[--version]
VolumeGroupName
[PhysicalVolumePath...]
vgexport vgimport
#修改系统是否可以见卷组
root@king:~# vgexport --help
vgexport: Unregister volume group(s) from the system
vgexport
[-a|--all]
[-d|--debug]
[-h|--help]
[-v|--verbose]
[--version]
VolumeGroupName [VolumeGroupName...]
root@king:~# vgimport --help
vgimport: Register exported volume group with system
vgimport
[-a|--all]
[-d|--debug]
[-f|--force]
[-h|--help]
[-t|--test]
[-v|--verbose]
[--version]
VolumeGroupName...
合并两个卷组
root@king:~# vgmerge --help
vgmerge: Merge volume groups
vgmerge
[-A|--autobackup y|n]
[-d|--debug]
[-h|--help]
[-l|--list]
[-t|--test]
[-v|--verbose]
[--version]
DestinationVolumeGroupName SourceVolumeGroupName
# 将后一个卷组合并到第二个卷组
拆分卷组
root@king:~# vgsplit --help
vgsplit: Move physical volumes into a new or existing volume group
vgsplit
[-A|--autobackup {y|n}]
[--alloc AllocationPolicy]
[-c|--clustered {y|n}]
[-d|--debug]
[-h|--help]
[-l|--maxlogicalvolumes MaxLogicalVolumes]
[-M|--metadatatype 1|2]
[--[vg]metadatacopies #copies]
[-n|--name LogicalVolumeName]
[-p|--maxphysicalvolumes MaxPhysicalVolumes]
[-t|--test]
[-v|--verbose]
[--version]
SourceVolumeGroupName DestinationVolumeGroupName
[PhysicalVolumePath...]
移动一个或者多个物理卷从源卷组到目的卷组。可以通过指定物理卷路径或者指定逻辑卷名称,指定逻辑卷那么该逻辑卷下的物理卷才会移动。如果目的卷组不存在,一个新的卷组将被创建。
如果目的卷组存在会检查源卷组容量,目的卷组有操作,拆分将不会发生。
逻辑卷不会分布于多个卷组,操作只会移动整个物理卷。split可能会失败,如果会导致一个逻辑卷分布于多个卷组。
扫描卷组
root@king:~# vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg_2" using metadata type lvm2
Found volume group "vg_1" using metadata type lvm2
#扫描物理卷,获取卷组信息。