I am trying to upload a disk image for use on the Azure cloud platform. I've been following through these instructions, but image resizing is giving me a hard time.
I start out with a qcow2 image:
$ qemu-img info --output=json myimage.qcow2
{
"virtual-size": 8589934592,
"filename": "myimage.qcow2",
"cluster-size": 65536,
"format": "qcow2",
"actual-size": 1468272640,
"format-specific": {
"type": "qcow2",
"data": {
"compat": "0.10",
"refcount-bits": 16
}
},
"dirty-flag": false
}
I convert this image into a raw disk:
$ qemu-img convert -f qcow2 -O raw myimage.qcow2 myimage.img
Then, following along with the instructions, I round the size of to an even number of megabytes:
$ MB=$((1024 * 1024))
$ size=$(qemu-img info -f raw --output json "$1" |
gawk 'match($0, /"virtual-size": ([0-9]+),/, val) {print val[1]}')
$ rounded_size=$((($size/$MB + 1) * $MB))
$ echo $rounded_size
8590983168
And resize the image:
$ qemu-img resize -f raw myimage.img $rounded_size
Which gets me:
$ qemu-img info -f raw --output=json myimage.img
{
"virtual-size": 8590983168,
"filename": "myimage.img",
"format": "raw",
"actual-size": 1458573312,
"dirty-flag": false
}
(That's exactly 8193 MB).
When I convert this to VHD format:
$ qemu-img convert -f raw -o subformat=fixed -O vpc myimage.img myimage.vhd
I end up with a file that is no longer the correct size:
$ ls -l myimage.vhd
-rw-r--r--. 1 lars lars 8591450624 Apr 14 12:04 myimage.vhd
And when I try to upload this, Azure yells at me:
$ azure vm image create myimage myimage.vhd --os Linux --location 'East US'
info: Executing command vm image create
+ Retrieving storage accounts
info: VHD size : 8193 MB
info: Uploading 8390088.5 KB
...
info: https://....blob.core.windows.net/vm-images/myimage.vhd was uploaded successfully
error: The VHD https://....blob.core.windows.net/vm-images/myimage.vhd has an unsupported virtual size of 8591450112 bytes. The size must be a whole number (in MBs).
info: Error information has been recorded to /home/lars/.azure/azure.err
error: vm image create command failed
How do I appease the Azure monster and make it stop yelling at me?
(FYI: I am using: qemu-img version 2.5.0 (qemu-2.5.0-10.fc23)
)