Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > HOWTO-Related Questions

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 7th March 2010, 15:20
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,713 Times in 2,556 Posts
Default

As you already said, it seems as if the logical volume needs to be a little bit bigger than the partitions in the vmbuilder.partition file.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 7th March 2010, 23:44
yowzator yowzator is offline
Junior Member
 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by falko View Post
As you already said, it seems as if the logical volume needs to be a little bit bigger than the partitions in the vmbuilder.partition file.
Thanks Falko. I'm now thinking it is slightly bigger to make room for the partition table and MBR. Does this make sense?

Why did you not have this problem in your howto? Perhaps on your system, the sizes you defined didn't perfectly fit into a physical extent, so there was still room? Should the howto be updated to reflect this possible issue?

By the way, your howto doesn't say anything about having to use qemu-img and dd, but I couldn't get it onto the LVM without doing this. Does the howto really work? If so, why do I need to add these steps?

Thanks again,
Tauren
Reply With Quote
  #4  
Old 8th March 2010, 13:29
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,713 Times in 2,556 Posts
Default

Quote:
Originally Posted by yowzator View Post
By the way, your howto doesn't say anything about having to use qemu-img and dd, but I couldn't get it onto the LVM without doing this. Does the howto really work? If so, why do I need to add these steps?
Yes, it worked for me as explained in the tutorial. On 9.04, it was different (see http://www.howtoforge.com/virtualiza...ubuntu-9.04-p4 ).
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Tags
kvm, lvm, ubuntu 9.10

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:14.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.