Re: Virtualization With KVM On Ubuntu 8.10 (Problems with LVM)

Discussion in 'HOWTO-Related Questions' started by frippz, Jan 14, 2009.

  1. frippz

    frippz New Member

    This question is specific to part 6 of Virtualization With KVM On Ubuntu 8.10, specifically Creating an LVM based VM.

    I've followed the guide exactly and yet everytime after I've converted the qcow2 image to a LV using
    Code:
    qemu-img convert disk0.qcow2 -O raw /dev/volumegroup/logicalvolume
    , I get the following error:

    Code:
    Boot from (hd0,0) ext3 894e741d-97b0-461a-9709-147b24506905
    Starting up ...
    
    crc error
    
     -- System halted
    I saw another user in the Ubuntu forums that experienced the exact same problem, but no one had a solution (he had followed the same guide). People who have installed directly onto a LV did not experience this issue, but as far as I know, ubuntu-vm-builder does not yet support this.

    Any help with this would be very much appreciated!
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Not sure what it is. Did you create a filesystem on /dev/volumegroup/logicalvolume, or did you just create the LV with lvcreate, nothing more?

    Any errors in your logs?
     
  3. frippz

    frippz New Member

    I just created the LV with lvcreate, yes. Then I used qemu-img to convert the image file.

    Code:
    qemu-img convert disk0.qcow2 -O raw /dev/mogwai/milltime
    The only thing that shows up in /var/log/libvirt/qemu/milltime.log is:

    Code:
    /usr/bin/kvm -S -M pc -m 1024 -smp 1 -name milltime -monitor pty -boot c -drive file=/dev/mogwai/milltime,if=ide,index=0,boot=on -net nic,macaddr=52:54:00:09:91:db,vlan=0 -net tap,fd=14,script=,vlan=0,ifname=vnet2 -serial none -parallel none -usb -vnc 0.0.0.0:1 
    char device redirected to /dev/pts/5
    info cpus
    Doesn't say much, from what I can tell. Are there any other logs I can check?

    edit: This wasn't mentioned specifically in the guide, but I did boot the machine from the disk0.qcow2 image first, in order to change the password for the account. I then proceeded to shut it down (from within the VM using sudo shutdown -h now) and changed the config file to point to the LV instead of the image file, redefined the VM in virsh and started it up again, which resultet in the crc error and "System halted"

    edit2: Oh yeah, here's the xml-file for the VM

    Code:
    <domain type='kvm'>
      <name>milltime</name>
      <uuid>0a721358-9107-aa88-2ca5-92b983865adb</uuid>
      <memory>1048576</memory>
      <currentMemory>1048576</currentMemory>
      <vcpu>1</vcpu>
      <os>
        <type>hvm</type>
        <boot dev='hd'/>
      </os>
      <features>
        <acpi/>
      </features>
      <clock offset='utc'/>
      <on_poweroff>destroy</on_poweroff>
      <on_reboot>restart</on_reboot>
      <on_crash>destroy</on_crash>
      <devices>
        <emulator>/usr/bin/kvm</emulator>
        <disk type='file' device='disk'>
          <source file='/dev/mogwai/milltime'/>
          <target dev='hda' bus='ide'/>
        </disk>
        <interface type='bridge'>
          <mac address='52:54:00:09:91:db'/>
          <source bridge='br0'/>
        </interface>
        <input type='mouse' bus='ps2'/>
        <graphics type='vnc' port='-1' listen='0.0.0.0'/>
      </devices>
    </domain>
     
    Last edited: Jan 15, 2009
  4. joostvdl

    joostvdl Member

    Same problem here

    Hi

    I have the same problem here.

    Still looking for an answer.

    Another problem I found with VM BUilder is that the memory calculation is not correct. It gives no good result.
     
  5. frippz

    frippz New Member

    I just finished some testing using qemu-img to convert the qcow2 file to a raw file, just to see if that would work to boot from, which it did actually. So I'm guessing that something goes wrong when the conversion goes straight to the LV. I just wish I knew what exactly...

    edit: Just for fun, I tried to use dd to copy the raw file to the LV. Lo and behold, the damn thing could now boot off the LV. A little hassle with this workaround, sure, but it seems to work. :)

    I'm not quite ready to call this one solved yet, but it's a very good start! :)
     
    Last edited: Jan 15, 2009
  6. falko

    falko Super Moderator Howtoforge Staff

    Ok, that's the correct way.

    I wonder why it worked for, and why so many users have this problem now - maybe Ubuntu updated the packages since I wrote the tutorial? I think I have to check again when I find some time...
     
  7. joostvdl

    joostvdl Member

    Current solution

    This is how I convert an qemu disk image to an LVM volume. It is to be noted that in the Logical Volume the same partitions are created as in the image file. So directly mounting of an LVM is not possible. To do that use kpartx to create multiple loopback devices which are mountable.

    {10G is total disksize of RAW file as defined in vmbuilder.partation}
    {VG01 is name of LVM volume group}

    Change server-01.xml in /etc/libvirt/qemu:
    Code:
        <disk type='block' device='disk'>
          <source dev='/dev/VG01/server-01_disk0'/>
          <target dev='hda' bus='ide'/>
        </disk>
     
    Last edited: Jan 23, 2009
  8. Slasher

    Slasher New Member

    The problem seems to be that qemu-img convert doesn't overwrite the entire volume and if the volume contains non-zeroed data that will confuse the file system. So you need to do dd bs=1M if=/dev/zero of=LVM_volume before calling qemu-img to write the output directly to the LV.
     
  9. Nakarti

    Nakarti New Member

    Yay, how to put Windows XP on KVM LVM

    May we all thank Frippz for the procedure to get Windows XP working as LVM in a KVM guest!
    I think the reason direct copy doesn't work is that it retains the MBR in a different location for qcow, but LVM only functions as a raw disk... (That is probably why my LVM install isn't working: I didn't specify raw.)

    (Removed the quote because it was mangled)
    So: Install Windows to a qcow file, qemu-img convert it to raw, dd that to LVM, and boot LVM.
     
    Last edited: Jan 16, 2012
  10. Nakarti

    Nakarti New Member

    Now I get a green screen instead of boot! What the fish!

    (ps. Seriously? Not working 3 years later? Does *anybody* do this?)
     
    Last edited: Jan 17, 2012

Share This Page