lvconvert
Convert logical volumes between types
TLDR
Convert a linear logical volume to RAID1 (add one mirror: two copies total)
Remove mirroring and convert back to a linear logical volume
Merge a snapshot back into its origin logical volume (applies on next activation)
Repair a degraded RAID logical volume
Convert an existing logical volume into a thin pool with a separate metadata LV
SYNOPSIS
lvconvert [OPTIONS] LogicalVolume[Path]
Common usages:
lvconvert --type mirror -m <N> LogicalVolumePath
lvconvert --type snapshot -s -n <SnapshotName> OriginLogicalVolumePath
lvconvert --merge SnapshotLogicalVolumePath
lvconvert --type cache --cachepool <CachePoolName> LogicalVolumePath
lvconvert --repair LogicalVolumePath
PARAMETERS
--alloc <Policy>
Specify the allocation policy (e.g., contiguous, anywhere, cluster) for allocating physical extents.
--cachepool <LV_path|LV_name>
Specify an existing cache pool logical volume to convert an LV into a cached volume.
--discards {discard|nopassdown}
Control discard behavior for thin pools, either passing discards down to the underlying physical volume or not.
-m <N>, --mirrors <N>
Convert to a mirrored LV with N additional mirror images. Setting N=0 removes all mirrors.
--merge
Merge a snapshot logical volume back into its origin. The snapshot LV is removed after a successful merge.
-n <Name>, --name <Name>
Specify the name for a new logical volume, typically used when creating a snapshot.
-s, --snapshot
Create a new snapshot of the specified origin logical volume.
--splitmirrors <N>
Split off N images of a mirrored LV to create a new, independent logical volume.
--repair
Repair a mirrored or RAID logical volume that has detected failures (e.g., missing physical volumes).
--thinpool <LV_path|LV_name>
Specify an existing thin pool logical volume for thin LV conversion or management.
--type {mirror|snapshot|cache|thin|raidN}
Specify the target logical volume type for the conversion (e.g., to create a mirror, snapshot, or cache LV).
--yes
Assume 'yes' to all questions; bypasses interactive confirmation prompts.
DESCRIPTION
lvconvert is a crucial utility within the Logical Volume Manager (LVM) framework, designed to alter the characteristics or layout of existing logical volumes (LVs). It empowers system administrators to transform an LV's structure without necessarily affecting its underlying data. Common operations include converting a standard logical volume into a mirrored volume, enabling high availability, or removing mirrors to reclaim physical extents. It's also extensively used for managing snapshots: creating new point-in-time copies of LVs for backup or testing, and subsequently merging these snapshots back into their origin volumes. Furthermore, lvconvert facilitates the integration of caching layers to improve performance, and the management of thin provisioning, allowing for flexible storage allocation. Its versatility makes it indispensable for adapting storage configurations to evolving requirements, ensuring data integrity and optimizing performance within LVM-managed environments.
CAVEATS
Requires sufficient free physical extents in the volume group for operations like adding mirrors or creating snapshots.
Merging snapshots (--merge) can be a lengthy process and may temporarily degrade performance; ensure sufficient system resources.
Incorrect use of lvconvert (e.g., merging the wrong snapshot) can lead to data loss or corruption. Always back up critical data before major LVM operations.
Operations like adding mirrors or converting to cached LVs consume physical storage space.
Repairing mirrored/RAID LVs requires the faulty physical volumes to be addressed or replaced.
COMMON USE CASES
lvconvert is frequently used to transform existing logical volumes. A common scenario is converting a standard logical volume into a mirrored volume to enhance data redundancy and availability, often after the system has been in production. It's also the primary command for managing LVM snapshots, allowing administrators to create point-in-time copies for backup verification or to test software upgrades, and then merge these changes back to the origin or discard them. The command also enables the integration of caching layers to accelerate I/O operations for frequently accessed data on slower storage, or to manage thin provisioning for efficient space utilization.
CONSIDERATIONS FOR PERFORMANCE
When converting LVs to mirrored or cached types, there can be a performance overhead during the initial synchronization or population process. Merging snapshots can also be I/O intensive, impacting system performance until the merge operation is complete. Planning these operations during off-peak hours is often recommended to minimize disruption.
HISTORY
lvconvert is an integral part of the Logical Volume Manager (LVM) version 2 (LVM2) suite, which superseded the original LVM implementation to provide enhanced capabilities and flexibility. LVM2 was developed by Red Hat and its community, aiming to offer a more robust and feature-rich logical volume management system for Linux. lvconvert itself evolved with LVM2 to handle complex LV transformations, moving beyond simple creation and extension to include advanced features like mirroring, snapshots, caching, and thin provisioning, reflecting the growing demands for flexible and dynamic storage management in modern systems.