In this lesson, you will learn how to reorganize your storage infrastructure by splitting a single Volume Group (VG) into two, or joining two existing VGs into one, without losing your data.
Understanding VG Manipulation
Sometimes, a Volume Group grows too large or contains mixed project data that you want to isolate for better management or to move to a different server. LVM allows you to perform "surgery" on your storage layout using two primary commands: vgsplit and vgmerge.
Splitting a Volume Group
If you have a large Volume Group named vg_data and you want to move specific Physical Volumes (PVs) to a new group called vg_archive, you use vgsplit. The condition is that the destination VG must not exist yet; the command will create it for you.
To move the physical drive /dev/sdb1 from vg_data into a new group vg_archive:
vgsplit vg_data vg_archive /dev/sdb1
Note that any Logical Volumes (LVs) residing on that specific drive must be moved or evacuated first if they span across the split point, as a single logical volume cannot exist across two separate volume groups.
Merging Volume Groups
Conversely, if you have two smaller VGs that you want to consolidate into one larger pool of free space, you can merge them using vgmerge.
If you want to combine vg_archive back into vg_data:
vgmerge vg_data vg_archive
For this to work, the source volume group (vg_archive) must be inactive (all its LVs must be unmounted and closed). Once merged, all physical volumes and logical volumes from vg_archive are moved into vg_data, and vg_archive ceases to exist.
Why perform these actions?
These operations are essential for administrative flexibility. You might use them to physically separate data for security, to decommission a specific disk, or to simplify your storage topology when combining smaller servers into a larger, centralized storage array. Always ensure your LVs are unmounted before performing a merge to prevent data corruption.
Key Takeaway: Use vgsplit to carve out sections of your storage into new volume groups, and vgmerge to consolidate inactive volume groups into a single, unified storage pool.