Azure VM using custom image Failing

Sarangi, Bibhudatta 20 Reputation points
2023-02-11T02:26:11.72+00:00

I have a Ubuntu image in the .ova format. I am trying to use it as an image for creating a VM.

Below are the steps followed :

1>Extracted the VMDK file from the OVA file using 7z x

ls -lrt

total 5876444

-rwxrwx--- 1 root root 3008732672 Feb 11 08:45 caz4.5.ova

-rwxrwx--- 1 root root      12241 Feb 11 08:45 caz4.5.ovf

-rwxrwx--- 1 root root 3008718336 Feb 11 08:46 caz4.5-disk001.vmdk

-rwxrwx--- 1 root root        131 Feb 11 08:46 caz4.5.mf

2> Created a fixed variant VHD file

VBoxManage clonemedium caz4.5-disk001.vmdk caz4.5-disk001.vhd --format VHD --variant fixed

3> Tried creating an image using the VHD file but got error "has an unsupported virtual size of 35422.09375 MB. The size must be a whole number in MBs

4> Referring below Microsoft site tried to re-size VHD file

https://learn.microsoft.com/en-us/azure/virtual-machines/linux/create-upload-generic

5> Its tries to create the raw file but eventually fails giving below error. I have also tried to create the raw file using the VMDK file which i got while extracting the OVA but no luck

Can you please advise here and let me know what can be done to fix it.

qemu-img convert -f vpc -O raw caz4.5-disk001.vhd caz4.5.raw

qemu-img convert -f vmdk -O raw caz4.5-disk001.vmdk caz4.5.raw

qemu-img: Could not open 'caz4.5.raw': Could not open 'caz4.5.raw': No such file or directory

ls -lrt

total 0

-rwxrwx--- 1 root root  3008732672 Feb 11 08:45 caz4.5.ova

-rwxrwx--- 1 root root       12241 Feb 11 08:45 caz4.5.ovf

-rwxrwx--- 1 root root         131 Feb 11 08:46 caz4.5.mf

-rwxrwx--- 1 root root  3008718336 Feb 11 08:46 caz4.5-disk001.vmdk

-rwxrwx--- 1 root root 37142790144 Feb 11 08:54 caz4.5.raw

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,013 questions
0 comments No comments
{count} votes

Accepted answer
  1. vipullag-MSFT 26,487 Reputation points Moderator
    2023-02-13T02:29:00.18+00:00

    Hello Sarangi, Bibhudatta

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    Based on the the error message "Could not open 'caz4.5.raw': Could not open 'caz4.5.raw': No such file or directory" suggests that the file doesn't exist in the specified location.

    Try the following steps and see if that helps:

    -Make sure the qemu-img command is installed on your machine. If not, install it using your system's package manager.

    -Ensure that you have sufficient disk space to create the raw file.

    -Check the file path for the input and output files in the qemu-img command. Make sure the path is correct and accessible.

    -If the above steps do not resolve the issue, try converting the file using a different file format, such as qcow2 or qed.

    Here's an example command to convert the file to qcow2 format:
    qemu-img convert -f vpc -O qcow2 caz4.5-disk001.vhd caz4.5.qcow2

    Also, the error message you are getting is related to the virtual size of the VHD file. To fix this issue, you will need to resize the VHD file to a multiple of 1 MiB. ou can use the qemu-img tool to resize the VHD file.

    Please try below steps:

    -Convert the VMDK file to a raw file using the following command:

    qemu-img convert -f vmdk -O raw caz4.5-disk001.vmdk caz4.5.raw

    -Use the qemu-img tool to resize the raw file to a multiple of 1 MiB:

    qemu-img resize caz4.5.raw +1M
    -Convert the raw file back to a VHD file:

    qemu-img convert -f raw -O vpc caz4.5.raw caz4.5-disk001.vhd

    Try creating an image using the resized VHD file.

    Ref:

    https://learn.microsoft.com/en-us/azure/virtual-machines/linux/create-upload-generic
    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/prepare-for-upload-vhd-image

    Please note that you may also need to rebuild the initrd or initramfs image for the Linux distribution you are using. You can refer to the documentation of your Linux distribution for instructions on how to do this.

    Also, make sure that you are using a compatible version of qemu-img. There is a known bug in qemu-img versions >=2.2.1 that results in an improperly formatted VHD. The issue has been fixed in QEMU 2.6. We recommend using either qemu-img 2.2.0 or lower, or 2.6 or higher.

    Hope this helps.

    If you need further help on this, tag me in a comment.

    If the suggested response helped you resolve your issue, please 'Accept as answer', so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sarangi, Bibhudatta 20 Reputation points
    2023-02-13T15:04:10.8166667+00:00

    Thank You @vipullag-MSFT for your response.

    To clarify while attempting to create caz4.5.raw using below command. The output file is getting created initially in the same folder but its end up reporting " No such file or directory"

    qemu-img convert -f vmdk -O raw caz4.5-disk001.vmdk caz4.5.raw

    -rwxrwx--- 1 root root  3008732672 Feb 11 08:45 caz4.5.ova

    -rwxrwx--- 1 root root       12241 Feb 11 08:45 caz4.5.ovf

    -rwxrwx--- 1 root root         131 Feb 11 08:46 caz4.5.mf

    -rwxrwx--- 1 root root  3008718336 Feb 11 08:46 caz4.5-disk001.vmdk

    -rwxrwx--- 1 root root 37142790144 Feb 11 08:54 caz4.5.raw

    I have mounted my blobstorage into my linux VM and creating it over there. Hope it will take care of the storage part and space shouldn't be an issue.

    Also i am using latest version qemu.

    My goal is to extract the raw file from the VMDK image and then re-size in MB multiple and then converting it to fixed size VHD file so that i can use it to create the VM using it.

    Please assist further.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.