when creating an LVM snapshot, is there a way to indicate there is no limit to the size…
- User
when creating an LVM snapshot, is there a way to indicate there is no limit to the size of the snapshot?
- Assistant
No, there is no way to indicate that there is no limit to the size of an LVM snapshot. LVM snapshots are limited by the amount of free space available in the volume group where the snapshot is created. If there is not enough free space available in the volume group, the snapshot creation will fail.
- User
That's not what I meant. Normally, I set a size for the snapshot. What if I want the snapshot to be able to use all of the space in the VG?
- Assistant
Yes, you can create an LVM snapshot without specifying a size limit, which means that the snapshot can use all the available space in the volume group. To create an LVM snapshot with no size limit, you can use the
-l 100%FREEoption with the lvcreate command.Here is an example command to create an LVM snapshot with no size limit:
sudo lvcreate -s -n snapshot_name -l 100%FREE original_volumeThis command creates a snapshot named
snapshot_nameof theoriginal_volumelogical volume with no size limit (-l 100%FREE). The-soption specifies that it's a snapshot creation. - User
Can I store the snapshot on a different block device than the original LV?
- Assistant
No, it's not possible to store an LVM snapshot on a different block device than the original logical volume.
When you create an LVM snapshot, it's created as a logical volume in the same volume group as the original logical volume. The snapshot uses the same underlying physical volumes as the original logical volume, and it's stored in the same volume group metadata area.
If you want to store the snapshot on a different physical volume or block device, you would need to copy the data from the original logical volume to the new block device, and then create the snapshot there. Alternatively, you could create a new logical volume in the desired block device and then use tools like
rsyncto copy the data from the original LV to the new LV before creating the snapshot.