ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Lvconvert—将逻辑卷从线性转换为镜像或快照

2022-09-10 13:01:13  阅读:171  来源: 互联网

标签:快照 -- vg00 logical volume Lvconvert mirror 镜像 lvconvert


 

摘要

lvconvert -m|--mirrors Mirrors [--mirrorlog {disk|core|mirrored}] [--corelog] [-R|--regionsize MirrorLogRegionSize] [--type SegmentType] [-A|--alloc AllocationPolicy] [-b|--background] [-f|--force] [-i|--interval Seconds] [-h|-?|--help] [--stripes Stripes [-I|--stripesize StripeSize]] [--noudevsync] [-v|--verbose] [-y|--yes] [--versionLogicalVolume[Path] [PhysicalVolume[Path][:PE[-PE]]...]

lvconvert --splitmirrors Images [--name SplitLogicalVolumeName] [--trackchanges] MirrorLogicalVolume[Path] [SplittablePhysicalVolume[Path][:PE[-PE]]...]

lvconvert -s|--snapshot [-c|--chunksize ChunkSize[bBsSkK]] [-h|-?|--help] [--noudevsync] [-v|--verbose] [-Z|--zero {y|n}] [--versionOriginalLogicalVolume[PathSnapshotLogicalVolume[Path]

lvconvert --merge [-b|--background] [-i|--interval Seconds] [-h|-?|--help] [-v|--verbose] [--versionLogicalVolume[Path]...

lvconvert --repair [-h|-?|--help] [-v|--verbose] [--versionLogicalVolume[Path] [PhysicalVolume[Path]...]

lvconvert --replace PhysicalVolume [-h|-?|--help] [-v|--verbose] [--version] LogicalVolume[Path] [PhysicalVolume[Path]...]

lvconvert --thinpool ThinPoolLogicalVolume{Name|Path} [-c|--chunksize ChunkSize[bBsSkKmMgG]] [--discards {ignore|nopassdown|passdown}] [[--poolmetadata ThinPoolMetadataLogicalVolume{Name|Path}] | [--poolmetadatasize ThinPoolMetadataSize[bBsSkKmMgG]] [-r|--readahead {ReadAheadSectors|auto|none}] [--stripes Stripes [-I|--stripesize StripeSize]]] [-Z|--zero {y|n}] [-h|-?|--help] [-v|--verbose] [--version] [PhysicalVolume[Path][:PE[-PE]]...]

 

Lvconvert用于改变逻辑卷的段类型(如线性、镜像等)或特性。例如,它可以添加或删除逻辑卷的冗余映像、更改镜像的日志类型或将逻辑卷指定为快照存储库。 如果转换需要分配物理区段(例如,从线性转换到镜像时),并且指定一个或多个physicalvolume(可选地指定物理区段范围),则物理区段的分配将被限制在这些物理区段上。如果转换释放物理区段(例如,从镜像转换为线性或减少镜像分支时),并且指定一个或多个physicalvolume,则释放的区段首先来自指定的physicalvolume

 

选项

See lvm(8) for common options.
Exactly one of --merge--mirrors--repair--replace , --snapshot--splitmirrors or --thinpool arguments is required.

-m--mirrors Mirrors
Specifies the degree of the mirror you wish to create. For example, "-m 1" would convert the original logical volume to a mirror volume with 2-sides; that is, a linear volume plus one copy.
--mirrorlog {disk|core|mirrored}
Specifies the type of log to use. The default is disk, which is persistent and requires a small amount of storage space, usually on a separate device from the data being mirrored. Core may be useful for short-lived mirrors: It means the mirror is regenerated by copying the data from the first device again every time the device is activated - perhaps, for example, after every reboot. Using "mirrored" will create a persistent log that is itself mirrored.
--corelog
The optional argument --corelog is the same as specifying --mirrorlog core.
-R--regionsize MirrorLogRegionSize
A mirror is divided into regions of this size (in MB), and the mirror log uses this granularity to track which regions are in sync.
--type SegmentType
Used to convert a logical volume to another segment type or to explicitly state the desired RAID1 segment type (mirror or raid1) when converting a linear logical volume to a mirror with the -m argument.
-b--background
Run the daemon in the background.
-i--interval Seconds
Report progress as a percentage at regular intervals.
--noudevsync
Disable udev synchronisation. The process will not wait for notification from udev. It will continue irrespective of any possible udev processing in the background. You should only use this if udev is not running or has rules that ignore the devices LVM2 creates.
--splitmirrors Images
The number of redundant Images of a mirror to be split off and used to form a new logical volume. A name must be supplied for the newly-split-off logical volume using the --name argument, unless the --trackchanges argument is given.
-n Name
The name to apply to a logical volume which has been split off from a mirror logical volume.
--trackchanges
Used with --splitmirrors on a raid1 device, this tracks changes so that the read-only detached image can be merged efficiently back into the mirror later. Only the regions of the detatched device where the data changed get resynchronized.

Please note that this feature is only supported with the new md-based mirror implementation and not with the original device-mapper mirror implementation.

-s, --snapshot
Create a snapshot from existing logical volume using another existing logical volume as its origin.
-c--chunksize ChunkSize[bBsSkKmMgG]
Gives the size of chunk for snapshot and thin pool logical volumes. For snapshots the value must be power of 2 between 4KiB and 512KiB and the default value is 4. For thin pools the value must be between 64KiB and 1GiB and the default value starts with 64 and scales up to fit the pool metadata size within 128MB, if the pool metadata size is not specified. Older dm thin pool target version (<1.4) requires the value to be power of 2. The newer version requires to be the multiple of 64KiB, however discard is not supported for non power of 2 values. Default unit is in kilobytes.
--discards {ignore|nopassdown|passdown}
Sets discards behavior for thin pool. Default is passdown.
-Z--zero {y|n}
Controls zeroing of the first KB of data in the snapshot. If the volume is read-only the snapshot will not be zeroed. For thin pool volumes it controls zeroing of provisioned blocks. Note: Provisioning of large zeroed chunks impacts performance.
--merge
Merges a snapshot into its origin volume or merges a raid1 image that has been split from its mirror with --trackchanges back into its mirror.

To check if your kernel supports the snapshot merge feature, look for 'snapshot-merge' in the output of dmsetup targets. If both the origin and snapshot volume are not open the merge will start immediately. Otherwise, the merge will start the first time either the origin or snapshot are activated and both are closed. Merging a snapshot into an origin that cannot be closed, for example a root filesystem, is deferred until the next time the origin volume is activated. When merging starts, the resulting logical volume will have the origin's name, minor number and UUID. While the merge is in progress, reads or writes to the origin appear as they were directed to the snapshot being merged. When the merge finishes, the merged snapshot is removed. Multiple snapshots may be specified on the commandline or a @tag may be used to specify multiple snapshots be merged to their respective origin.

--poolmetadata ThinPoolMetadataLogicalVolume{Name|Path}
Specifies thin pool metadata logical volume. The size should be in between 2MiB and 16GiB. Thin pool is specified with the option --thinpool. When the specified thin pool already exists, the thin pool's metadata volume will be swapped with the given LV. Properties of the thin pool like chunk size, discards or zero are preserved by default in this case. It can be useful for thin pool metadata repair or its offline resize, since the content of metadata becomes accessible for thin provisioning tools thin_dump(8) and thin_restore(8).
--poolmetadatasize ThinPoolMetadataSize[bBsSkKmMgG]
Sets the size of thin pool's metadata logical volume, if the pool metadata volume is undefined. Thin pool is specified with the option --thinpool. Supported value is in the range between 2MiB and 16GiB. The default value is estimated with this formula (Pool_LV_size / Pool_LV_chunk_size * 64b). Default unit is megabytes.
-r--readahead {ReadAheadSectors|auto|none}
Sets read ahead sector count of thin pool metadata logical volume. The default value is "auto" which allows the kernel to choose a suitable value automatically. "None" is equivalent to specifying zero.
--repair
Repair a mirror after suffering a disk failure. The mirror will be brought back into a consistent state. By default, the original number of mirrors will be restored if possible. Specify -y on the command line to skip the prompts. Use -f if you do not want any replacement. Additionally, you may use --use-policies to use the device replacement policy specified in lvm.conf(5), viz. activation/mirror_log_fault_policy or activation/mirror_device_fault_policy.
--replace PhysicalVolume
Remove the specified device (PhysicalVolume) and replace it with one that is available in the volume group or from the specific list provided. This option is only available to RAID segment types (e.g. "raid1", "raid5", etc).
--stripes Stripes
Gives the number of stripes. This is equal to the number of physical volumes to scatter the logical volume.
-I--stripesize StripeSize
Gives the number of kilobytes for the granularity of the stripes.
StripeSize must be 2^n (n = 2 to 9) for metadata in LVM1 format. For metadata in LVM2 format, the stripe size may be a larger power of 2 but must not exceed the physical extent size.
--thinpool ThinPoolLogicalVolume{Name|Path}
Changes logical volume into a thin pool volume. The volume will store the pool's data. Thin pool metadata logical volume can be specified with the option --poolmetadata or allocated with --poolmetadatasize.

Examples

Converts the linear logical volume "vg00/lvol1" to a two-way mirror logical volume:

lvconvert -m1 vg00/lvol1

Converts the linear logical volume "vg00/lvol1" to a two-way RAID1 logical volume:

lvconvert --type raid1 -m1 vg00/lvol1

Converts a mirror with a disk log to a mirror with an in-memory log:

lvconvert --mirrorlog

core vg00/lvol1

Converts a mirror with an in-memory log to a mirror with a disk log:

lvconvert --mirrorlog disk vg00/lvol1

Converts a mirror logical volume to a linear logical volume:

lvconvert -m0 vg00/lvol1

Converts a mirror logical volume to a RAID1 logical volume with the same number of images:

lvconvert --type raid1 vg00/mirror_lv

Converts logical volume "vg00/lvol2" to snapshot of original volume "vg00/lvol1":

lvconvert -s vg00/lvol1 vg00/lvol2

Converts linear logical volume "vg00/lvol1" to a two-way mirror, using physical extents /dev/sda:0-15 and /dev/sdb:0-15 for allocation of new extents:

lvconvert -m1 vg00/lvol1 /dev/sda:0-15 /dev/sdb:0-15

Converts mirror logical volume "vg00/lvmirror1" to linear, freeing physical extents from /dev/sda:

lvconvert -m0 vg00/lvmirror1 /dev/sda

Merges "vg00/lvol1_snap" into its origin:

lvconvert --merge vg00/lvol1_snap

If "vg00/lvol1", "vg00/lvol2" and "vg00/lvol3" are all tagged with "some_tag" each snapshot logical volume will be merged serially, e.g.: "vg00/lvol1", then "vg00/lvol2", then "vg00/lvol3". If --background were used it would start all snapshot logical volume merges in parallel.

lvconvert --merge @some_tag

Extracts one image from the mirror, making it a new logical volume named "lv_split". The mirror the image is extracted from is reduced accordingly. If it was a 2-way mirror (created with '-m 1'), then the resulting original volume will be linear.

lvconvert

-

-

splitmirrors 1 --name lv_split vg00/lvmirror1

A mirrored logical volume created with --type raid1 can use the --trackchanges argument when splitting off an image. Detach one image from the mirrored logical volume lv_raid1 as a separate read-only device and track the changes made to the mirror while it is detached. The split-off device has a name of the form lv_raid1_rimage_N, where N is a number, and it cannot be renamed.

lvconvert --splitmirrors 1

-

-

trackchanges vg00/lv_raid1

Merge an image that was detached temporarily from its mirror with the --trackchanges argument back into its original mirror and bring its contents back up-to-date.

lvconvert --merge vg00/lv_raid1_rimage_1

Replaces the physical volume "/dev/sdb1" in the RAID1 logical volume "my_raid1" with the specified physical volume "/dev/sdf1". Had the argument "/dev/sdf1" been left out, lvconvert would attempt to find a suitable device from those available in the volume group.

lvconvert --replace /dev/sdb1 vg00/my_raid1

/dev/sdf1

标签:快照,--,vg00,logical,volume,Lvconvert,mirror,镜像,lvconvert
来源: https://www.cnblogs.com/chencantian/p/16676304.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有