mellotanica
mellotanica

Reputation: 184

lvm: create snapshot between volume groups

is there a way to create a snapshot of a logical volume (lv1) that resides into volume group vgA inside a different volume group (say vgB)?

i have my root logical volume in volume group vgA on the SSD and i want to take a snapshot of the volume on the second volume grout vgB that sits onto the mechanical hard disk, so i tried to execute

lvcreate -L 10G -s -n vgB/rootSnapshot vgA/rootVolume

and some other variants but had no luck..

Upvotes: 1

Views: 6456

Answers (3)

jurez
jurez

Reputation: 4657

It's not possible with LVM, specifically lvcreate does not support it. However, it's possible if you use device mapper directly (via dmsetup).

See here:

Upvotes: 0

L3w1s
L3w1s

Reputation: 306

Only want to say that limiting the snapshot in the same volume group as it's orignal lv really makes the idea of "logical" volume degraded.

For example, I use two hard drives with a RAID card to form a RAID1 disk and manage all it's physical space with volume group VG_SYS, and create my system volume and install my OS within it.Then I use another two drives to form a RAID0 disk and build a VG_DATA volume group on it, planning to use it as storage for unimportant data and snapshot.

However, I can't create snapshot volume in VG_DATA due to the limitation of LVM. Of course I can extend my VG_SYS onto my RAID0 drive and dedicate those pvs from RAID0 drive to my snapshot volume. But that would make my intention vague which separating logical volumes into important system volume group (redundancy guaranteed by RAID1) and unimportant quickly updated data volume group (RAID0 to increase I/O efficiency). Snapshots are meant to be updated and recycled very quickly so they don't need any redundancy. If a snapshot happens to be broken you just need to rebuild another one -- it's unlikely both your original volume and snapshot are broken at the same time.

Upvotes: 1

CharlesL
CharlesL

Reputation: 942

The snapshot volume must reside on the same VG as lv1.

For your situation, you may want to consider creating one VG (vgA) that spans over two PVs (pv1 for SSD, and pv2 for mechanical hard disk). Then you can create lv1 on pv1 and lvsnap on pv2.

 lvcreate -L 100G -n lv1 vgA /dev/pv1
 lvcreate -L 10G -s -n lvsnap /dev/vgA/lv1 /dev/pv2

Upvotes: 4

Related Questions