Inspect LVM history using metadata archives.
Inspect LVM history on a regular Ubuntu instance.
$ sudo bash -c "cat /etc/lvm/archive/*" | \ awk -F= '$0 ~ /^creation_time =|^description =/ { print $2 }' | \ awk 'NR%2==1 {sub(/Created \*before\* /,"",$0);line1=$0;state=1} NR%2==0 {line2=$0;state=0} {if(state==0) {print line2 " -" line1}}' | \ sort -n -k 1 | \ grep -v "'lvs'\|'vgs'\|'vgdisplay'\|'vgscan"
1612982331 # Wed Feb 10 19:38:51 2021 - "executing 'vgrename pPnX9c-Jolo-fwOF-7aYS-ZgoV-IFf1-Lx9dle additional_vg'" 1613517024 # Wed Feb 17 00:10:24 2021 - "executing 'vgcreate vgbackup /dev/mapper/sda_crypt'" 1613517147 # Wed Feb 17 00:12:27 2021 - "executing 'lvcreate -n backup -l +100%FREE vgbackup'" 1627422584 # Tue Jul 27 23:49:44 2021 - "executing 'lvextend -Ay -l+1 /dev/mapper/vgubuntu-swap_1'" 1627422637 # Tue Jul 27 23:50:37 2021 - "executing 'lvextend -Ay -L+1G /dev/mapper/vgubuntu-swap_1'"
Inspect LVM history on a regular Debian server using a slightly simpler version.
$ sudo bash -c "cat /etc/lvm/archive/*" | \ awk -F= '$0 ~ /^creation_time =|^description =/ { print $2 }' | \ awk 'NR%2==1 {line1=$0;state=1} NR%2==0 {line2=$0;state=0} {if(state==0) {print line2 " -" line1}}' | \ sort -n -k 1
1620569366 # Sun May 9 16:09:26 2021 - "Created *before* executing 'pvscan --cache --activate ay 8:3'" 1620594029 # Sun May 9 23:00:29 2021 - "Created *before* executing '/sbin/lvcreate --type thin-pool -L459343216.64K --poolmetadatasize 4687175.68K -n ssd ssd'" 1620594029 # Sun May 9 23:00:29 2021 - "Created *before* executing '/sbin/vgcreate ssd /dev/sdb'" 1620594599 # Sun May 9 23:09:59 2021 - "Created *before* executing 'vgrename ssd cerberus-ssd'" 1620594634 # Sun May 9 23:10:34 2021 - "Created *before* executing 'lvrename cerberus-ssd ssd cerberus-ssd'" 1620595037 # Sun May 9 23:17:17 2021 - "Created *before* executing '/sbin/lvcreate --type thin-pool -L459343216.64K --poolmetadatasize 4687175.68K -n cerberus-ssd cerberus-ssd'" 1620595037 # Sun May 9 23:17:17 2021 - "Created *before* executing '/sbin/vgcreate cerberus-ssd /dev/sdb'" 1620598096 # Mon May 10 00:08:16 2021 - "Created *before* executing '/sbin/lvcreate -aly -V 20971520k --name vm-100-disk-0 --thinpool cerberus-ssd/cerberus-ssd'" 1620598164 # Mon May 10 00:09:24 2021 - "Created *before* executing '/sbin/lvcreate -aly -V 20971520k --name vm-101-disk-0 --thinpool cerberus-ssd/cerberus-ssd'" 1620598232 # Mon May 10 00:10:32 2021 - "Created *before* executing '/sbin/lvcreate -aly -V 20971520k --name vm-102-disk-0 --thinpool cerberus-ssd/cerberus-ssd'" 1620687398 # Tue May 11 00:56:38 2021 - "Created *before* executing '/sbin/lvcreate -n snap_vm-100-disk-0_AfterInstall -pr -s cerberus-ssd/vm-100-disk-0'" 1620687406 # Tue May 11 00:56:46 2021 - "Created *before* executing '/sbin/lvcreate -n snap_vm-101-disk-0_AfterInstall -pr -s cerberus-ssd/vm-101-disk-0'" 1620687411 # Tue May 11 00:56:51 2021 - "Created *before* executing '/sbin/lvcreate -n snap_vm-102-disk-0_AfterInstall -pr -s cerberus-ssd/vm-102-disk-0'" 1622058143 # Wed May 26 21:42:23 2021 - "Created *before* executing '/sbin/lvcreate -kn -n vm-102-disk-0 -s cerberus-ssd/snap_vm-102-disk-0_AfterInstall'" 1622058143 # Wed May 26 21:42:23 2021 - "Created *before* executing '/sbin/lvremove -f cerberus-ssd/vm-102-disk-0'" 1622058166 # Wed May 26 21:42:46 2021 - "Created *before* executing '/sbin/lvcreate -kn -n vm-101-disk-0 -s cerberus-ssd/snap_vm-101-disk-0_AfterInstall'" 1622058166 # Wed May 26 21:42:46 2021 - "Created *before* executing '/sbin/lvremove -f cerberus-ssd/vm-101-disk-0'" 1622058175 # Wed May 26 21:42:55 2021 - "Created *before* executing '/sbin/lvremove -f cerberus-ssd/vm-100-disk-0'" 1622058176 # Wed May 26 21:42:56 2021 - "Created *before* executing '/sbin/lvcreate -kn -n vm-100-disk-0 -s cerberus-ssd/snap_vm-100-disk-0_AfterInstall'" 1622576277 # Tue Jun 1 21:37:57 2021 - "Created *before* executing '/sbin/lvcreate -aly -V 20971520k --name vm-107-disk-0 --thinpool cerberus-ssd/cerberus-ssd'"
I love it!
Additional notes
Sample metadata backup file.
$ sudo cat /etc/lvm/archive/ssd_00002-1290366653.vg
# Generated by LVM2 version 2.03.02(2) (2018-12-18): Sun May 9 23:09:59 2021 contents = "Text Format Volume Group" version = 1 description = "Created *before* executing 'vgrename ssd cerberus-ssd'" creation_host = "cerberus" # Linux cerberus 5.4.106-1-pve #1 SMP PVE 5.4.106-1 (Fri, 19 Mar 2021 11:08:47 +0100) x86_64 creation_time = 1620594599 # Sun May 9 23:09:59 2021 ssd { id = "nxbNj2-qbG7-S5dA-PVvZ-i2fO-a3KJ-XMQ5Wk" seqno = 4 format = "lvm2" # informational status = ["RESIZEABLE", "READ", "WRITE"] flags = [] extent_size = 8192 # 4 Megabytes max_lv = 0 max_pv = 0 metadata_copies = 0 physical_volumes { pv0 { id = "DmbGuf-GER2-5ZOz-XkZN-Nnwr-qv9Z-TYGAa1" device = "/dev/sdb" # Hint only status = ["ALLOCATABLE"] flags = [] dev_size = 937703088 # 447.132 Gigabytes pe_start = 2048 pe_count = 114465 # 447.129 Gigabytes } } logical_volumes { ssd { id = "JuCbvP-RfjC-EwYU-laN1-h7SG-qO6h-NhfBFC" status = ["READ", "WRITE", "VISIBLE"] flags = [] creation_time = 1620594029 # 2021-05-09 23:00:29 +0200 creation_host = "cerberus" segment_count = 1 segment1 { start_extent = 0 extent_count = 112145 # 438.066 Gigabytes type = "thin-pool" metadata = "ssd_tmeta" pool = "ssd_tdata" transaction_id = 0 chunk_size = 128 # 64 Kilobytes discards = "passdown" zero_new_blocks = 1 } } lvol0_pmspare { id = "TshsPE-nz1s-KAXw-8Ckc-AWu5-gvmX-fDePnB" status = ["READ", "WRITE"] flags = [] creation_time = 1620594029 # 2021-05-09 23:00:29 +0200 creation_host = "cerberus" segment_count = 1 segment1 { start_extent = 0 extent_count = 1145 # 4.47266 Gigabytes type = "striped" stripe_count = 1 # linear stripes = [ "pv0", 0 ] } } ssd_tmeta { id = "anex6N-qQ0j-eL7a-o721-S3kg-GNBY-C6az5K" status = ["READ", "WRITE"] flags = [] creation_time = 1620594029 # 2021-05-09 23:00:29 +0200 creation_host = "cerberus" segment_count = 1 segment1 { start_extent = 0 extent_count = 1145 # 4.47266 Gigabytes type = "striped" stripe_count = 1 # linear stripes = [ "pv0", 113290 ] } } ssd_tdata { id = "zxYMXo-1aci-Zd0W-8hoP-ogdb-L0SF-sKDqc2" status = ["READ", "WRITE"] flags = [] creation_time = 1620594029 # 2021-05-09 23:00:29 +0200 creation_host = "cerberus" segment_count = 1 segment1 { start_extent = 0 extent_count = 112145 # 438.066 Gigabytes type = "striped" stripe_count = 1 # linear stripes = [ "pv0", 1145 ] } } } }
Sample /etc/lvm/archive/
directory contents.
$ sudo ls -1 /etc/lvm/archive/
cerberus-ssd_00000-1551757938.vg cerberus-ssd_00001-358292428.vg cerberus-ssd_00002-217153102.vg cerberus-ssd_00003-987042352.vg cerberus-ssd_00004-1544365741.vg cerberus-ssd_00005-1580297650.vg cerberus-ssd_00006-1399830088.vg cerberus-ssd_00007-1821602134.vg cerberus-ssd_00008-482006289.vg cerberus-ssd_00009-1710007123.vg cerberus-ssd_00010-1592065077.vg cerberus-ssd_00011-2089845312.vg cerberus-ssd_00012-222013694.vg cerberus-ssd_00013-2062860377.vg cerberus-ssd_00014-508120940.vg cerberus-ssd_00015-1172909953.vg pve_00000-1780689292.vg ssd_00000-1314166574.vg ssd_00001-1743363382.vg ssd_00002-1290366653.vg