I was playing with my LVM thin installation. Created multiple snapshots, merged them with origin many times. At some point in the output of lvs -a
command oldest snapshots lost its origin. In the output of more detailed command lvs -a -o time,name,origin,lv_role
this snapshots are now have lv_role
as public
(while snapshots have roles public,snapshot,thinsnapshot
). merge
is now not possible with error is not a mergeable logical volume
. Now I have multiple questions:
- is this orphaned snapshots are proper volumes or they are corrupted?
- why does this happen? (I was merging some middle in terms of creation time snapshots with their origin and then recreating them)
- can I manually remove origin from a snapshot to make it separated volume?
- is there a way back for this volumes to became snapshots with equal blocks of data being linked to origin again to preserve space?
Update. Test script.
initial config with name of VG and pool that should exist:
VG=vg
Pool="${VG}"/pool0
Test_volume="test"
create test LV and make it random
lvcreate -V10M -T "${Pool}" -n "${Test_volume}"
lvchange -ay -Ky "${VG}"/"${Test_volume}"
dd if=/dev/urandom of="/dev/${VG}/${Test_volume}"
lvcreate -n "${Test_volume}_snap_0" --snapshot "${VG}"/"${Test_volume}"
lvchange -ay -Ky "${VG}"/"${Test_volume}_snap_0"
dd if=/dev/urandom of="/dev/${VG}/${Test_volume}"
lvcreate -n "${Test_volume}_snap_1" --snapshot "${VG}"/"${Test_volume}"
lvchange -ay -Ky "${VG}"/"${Test_volume}_snap_1"
dd if=/dev/urandom of="/dev/${VG}/${Test_volume}"
lvcreate -n "${Test_volume}_snap_2" --snapshot "${VG}"/"${Test_volume}"
lvchange -ay -Ky "${VG}"/"${Test_volume}_snap_2"
dd if=/dev/urandom of="/dev/${VG}/${Test_volume}"
lvcreate -n "${Test_volume}_snap_3" --snapshot "${VG}"/"${Test_volume}"
lvchange -ay -Ky "${VG}"/"${Test_volume}_snap_3"
sha256sum "/dev/${VG}/${Test_volume}_snap"*
lvs -a -o name,origin,lv_role| grep "${Test_volume}"
lvs
output:
test public,origin,thinorigin,multithinorigin
test_snap_0 test public,snapshot,thinsnapshot
test_snap_1 test public,snapshot,thinsnapshot
test_snap_2 test public,snapshot,thinsnapshot
test_snap_3 test public,snapshot,thinsnapshot
now merge one snapshot:
lvconvert --merge "${VG}/${Test_volume}_snap_2"
lvs -a -o name,origin,lv_role| grep "${Test_volume}"
output:
test public
test_snap_0 public
test_snap_1 public
test_snap_3 public
this snapshots are now just volumes, they may share some blocks with each other, sha256sum
shows that data are intact, overriding one does not affect others.
It's quite strange why they lose origin but still have common data blocks.