[linux-lvm] Question: How much space is needed do make sure that a LVM snapshot won't overflow

Guilherme Destefani gd at helixbrasil.com.br
Tue Feb 12 18:39:58 UTC 2008


Hi.

In the LVM2 HOWTO, it says:
(http://www.tldp.org/HOWTO/LVM-HOWTO/snapshotintro.html),

"Full snapshot are automatically disabled"
and:
"If the snapshot size equals the origin size, it will never overflow.".

But if one snapshot is created and an equal size is allocated to the
snapshot, it still overflows (creates a volume with 32M, a snapshot with
32M, and fills the volume with zeros).
Using more space, it doesn't overflow (same thing, but 64M for the
snapshot).

How much more space is needed to be alocated to the snapshot to ensure
that it will never overflow?

Thanks in advance,

Guilherme.


        Script started on Tue 12 Feb 2008 02:11:11 PM BRST
        [root at localhost ~]# lvcreate -L 32M -n base_volume hf
          Logical volume "base_volume" created
        [root at localhost ~]# lvcreate -s -L 32M -n
        copy_volume /dev/hf/base_volume 
          Logical volume "copy_volume" created
        [root at localhost ~]# lvdisplay |grep -A 13 "_volume"
          LV Name                /dev/hf/base_volume
          VG Name                hf
          LV UUID                qPzWgG-ON3V-swUr-O0IP-I172-G3YV-GH431K
          LV Write Access        read/write
          LV snapshot status     source of
                                 /dev/hf/copy_volume [active]
          LV Status              available
          # open                 0
          LV Size                32.00 MB
        --
          LV Name                /dev/hf/copy_volume
          VG Name                hf
          LV UUID                oGK0gG-o62D-Tu84-9CW0-rvPb-H7HX-bjUwk0
          LV Write Access        read/write
          LV snapshot status     active destination
        for /dev/hf/base_volume
          LV Status              available
          # open                 0
          LV Size                32.00 MB
          Current LE             1
          COW-table size         32.00 MB
          COW-table LE           1
          Allocated to snapshot  0.05% 
          Snapshot chunk size    8.00 KB
          Segments               1
          Allocation             inherit
          Read ahead sectors     0
          Block device           253:20
           
        [root at localhost ~]# dd if=/dev/zero of=/dev/hf/copy_volume 
        dd: writing to `/dev/hf/copy_volume': No space left on device
        65537+0 records in
        65536+0 records out
        33554432 bytes (34 MB) copied, 8.01466 s, 4.2 MB/s
        [root at localhost ~]# lvresize -L 64M /dev/hf/copy_volume 
          /dev/dm-20: read failed after 0 of 4096 at 0: Input/output
        error
          Extending logical volume copy_volume to 64.00 MB
          Logical volume copy_volume successfully resized
        [root at localhost ~]# lvdisplay |grep -A 13 "_volume"
          /dev/dm-20: read failed after 0 of 4096 at 0: Input/output
        error
          LV Name                /dev/hf/base_volume
          VG Name                hf
          LV UUID                qPzWgG-ON3V-swUr-O0IP-I172-G3YV-GH431K
          LV Write Access        read/write
          LV snapshot status     source of
                                 /dev/hf/copy_volume [INACTIVE]
          LV Status              available
          # open                 0
          LV Size                32.00 MB
          Current LE             1
          Segments               1
          Allocation             inherit
          Read ahead sectors     0
          Block device           253:18
        --
          LV Name                /dev/hf/copy_volume
          VG Name                hf
          LV UUID                oGK0gG-o62D-Tu84-9CW0-rvPb-H7HX-bjUwk0
          LV Write Access        read/write
          LV snapshot status     INACTIVE destination
        for /dev/hf/base_volume
          LV Status              available
          # open                 0
          LV Size                32.00 MB
          Current LE             1
          COW-table size         64.00 MB
          COW-table LE           2
          Snapshot chunk size    8.00 KB
          Segments               1
          Allocation             inherit
          Read ahead sectors     0
          Block device           253:20
           
        [root at localhost ~]# lvremove /dev/hf/copy_volume 
          /dev/dm-20: read failed after 0 of 4096 at 0: Input/output
        error
        Do you really want to remove active logical volume
        "copy_volume"? [y/n]: y
          Logical volume "copy_volume" successfully removed
        [root at localhost ~]# lvcreate -s -L 64M -n \
        copy_volume /dev/hf/base_volume 
          Logical volume "copy_volume" created
        [root at localhost ~]# lvdisplay |grep -A 13 "_volume"
          LV Name                /dev/hf/base_volume
          VG Name                hf
          LV UUID                qPzWgG-ON3V-swUr-O0IP-I172-G3YV-GH431K
          LV Write Access        read/write
          LV snapshot status     source of
                                 /dev/hf/copy_volume [active]
          LV Status              available
          # open                 0
          LV Size                32.00 MB
          Current LE             1
          Segments               1
          Allocation             inherit
          Read ahead sectors     0
          Block device           253:18 
        --
          LV Name                /dev/hf/copy_volume
          VG Name                hf
          LV UUID                LSUqQB-O2n4-8zmk-iL9n-2vDQ-qSsB-yOBDL1
          LV Write Access        read/write
          LV snapshot status     active destination
        for /dev/hf/base_volume
          LV Status              available
          # open                 0
          LV Size                32.00 MB
          Current LE             1
          COW-table size         64.00 MB
          COW-table LE           2
          Allocated to snapshot  0.02% 
          Snapshot chunk size    8.00 KB
          Segments               1
          Allocation             inherit
          Read ahead sectors     0
          Block device           253:20
           
        [root at localhost ~]# dd if=/dev/zero of=/dev/hf/copy_volume 
        dd: writing to `/dev/hf/copy_volume': No space left on device
        65537+0 records in
        65536+0 records out
        33554432 bytes (34 MB) copied, 9.5375 s, 3.5 MB/s
        [root at localhost ~]# lvdisplay |grep -A 13 "_volume"
          LV Name                /dev/hf/base_volume
          VG Name                hf
          LV UUID                qPzWgG-ON3V-swUr-O0IP-I172-G3YV-GH431K
          LV Write Access        read/write
          LV snapshot status     source of
                                 /dev/hf/copy_volume [active]
          LV Status              available
          # open                 0
          LV Size                32.00 MB
          Current LE             1
          Segments               1
          Allocation             inherit
          Read ahead sectors     0
          Block device           253:18
           
          --- Logical volume ---
          LV Name                /dev/hf/F4_burn
          VG Name                hf
          LV UUID                Bj1VJS-1JUK-BA18-egFj-xOoY-qrbq-jbZFFY
        --
          LV Name                /dev/hf/copy_volume
          VG Name                hf
          LV UUID                LSUqQB-O2n4-8zmk-iL9n-2vDQ-qSsB-yOBDL1
          LV Write Access        read/write
          LV snapshot status     active destination
        for /dev/hf/base_volume
          LV Status              available
          # open                 0
          LV Size                32.00 MB
          Current LE             1
          COW-table size         64.00 MB
          COW-table LE           2
          Allocated to snapshot  50.12% 
          Snapshot chunk size    8.00 KB
          Segments               1
          Allocation             inherit
          Read ahead sectors     0
          Block device           253:20
           
        [root at localhost ~]# exit
        
        Script done on Tue 12 Feb 2008 02:13:07 PM BRST
        [Gui at localhost:~]$ 
        
        





More information about the linux-lvm mailing list