Linux – Is it possible to convert a LVM2 snapshot to a linear LV

linuxlvmsnapshot

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?

Thanks

Best Answer

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 :P 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.