You are not logged in.
Hi all,
I would like to move disk images of some virtual machines to thinly provisioned lvm volumes.
The VM disk image is in a sparse raw file:
root@penny smb # ls -lksh vm-win10.raw
24G -rw-r--r-- 1 root root 80G Feb 24 18:45 vm-win10.rawIt takes 24G to store the 80G disk.
I created a thin logical volume as described in lvmthin(7) man page:
root@penny smb # lvcreate -n vm-win -V 85899345920b --thinpool pool0 vg0
Logical volume "vm-win" createThen, I dd'd the disk to the logical volume
root@penny smb # dd if=vm-win10.raw of=/dev/vg0/vm-win bs=1k status=progress
85831631872 bytes (86 GB, 80 GiB) copied, 2022 s, 42.4 MB/s
83886080+0 records in
83886080+0 records out
85899345920 bytes (86 GB, 80 GiB) copied, 2023.69 s, 42.4 MB/sIt seems zero chunks were written to vm-win as well and the size of the logical volume is 80G and not 24G
root@penny smb # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
arch vg0 -wi-ao---- 300.00g
pool0 vg0 twi-aotz-- 300.00g 35.67 7.03
vm-win vg0 Vwi-a-tz-- 80.00g pool0 100.00
work vg0 Vwi-aotz-- 100.00g pool0 27.01 What went wrong? I know there are other ways to store VM disks, but I'd like to learn more about thin provisioning.
Thanks
Offline
by default dd copies everything, zero or not, dd does not care
but then, dd has conv=sparse to skip zero
use it with caution (only reliable if the target will actually return zero for the skipped areas - as there may be deliberate non-free zero)
other option would be to run fstrim after the copy, or copy files instead of raw
you can also query extents with filefrag then copy each extent individually, but that requires even more care to get all the correct segments at the correct offsets
Last edited by frostschutz (2019-02-25 17:06:37)
Offline
conv=sparse did the trick
root@penny smb # dd if=vm-win10.raw of=/dev/vg0/vm-win conv=sparse bs=4k status=progress
83788333056 bytes (84 GB, 78 GiB) copied, 880 s, 95.2 MB/s
20971520+0 records in
20971520+0 records out
85899345920 bytes (86 GB, 80 GiB) copied, 881.115 s, 97.5 MB/s
root@penny smb # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
arch vg0 -wi-ao---- 300.00g
pool0 vg0 twi-aotz-- 300.00g 17.31 4.28
vm-win vg0 Vwi-a-tz-- 80.00g pool0 31.16
work vg0 Vwi-aotz-- 100.00g pool0 27.01 Offline