4

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

1
  • You can add bs parameter to dd to speed it up
    – dmityugov
    Jun 17, 2009 at 15:06

2 Answers 2

2

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.

2
  • I don't want to use the snapshot forever because it will eventually be used in production and that would have a serious performance impact. I also read the manual - do you know how to do it? I couldn't see an example that really explained it. Jun 17, 2009 at 11:13
  • Thanks wzzrd. Hopefully someone will come along and go "yes you just enter this cryptic undocumented command!" hehe. This is something VMWare does really well being able to snapshot a running VM and roll back to it within seconds at any time, I hope to find a good way to do this with Xen+LVM. Jun 17, 2009 at 23:22
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .