Resize (grow) a .img file


luca2

Recommended Posts

Hi,

I have managed to grow a .qcow2 file succesfully, but cannot make it with the default .img file that is created when using the built-in functionality in Unraid to create vm´s.

I used to type this command...and this is what I get:

root@Tower:/mnt/vm# qemu-img resize vdisk1.img +60G
WARNING: Image format was not specified for 'vdisk1.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
Image resized.

I am running v6.0.1.

Hope someone can help.

Link to comment

Hi,

I have managed to grow a .qcow2 file succesfully, but cannot make it with the default .img file that is created when using the built-in functionality in Unraid to create vm´s.

I used to type this command...and this is what I get:

root@Tower:/mnt/vm# qemu-img resize vdisk1.img +60G
WARNING: Image format was not specified for 'vdisk1.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
Image resized.

I am running v6.0.1.

Hope someone can help.

Since the error message implies you need to specify you need to give the format for raw images in the parameters have you tried the command

 qemu-img resize -fmt raw vdisk1.img +60G

Link to comment

Hi, thx for trying. This is waht I get:

root@Tower:/mnt/vm# qemu-img resize -fmt raw vdisk1.img +60G
qemu-img: Expecting one image file name
Try 'qemu-img --help' for more information

Any other idea?

Looking at the help from qemu-img it does not seem to have any option on the resize mode to specify a format.  All I can think is that you convert the raw format to some other one that can be resized, resize that, and then convert back. 

 

It may be possible to resize a raw image using the Linux 'truncate' command to extend the file, but I am not sure.

Link to comment

Jonp, I love kvm vodoo magic. I am not an expert in linux, but I love this!

I have been posting before that I could not grow (resize) my .img created by unraid (using the tool to create vm´s in VM menu).

Just a couple of minutes ago, I checked again my .img using "qemu-img info" and I could not believe it:

root@Tower:/mnt/vm# qemu-img info vdisk1.img
image: vdisk1.img
file format: raw
virtual size: 100G (107374182400 bytes)
disk size: 17G

My original .img of 40G did actually grow to 100G!

How did this happen?

Based on previous fighting with kvm for months (while creating my vm´s) I always backup my command line inputs in putty, so this is what I found out.

I did again grow my .img +20G ... so here again vodoo magic was happening:

root@Tower:/mnt/vm# qemu-img info vdisk1.img
image: vdisk1.img
file format: raw
virtual size: 100G (107374182400 bytes)
disk size: 17G
root@Tower:/mnt/vm# qemu-img resize vdisk1.img +20G
WARNING: Image format was not specified for 'vdisk1.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
Image resized.
root@Tower:/mnt/vm# qemu-img info vdisk1.img
image: vdisk1.img
file format: raw
virtual size: 120G (128849018880 bytes)
disk size: 17G

Thx all for support.

I wish I was rich and could play more with kvm  8)

Hope this help others.

Rgds.

 

 

Link to comment
  • 2 years later...
  • 2 months later...
On 11/21/2017 at 8:25 PM, busa1 said:

I'm not sure if anyone is still reading this, but just by increasing the size of the vm, that data doesn't get allocated, if I'm right. Anyone know how to allocate data on ubuntu server? (Only using command line)

You should be able to use gparted to do that.  Always best to have a backup first.

Link to comment

I am facing the same issue at the moment... I increased the Filesystem with Unraid Webinterface but it is not allocated. I tried running gparted on my UbuntuServer VM without success. Any suggestions how I can extend the filesystem?

sss.png

Edited by dweb
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.