vgexport
Make volume group unavailable to the system
SYNOPSIS
vgexport [options] VolumeGroupName...
vgexport -a|--all [options]
PARAMETERS
-a, --all
Exports all volume groups that are currently deactivated.
-p, --partial
Allows export of a volume group even if some of its physical volumes are missing. Use with caution.
-t, --test
Runs the command in test mode, showing what would happen without actually making any changes.
-v, --verbose
Provides more detailed output during command execution.
-h, --help
Displays a help message and exits.
-V, --version
Displays the LVM version information and exits.
VolumeGroupName...
The name(s) of the volume group(s) to be exported. Multiple names can be specified.
DESCRIPTION
The vgexport command is part of the Logical Volume Manager (LVM) suite of utilities. It serves the crucial purpose of making one or more volume groups (VGs) inaccessible and unknown to the operating system. When a volume group is exported, LVM removes its metadata from the kernel's device mapper, effectively unregistering the VG. This action does not delete any data on the physical volumes comprising the volume group; it merely makes the VG unavailable for use by the system.
This command is typically used in scenarios where a volume group needs to be moved from one system to another, or when it needs to be temporarily or permanently removed from the current system's active LVM configuration without destroying the underlying data. Before a volume group can be exported, it is imperative that all its logical volumes are closed and the volume group itself is deactivated (e.g., using vgchange -an VolumeGroupName). Exporting an active volume group is not permitted by LVM to prevent data corruption. After export, the physical volumes belonging to the VG are free to be moved to another system, where they can be re-registered using the vgimport command.
CAVEATS
Before exporting a volume group, ensure that all its logical volumes are unmounted and closed, and the volume group itself is deactivated using vgchange -an VolumeGroupName. Attempting to export an active volume group will result in an error.
vgexport does not delete any data on the physical volumes. It only removes the volume group's metadata from the system's active LVM configuration. The data remains intact on the physical disks.
When dealing with shared storage, ensure proper fencing or coordination to prevent other systems from accessing or attempting to import the same volume group concurrently, which could lead to data corruption.
USE CASES FOR MIGRATION
vgexport is indispensable for migrating volume groups between different systems. After deactivating and exporting a VG from a source machine, its underlying physical volumes can be physically moved or presented via a SAN to a target machine. On the target, vgimport is then used to re-register the VG, making its logical volumes accessible.
TROUBLESHOOTING AND RECOVERY
In some advanced troubleshooting scenarios, if a volume group's metadata becomes corrupted or inaccessible on a system, exporting it (if possible) and then re-importing it might help refresh the LVM's view of the VG. This assumes the underlying physical volume metadata remains intact.
HISTORY
The vgexport command has been a fundamental part of the Logical Volume Manager (LVM) suite since its early iterations on Linux. LVM, first introduced to the Linux kernel around 1998, provided a flexible way to manage disk space. vgexport's role has consistently been to facilitate the removal and portability of volume groups, making it a critical tool for system administrators needing to migrate storage, perform hardware maintenance, or decommission systems. Its core functionality has remained stable, evolving primarily with improvements and bug fixes within the broader LVM framework.