2

I have a product that uses LVM and snapshots. When the base installation is created, I create snapshots of partitions with the following:

lvcreate -L 15G -s -n lv_root_gold /dev/vg_sys/lv_root
lvcreate -L 15G -s -n lv_home_gold /dev/vg_sys/lv_home
lvcreate -L 1G -s -n lv_services_gold /dev/vg_sys/lv_services

On my system, most software is installed into lv_services lv which gets mounted to /services. This creates a fair amount of changes to the lv_services_gold snapshot.

When I deploy software updates, I roll-back the entire system to its initial snapshots. I do this to ensure that all machines are installing from the same state. After reboot, I then take a new snapshot of the box in it's 'original' state and then proceed to install the new software.

When I rollback the system with the following:

lvconvert --merge -y /dev/vg_sys/lv_root_gold
lvconvert --merge -y /dev/vg_sys/lv_services_gold
lvconvert --merge -y /dev/vg_sys/lv_home_gold

A reboot is required since all of the partitions are mounted. But when I reboot, one of the partitions is left in Attr (O)rigin with merging snapshot:

  LV                 VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home            vg_sys -wi-ao----  15.00g                                                    
  lv_services        vg_sys Owi-aos---   1.00g             0.00  
  lv_root            vg_sys -wi-ao----  20.00g                                                    

The command 'lvdisplay vg_sys/lv_services_gold' shows that the snapshot still exists since it is being merged. However, the snapshot is not displayed via the lvs command.

Is there a modifier I can feed to 'lvconvert' to force the full merge of the snapshot while the system is booting and block to avoid the 'O' Attr once the system is online? If I reboot again, the lv_services LV is no longer in the 'Origin merging with snapshot' mode.

My work-around at this point is to determine if there are any snapshots when the system boots. If no, determine if any LV's are in the 'O' state. If so, keep rebooting until all LV's don't have 'Origin with merging snapshot'. Then I proceed to take new snapshots and do the software install. I would much prefer to avoid having to do repeated reboots.

1 Answer 1

4

I found the answer shortly after posting the question. Once lvs is reporting the merge status is down to 0.00 in the 'Data %' column. The [O]rigin with merging snapshot field can be cleared by issuing the following:

lvchange --refresh <<VG_NAME>>

Example (initial lvs command is after lvconvert --merge and reboot):

root@testbox:~# lvs
  LV                 VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_services        vg_sys Owi-aos---   1.00g             0.00  

root@testbox:~# lvchange --refresh vg_sys
root@testbox:~# lvs
  LV                 VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_services        vg_sys -wi-ao----   1.00g  
1
  • 1
    lvchange --refresh worked on a fresh Debian Testing/Bookworm install on my root filesystem, thanks!
    – genpfault
    Jan 25, 2023 at 22:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .