[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [linux-lvm] Snapshots



jonr destar net wrote:
> Hello List,
> 
> I don't get it!
> 
> I have a xen system that has a DomU of FC11 with a 20GB LV for the  
> disk. I created a snapshot using this command:
> 
> lvcreate -L +10G -s -n s_cgate-be1 /dev/xenvg/cgate-be1
> 
> This is the output of an 'lvdisplay' of the snapshot LV:
> 
> lvdisplay /dev/xenvg/s_cgate-be1
>    --- Logical volume ---
>    LV Name                /dev/xenvg/s_cgate-be1
>    VG Name                xenvg
>    LV UUID                7c1kEs-xYoO-Qxem-2E2M-hlee-pc4Q-zm6TZ5
>    LV Write Access        read/write
>    LV snapshot status     active destination for /dev/xenvg/cgate-be1
>    LV Status              available
>    # open                 2
>    LV Size                20.00 GB
>    Current LE             5120
>    COW-table size         10.00 GB
>    COW-table LE           2560
>    Allocated to snapshot  0.11%
>    Snapshot chunk size    4.00 KB
>    Segments               1
>    Allocation             inherit
>    Read ahead sectors     auto
>    - currently set to     256
>    Block device           253:15
> 
> I then shutdown the DomU and pointed the 'Disk...' line in the config  
> file for the DomU to the snapshot. It boots.
> 
> OK, I must be missing the simple answer because I cannot seem to grasp  
> the concept of snapshots.
> 
> 
> 1. How can I have a 20GB LV as a disk and the snapshot be 10GB and  
> boot the entire OS?
> 
That's because the snapshot uses these 10GB as a "COW-table". i.e. A "Copy On Write table".
When the snapshot is first created, no copy is performed. All the blocks of the snapshot are identical to the blocks of the original LV. Accessing the snapshot or original LV access the same block.
Then, if you modify some data in either the original LV or the snapshot LV, an "exception list" listing data chunks that are different in the snapshot LV than in the original LV, is created.
When reading a snapshot LV block, LVM first looks at the "exception list". If the chunk accessed is the in the "exception list", the chunk data in the exception list is returned. If the chunk isn't in the exception list, the chunk data is extracted from the original volume.
When writing a snapshot LV block, it's written in a chunk of the exception list, either existing, or created at this time.
When writing a chunk in the original volume, it's first copied in the "exception list", and then, modified in the original volume.

The chunk size is specified with the --chunksize parameter (4k to 512k) to lvcreate(8), when creating a snapshot.

If ever you've so many exceptions that the snapshot volume overflows, it's dropped.
Consequently, you must take care of allocating enough space in snapshots. This space is the size of the data that may be modified in the snapshot or original volume.
Snapshots are fine for short lived snapshots (e.g. when backing up) but aren't designed to cope with heavy modifications of the entire file system.

> 2. Can I create a DomU and then snapshot the LV and use the snapshot  
> to create other DomU's?

I'm not a Xen user. Sorry, I don't know.
Here, Google may help:
<http://www.google.com/search?rls=en&hl=en&source=hp&q=xen+device+mapper>

> 
> 3. If 2 is yes, would I want to continue using the snapshot as the  
> disk or is there something else that should be done, i.e. dd the drive  
> to a new LV?
> 
> In the 'lvdisplay' of the snapshot I have these extra lines:
>    LV snapshot status     active destination for /dev/xenvg/cgate-be1
>    # open                 2
>    COW-table size         10.00 GB
>    COW-table LE           2560
>    Allocated to snapshot  0.11%
>    Snapshot chunk size    4.00 KB
> 
> 4. Does the 0.11% mean that the 10GB snapshot file is only using .11%  
> of the 10GB LV?
> 
It means that the internal LVM data structure + the exception chunks are using 0.11% of the 10GB "COW-table partition".

Create snapshot, dd(1), delete snapshot is a way to create a "forked" copy of the original volume.
That may, or may not be what you want. If you intend to share much data with the original volume, a simple snapshot may be the way to go. If a small or near-zero amount of data is to be shared, in that case, snapshotting won't save data space, but may incur performance penalties (see <http://www.nikhef.nl/~dennisvd/lvmcrap.html>), and so, my advice is to create snapshot, dd(1), and delete snapshot.

I hope it helps.
-- 
André Gillibert




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]