Is it possible to convert a LVM2 snapshot to a linear LV?

Posted on

Is it possible to convert a LVM2 snapshot to a linear LV? – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, lvm, snapshot, , .

We have DRBD volumes that are presented to guests, and we often snapshot them with the intention of reverting back to the snapshots. I understand in LVM, snapshoting then working with the snapshot is preferred when doing something experimental but often we make the snapshot simply as a backup to revert to if something goes wrong (known good state).

Mounting the disks and rsyncing is possible but sometimes the contents is complex with multiple partitions (or LV’s inside the disk). Using dd to copy all the data is also possible but it is very time consuming. What I was more hoping to do is can I use lvconvert and convert a snapshot into a normal linear lv? Can I mirror a snapshot then use that as a linear lv?


Solution :

From the lvconvert manpage:

lvconvert will change a linear logical
volume to a mirror logical volume or
to a snapshot of linear volume and
vice versa

Emphasis mine.

So yes, it should be possible to convert a snapshot into a linear LV or mirror. If that means you can mirror a snapshot and then use it as a linear lv, that’s something you would have to try out.

Apparently, the manpage and me we wrond 😛 I remembered seeing this stuff in the manpage, but I hadn’t actually tried converting a snapshot to a linear LV. Having seen the comment below, I decided to check it out. From what I can see now, it is not possible, what ever the manpage may imply, to convert a snapshot to a linear LV. What is possible using lvconvert is to convert a mirror volume to a linear LV. I think the manpage should be edited a bit here.

If someone does find a way to do this, let me know, but from what I know now, I’d say: not possible. Kinda logical when you think of it, because converting a snapshot LV to a linear LV means something in the line of

dd if=linear of=snapshot

Otoh, you can use a snapshot as a logical volume by itself. As I explained here, LVM is just some device mapper magic. So if you would take an LVM snapshot and then use that for your experiments, the original disk would not be touched, but can still keep functioning normally at the same time.

LVM2 snapshots can be mounted r/w and used as regular volumes. If there is a high likelihood that you’ll want to discard the changes introduced by the guest, perhaps the solution is to present the snapshot to the guest. Then you can either discard the snapshot or merge it back in with lvconvert --merge.

Leave a Reply

Your email address will not be published.