[CentOS] question(s) about LVM snapshots

Fri Oct 12 14:29:41 UTC 2007
Tony Schreiner <schreian at bc.edu>

On Oct 11, 2007, at 7:16 PM, William L. Maltby wrote:

> On Thu, 2007-10-11 at 15:47 -0400, Tony Schreiner wrote:
>> I've recently begun to try out LVM snapshots and I have 2 things I'm
>> wondering about
>>
>> My intention is to run backups off the snapshot. As a first
>> iteration, I left 15% of the disk for the snapshot LV.
>>
>> 1.
>> The HOWTO instructions suggest that the snapshot is in effect as long
>> as the snapshot LV exists, and use lvremove to disable the snapshot.
>> Is this the proper way?
>
> I reviewd some code I wrote and tested during 8/06 and I did not  
> remove
> the logical volume. I just unmounted it. ISTR that my reading of stuff
> at that time did *not* require the snapshot volume be removed.
>
>>
>> 2.
>> I chose 15% because the disk  is not that active and I think it will
>> be plenty for the duration of the backup I'm doing. Is there a way to
>> track how much space the snapshot is actually using?
>
> My code seems to indicate that once the snapshot voluke is mounted,  
> the
> usual "df <options of your choice>" work just as on any other logical
> volume.
>
> BTW, this *may* have been LVM 1? Not sure now and haven't researched
> since. But it did work great and the snapshot volume (IIRC) retains  
> its
> contents. This, I'm sure can be useful. Haven't really though about it
> though.
>
>>
>> Cheers,
>>
>> Tony Schreiner
>> <snip sig stuff>
>
> HTH (and that I'm correct)
> --
> Bill

When the snap shot volume is mounted, yes you can do df on it. But  
that shows you the state of the volume you take the snapshot of at  
the time of the snapshot. That's not what I want to know.

For example in my case

# vgdisplay
   --- Volume group ---
   VG Name               vg_data
.... snip ...
   VG Size               956.34 GB
   PE Size               4.00 MB
   Total PE              244824
   Alloc PE / Size       244824 / 956.34 GB
   Free  PE / Size       0 / 0

  # lvdisplay vg_data
   --- Logical volume ---
   LV Name                /dev/vg_data/lv_data
   VG Name                vg_data
... snip...
   LV Size                812.89 GB
   Current LE             208100
... snip ...

   --- Logical volume ---
   LV Name                /dev/vg_data/lv_backup
   VG Name                vg_data
,.. snip ...
   LV snapshot status     active destination for /dev/vg_data/lv_data
   LV Status              available
... snip ...
   LV Size                812.89 GB
   Current LE             208100
   COW-table size         143.45 GB
   COW-table LE           36724
... snip ...

the original volume has  208100 LEs, and the snapshot was created  
with 36724 LEs ( 85 % , 15 % ratio ).
mount the snapshot and do df

# df /data /data/backup
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_data-lv_data
                       801G  289G  471G  39% /data
/dev/mapper/vg_data-lv_backup
                       801G  289G  471G  39% /data/backup


the snapshot on /data/backup is showing the disk free of the original.

If I'm understanding LVM snapshots, initially no blocks are changed  
on the snapshot volume, they get changed as the original volume  
changes until you disable the snapshot, and eventually you will run  
out of space to store that. That is what I'm trying to track.

Tony Schreiner