Red Hat Bugzilla – Bug 209927
Creating a LVM snapshot destroys volume group metadata
Last modified: 2008-07-24 16:07:13 EDT
Description of problem:
When create a LVM snapshot of a volume group with metadata version 1 on RHEL4
the volume group becomes unusable. Nothing short of a vgcfgrestore fixes the
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1.lvcreate -L 32G -s -n snap /dev/vg01/lvol1 (on a metadata ver 1 vg/lv)
Reproduced, will see what can be done about it.
This request was previously evaluated by Red Hat Product Management
for inclusion in the current Red Hat Enterprise Linux release, but
Red Hat was unable to resolve it in time. This request will be
reviewed for a future Red Hat Enterprise Linux release.
Since LVM1 metadata can be converted to LVM2 easily *and* this is about
creating new snapshots on LVM1 volume groups, I would propose a simple measure
of disallowing such action. The tools somehow manage to corrupt the LVM1
metadata in nontrivial way, and I suppose it is not worth the debugging
trouble. LVM1 metadata is definitely deprecated and the only viable usecase is
maintaining a system compatible with RHEL3, which together with necessity to
create new snapshots is niche at best.
The patch for such a solution should be straightforward. I'm adding that to my
TODO and will propose such a patch shortly.
I've just tried this:
Invalid LV in extent map (PV /var/tmp/test2, PE 1, LV 1, LE 0)
Couldn't fill logical volume maps.
Let's at least understand why it goes wrong to make sure there's nothing more
fundamental we need to fix.
Indeed there is an underlying bug here: the internal variable vg->lv_count is
not maintained consistently throughout the code, leading to this bug.
One line fix in 2.02.36, to remember to include snapshots when writing the
number of LVs in the VG into the on-disk metadata.
Also fixed related problem of lvremove also getting the number of LVs wrong.
To clarify - this is a bug affecting the manipulation of metadata stored on-disk
in the old format used by LVM1. It should not affect data stored within any LVs.
Metadata stored on-disk using the default LVM2 format is unaffected.
To see which format you are using, run:
vgs -o +vg_fmt
Fix verified in lvm2-2.02.37-3.el4.
[root@taft-03 ~]# vgs -o +vg_fmt
VG #PV #LV #SN Attr VSize VFree Fmt
VolGroup00 1 2 0 wz--n- 68.12G 32.00M lvm2
taft 3 0 0 wz--n- 406.98G 406.98G lvm1
[root@taft-03 ~]# lvcreate -L 1G -n origin taft
Logical volume "origin" created
[root@taft-03 ~]# lvcreate -s taft/origin -L 100M -n snap
Logical volume "snap" created
[root@taft-03 ~]# lvs -a -o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
LogVol00 VolGroup00 -wi-ao 58.34G
LogVol01 VolGroup00 -wi-ao 9.75G
origin taft own-a- 1.00G
snap taft swn-a- 100.00M origin 0.01
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.