8.7. Tracking and displaying removed thin snapshot volumes
This procedure describes how to display and manage deleted historical logical volumes.
Procédure
-
Ensure that historical logical volumes are retained by setting
record_lvs_history=1
in thelvm.conf
file. This metadata option is not enabled by default. -
Optional: Set the value of the
lvs_history_retention_time
option in seconds. This is the time interval after which a record about individual historical logical volume is automatically destroyed. The automatic default value is0
and it disables this feature. If you do not set this option, you can also delete individual historical volumes manually. To display a thin-provisioned snapshot chain:
Dans cet exemple :
-
lvol1
is an origin volume, the first volume in the chain. -
lvol2
is a snapshot oflvol1
. -
lvol3
is a snapshot oflvol2
. -
lvol4
is a snapshot oflvol3
. lvol5
is also a snapshot oflvol3
.# lvs -H -o name,full_ancestors,full_descendants LV FAncestors FDescendants lvol1 lvol2,lvol3,lvol4,lvol5 lvol2 lvol1 lvol3,lvol4,lvol5 lvol3 lvol2,lvol1 lvol4,lvol5 lvol4 lvol3,lvol2,lvol1 lvol5 lvol3,lvol2,lvol1 pool
Note that, despite using
lvs
utility with the-H
option, no thin snapshot volume is removed and there are no historical logical volumes to display.
-
Remove logical volume
lvol3
from the snapshot chain:# lvremove -f vg/lvol3 Logical volume "lvol3" successfully removed
Run the
lvs
utility to see the details of historical logical volumes, along with their ancestors and descendants:# lvs -H -o name,full_ancestors,full_descendants LV FAncestors FDescendants lvol1 lvol2,-lvol3,lvol4,lvol5 lvol2 lvol1 -lvol3,lvol4,lvol5 -lvol3 lvol2,lvol1 lvol4,lvol5 lvol4 -lvol3,lvol2,lvol1 lvol5 -lvol3,lvol2,lvol1 pool
Additionally, display the removal timestamp of a historical volume:
# lvs -H -o name,full_ancestors,full_descendants,time_removed LV FAncestors FDescendants RTime lvol1 lvol2,-lvol3,lvol4,lvol5 lvol2 lvol1 -lvol3,lvol4,lvol5 -lvol3 lvol2,lvol1 lvol4,lvol5 2016-03-14 14:14:32 +0100 lvol4 -lvol3,lvol2,lvol1 lvol5 -lvol3,lvol2,lvol1 pool
You can reference historical logical volumes individually in a display command by specifying the vgname/lvname format:
# lvs -H vg/-lvol3 LV VG Attr LSize -lvol3 vg ----h----- 0
Note that the fifth bit in the
lv_attr
field is set toh
to indicate the volume is a historical one.LVM does not keep historical logical volumes if the volume has no live descendant. This means that if you remove a logical volume at the end of a snapshot chain, the logical volume is not retained as a historical logical volume.
# lvremove -f vg/lvol5 Automatically removing historical logical volume vg/-lvol5. Logical volume "lvol5" successfully removed # lvs -H -o name,full_ancestors,full_descendants LV FAncestors FDescendants lvol1 lvol2,-lvol3,lvol4 lvol2 lvol1 -lvol3,lvol4 -lvol3 lvol2,lvol1 lvol4 lvol4 -lvol3,lvol2,lvol1 pool
Remove the volume
lvol1
andlvol2
and to see how thelvs
command displays the volumes once they have been removed.# lvremove -f vg/lvol1 vg/lvol2 Logical volume "lvol1" successfully removed Logical volume "lvol2" successfully removed # lvs -H -o name,full_ancestors,full_descendants LV FAncestors FDescendants -lvol1 -lvol2,-lvol3,lvol4 -lvol2 -lvol1 -lvol3,lvol4 -lvol3 -lvol2,-lvol1 lvol4 lvol4 -lvol3,-lvol2,-lvol1 pool
Remove a historical logical volume completely by specifying the name of the historical volume that now includes the hyphen, as in the following example
# lvremove -f vg/-lvol3 Historical logical volume "lvol3" successfully removed # lvs -H -o name,full_ancestors,full_descendants LV FAncestors FDescendants -lvol1 -lvol2,lvol4 -lvol2 -lvol1 lvol4 lvol4 -lvol2,-lvol1 pool