vgimportclone
Import cloned Volume Group without conflicts
SYNOPSIS
vgimportclone [OPTIONS] PhysicalVolumePath [PhysicalVolumePath...]
PARAMETERS
PhysicalVolumePath
The path(s) to the physical volume(s) that belong to the cloned Volume Group (e.g., /dev/sdb, /dev/mapper/mpatha).
-n
Specifies a new name for the imported Volume Group. This is highly recommended to avoid naming conflicts if the original VG name is already present or desired to be different.
--force
Proceeds with the operation without requiring interactive confirmation, overriding some warnings. Use with extreme caution.
--basevg
When used with -n, this option allows specifying an original VG name, and the new VG name will be derived from it (e.g., original_vg_new).
--nouuidcheck
Skips the check for UUID uniqueness. Use with extreme caution, as this can lead to UUID conflicts if not properly managed, potentially corrupting metadata.
--restorefile
Imports the Volume Group using metadata from a specified backup file instead of directly from the PVs. Useful for recovering from metadata corruption or specific scenarios.
DESCRIPTION
vgimportclone is a crucial LVM utility designed to handle situations where LVM Volume Groups (VGs) have been duplicated, typically through disk imaging or virtual machine cloning. When a disk containing an LVM VG is cloned, the resulting copy will have an identical VG Unique Identifier (UUID) to the original. If both the original and the cloned disks are presented to the same system, this UUID conflict can prevent the system from properly activating or distinguishing between the VGs, potentially leading to data corruption or inaccessible logical volumes.
The primary function of vgimportclone is to scan the specified Physical Volumes (PVs) for LVM metadata, detect duplicated VG UUIDs, and then assign a new, unique UUID to the cloned Volume Group. It also provides options to rename the VG during the import process, ensuring that the cloned VG can coexist with the original or be independently managed on the system. This command is indispensable for maintaining LVM integrity in complex storage environments.
CAVEATS
Using vgimportclone incorrectly can lead to irreversible data loss or corruption. Always ensure you are targeting the correct physical volumes. It is highly recommended to perform an LVM metadata backup (e.g., using vgcfgbackup) before running this command. If the original Volume Group is still active and accessible on the system, ensure it is deactivated or exported before attempting to import a cloned VG with the same UUID to prevent conflicts and potential data integrity issues.
TYPICAL USAGE SCENARIO
A common use case involves cloning a virtual machine disk. When the cloned VM is started, its disk's LVM Volume Group will have the same UUID as the original. If both VMs are running on the same host or you're trying to attach the cloned disk to another system, vgimportclone is used to resolve this conflict. The general steps are:
1. Attach the cloned physical disk(s) to the system.
2. Run pvscan and vgscan; you might see warnings about duplicate UUIDs.
3. Execute vgimportclone, specifying the cloned PVs and a new VG name: vgimportclone -n
4. After successful import, the new VG can be activated: vgchange -ay
5. The logical volumes can then be mounted.
HISTORY
vgimportclone is an integral part of the LVM2 suite, which represents the second generation of Linux Logical Volume Manager. LVM2, introduced to improve upon LVM1, brought significant enhancements in metadata handling, scalability, and robustness. The inclusion of commands like vgimportclone addresses complex scenarios such as disk cloning and migration, providing tools to manage LVM metadata conflicts that were less straightforward in earlier versions. Its development reflects the increasing need for flexible and resilient storage management in virtualized and cloud environments.