S
S
sllrod2015-08-02 14:53:13
Xen
sllrod, 2015-08-02 14:53:13

Reducing the actual size of the XEN disk image. Is it possible to?

Colleagues, good afternoon.
Two cases:

  1. I make an hdd image using dd, transfer it in a compressed state via nfs to another server:
    mount -o ro,remount /
    dd if=/dev/sda bs=64K | gzip -c > /share/test.img.gz

    after gunzip I get a 20GB (for example) file finished with zeros at the end:
    du -h /md/share/test.img
    21G /md/share/test.img

  2. I create an empty image through the same dd:
    dd if=/dev/zero of=/md/share/test2.img bs=1024k seek=20480 count=0

    And I get the file:
    du -h /md/share/test2.img
    0 /md/share/test2.img
    ls -lah /md/share/test2.img
    -rw-r--r-- 1 root root 20G Aug 2 2:46 pm / md/share/test2.img

    After that, having mounted it, I can easily write anything to the VM, the file size will be equal to the actual content (but not more than 20GB).

Question! how to reduce file size for 1 case?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Pechersky, 2015-08-02
@Vasily_Pechersky

Use qcow format which works in thin provisioning mode.
But the performance drops noticeably.

S
sllrod, 2015-08-03
@sllrod

Answered on Serverfault:
serverfault.com/questions/710299/reduce-xen-image-...
In short, add conv=sparse to dd and pack with tar --sparse .
Only here is sparse for Centos 5.11 dd no) https://bugzilla.redhat.com/show_bug.cgi?id=908980

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question