Linked Clone confusion

Faris Raouf

Well-Known Member
Mar 19, 2018
147
26
58
I am really confused. Please can someone help me understand what's happening?

When I delete a VM Template from which I created a linked clone, the linked clone continues to work perfectly.

This is not what I expected and I have obviously misunderstood something. From what I've read, I thought a linked clone only created a "blank" filesystem, where additions/changes to the source VM would be stored. So if you destroy the source Template, the linked clone should stop working. But in my case it continues to work.

Please can someone clear up my misunderstanding? I feel very stupid asking this question. I would prefer to post in the "Newbie Stupid Question" section of the forum, but it seems not to exist.....


In case it is useful, this is what I did (Proxmox 5.2-5):

I created a Centos 7 VM (ID=101), then converted it into a Template.

In local-lvm, I can see base-101-disk-1 which is the disk image for this template (format = raw, type = disk image, size=32GB, this being the size I specified when creating the VM before turning it into a Template)

I then create a new linked clone (VM ID=103) from the Template . It takes 2 seconds, so it is definitely a linked clone not a full clone, which takes a much, much longer time.

in local-lvm, I can see vm-103-disk-1 (format = raw, type = disk image, size=32GB).

lvdisplay shows " LV Thin origin name base-101-disk-1" for /dev/pve/vm-103-disk1

So far so good.

Now if I Remove the Template (ID=101), it vanishes from the GUI, and base-101-disk-1 vanishes from local-lvm.

But somehow VM 103 still works fine.

In addition, lvdisplay now has no "LV Thin origin name" line for /dev/pve/vm-103-disk1
 
  • Like
Reactions: undertone2230
On lvm-thin all clones are independent, that's why it is possible to delete the parent.
 
Thanks Alwin. OK, so I'm not going mad. This is good.

But how does this work please? What magic happens in the background?
It takes 2 seconds to create the linked clone, but many minutes to create a full clone, so there is obviously a difference on creation.
 
On a full clone, all metadata & data has to be copied. With a linked clone, only the reference to the data is created.
 
OK. So a reference or pointer to the data is created. But when the source Template is removed, something more must happen. Something must say "ah, there is a reference to this data, so we must preserve it and change the references". Is this some built-in feature of LVM? I would like to understand it properly, and it would help if I know what to Google for.

But foremost in my mind is loss of data or damage to data.

If I create 10 linked clones from a Template in LVM-Thin, does that still mean that if a single block of data gets damaged - lets say this is where the Template's kernel is stored - then all 10 linked clones will fail (or at least not boot)?
 
So a reference or pointer to the data is created. But when the source Template is removed, something more must happen. Something must say "ah, there is a reference to this data, so we must preserve it and change the references".
That's what happening, as long as there is a reference (b-tree) to the block it will be kept.

Is this some built-in feature of LVM?
Of LVM-thin (device-mapper), yes.

But foremost in my mind is loss of data or damage to data.
Well, you always need a backup. This is no replacement for it. ;)

If I create 10 linked clones from a Template in LVM-Thin, does that still mean that if a single block of data gets damaged - lets say this is where the Template's kernel is stored - then all 10 linked clones will fail (or at least not boot)?
Yes, if there was no kernel update after. Hence the backup. :D
 
  • Like
Reactions: ZipTX

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!