How to determine when a snapshot merging is complete ?

Solution Verified - Updated -

Environment

Red Hat Enterprise Linux

Issue

  • LVM snapshot still appears after executing lvconvert with merge command and server reboot
  • Unable to identify status of LVM snapshot merge status

Resolution

  • The snapshot-merge and snapshot status lines end with:
<sectors_allocated> <total_sectors>  <metadata_sectors>

Both <sectors_allocated> and <total_sectors> include both data and metadata.

During merging, the number of sectors allocated gets smaller and smaller. Merging has finished when the number of sectors holding data is zero, in other words <sectors_allocated> == <metadata_sectors>.

  • Here is a practical example (using a hybrid of lvm and dmsetup commands):
# lvs
  LV      VG          Attr   LSize Origin  Snap%  Move Log Copy%  Convert
  base    volumeGroup owi-a- 4.00g
  snap    volumeGroup swi-a- 1.00g base  18.97

# dmsetup status volumeGroup-snap
0 8388608 snapshot 397896/2097152 1560
                                  ^^^^ metadata sectors

# lvconvert --merge -b volumeGroup/snap
  Merging of volume snap started.

# lvs volumeGroup/snap
  LV      VG          Attr   LSize Origin  Snap%  Move Log Copy%  Convert
  base    volumeGroup Owi-a- 4.00g          17.23

# dmsetup status volumeGroup-base
0 8388608 snapshot-merge 281688/2097152 1104

# dmsetup status volumeGroup-base
0 8388608 snapshot-merge 180480/2097152 712

# dmsetup status volumeGroup-base
0 8388608 snapshot-merge 16/2097152 16

Merging has finished.

# lvs
  LV      VG          Attr   LSize Origin  Snap%  Move Log Copy%  Convert
  base    volumeGroup owi-a- 4.00g

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments