View Single Post
  #1  
Old 7th March 2010, 02:58
yowzator yowzator is offline
Junior Member
 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ubuntu 9.10 with KVM and copying KVM disk image to LVM

This is in reference to Virtualization with KVM on Ubuntu 9.10, but pertains to basic disk imaging features as well.

Problem
I'm getting a No space left on device error when doing a dd command. I'm trying to move a KVM qcow2 file to an LVM partition and thought that the LVM partition needed to be the same size as the sum of the partitions in the vmbuilder.partition file. Here's the error output:

Code:
    root@bond:/tmp/zing-UZFgZpj1# dd if=disk0.raw of=/dev/vol/zing bs=1M
    dd: writing `/dev/vol/zing': No space left on device
    3001+0 records in
    3000+0 records out
    3145728000 bytes (3.1 GB) copied, 32.5236 s, 96.7 MB/s
I can use the new copy and everything still seems to work fine. I'm assuming I should be worried though. When I use dd to copy it to another file, the size of the file is slightly larger than the LVM partition! See below for details.

Additional details

I'm using KVM and vmbuilder to create the disk image. My vmbuilder.partition file looks like this (a total of 3000MB):

Code:
   root 2000
    swap 1000
So I first create an LVM partition big enough to hold the VM. I thought it was supposed to be the same size as the sum of the partitions, but is this not correct? Should I make it 3001M?

Code:
    root@bond:~/vmbuilder# lvcreate -L3000M -n zing vol
       Logical volume "zing" created
Then I use vmbuilder to create the disk image:

Code:
    root@bond:~/vmbuilder# vmbuilder kvm ubuntu -o \
    	--templates=/root/vmbuilder/templates \
    	--ip=192.168.0.225 \
    	--hostname=zing \
    	--raw=/dev/vol/zing \
    	--part=/root/vmbuilder/appliances/jetty/vmbuilder.partition \
    	--pass=7dhsLzUp \
    	--dest=/tmp/zing-UZFgZpj1 \
    	--user=zing \
        --mem=2048 \
        --firstboot=/tmp/boot-UZFgZpj1.sh \
        --copy=/tmp/copyfiles-UZFgZpj1 \
    	--addpkg=jetty ;
When it's done, I convert the qcow2 file to a raw file:

Code:
    root@bond:/tmp/zing-UZFgZpj1# ls -al
    total 447892
    drwxr-xr-x 2 root root      4096 2010-03-06 16:51 .
    drwxrwxrwt 5 root root      4096 2010-03-06 16:51 ..
    -rw-r--r-- 1 root root 458752000 2010-03-06 16:51 disk0.qcow2

    root@bond:/tmp/zing-UZFgZpj1# qemu-img convert disk0.qcow2 -O raw disk0.raw
    root@bond:/tmp/zing-UZFgZpj1# ls -al
    total 891384
    drwxr-xr-x 2 root root       4096 2010-03-06 17:32 .
    drwxrwxrwt 5 root root       4096 2010-03-06 16:51 ..
    -rw-r--r-- 1 root root  458752000 2010-03-06 16:51 disk0.qcow2
    -rw-r--r-- 1 root root 3146776576 2010-03-06 17:32 disk0.raw
Lastly, I copy it to the LVM partition:

Code:
    root@bond:/tmp/zing-UZFgZpj1# dd if=disk0.raw of=/dev/vol/zing bs=1M
    dd: writing `/dev/vol/zing': No space left on device
    3001+0 records in
    3000+0 records out
    3145728000 bytes (3.1 GB) copied, 32.5236 s, 96.7 MB/s
So some additional tests (copy to another file, not LVM):

Code:
    root@bond:/tmp/zing-UZFgZpj1# dd if=disk0.raw of=zing.disk bs=1M
    3001+0 records in
    3001+0 records out
    3146776576 bytes (3.1 GB) copied, 4.64961 s, 677 MB/s

    root@bond:/tmp/zing-UZFgZpj1# ls -l
    total 3964404
    -rw-r--r-- 1 root root  458752000 2010-03-06 16:51 disk0.qcow2
    -rw-r--r-- 1 root root 3146776576 2010-03-06 17:32 disk0.raw
    -rw-r--r-- 1 root root 3146776576 2010-03-06 17:33 zing.disk
Again, I'm not having any problems using the LVM partition with a KVM virtual machine, but should I be worried about it? It's size is 1,048,576 bytes (exactly 1MB) smaller than the original image file. Should I be adding 1MB to the LVM partition when I create it?

Code:
    root@bond:~/vmbuilder# lvremove /dev/vol/zing
    Do you really want to remove active logical volume "zing"? [y/n]: y
      Logical volume "zing" successfully removed
    
    root@bond:~/vmbuilder# lvcreate -L3001M -n zing vol
      Rounding up size to full physical extent 2.93 GB
      Logical volume "zing" created
    
    root@bond:/tmp/zing-UZFgZpj1# dd if=disk0.raw of=/dev/vol/zing bs=1M
    3001+0 records in
    3001+0 records out
    3146776576 bytes (3.1 GB) copied, 31.0581 s, 101 MB/s
Now I've created a partition that's size has been rounded up, but the copy fits in it.

What is the right process for copying qcow2 files to LVM partitions? Also, any idea why is it so much faster copying to a file than to an LVM device?
Reply With Quote
Sponsored Links