QEMU - Resize a virtual Disk (from the GUI)


Recommended Posts

Hi, I found out that you can resize the Vdisk ONLINE without a shutdown of the VM by using this command in SSH in the Unraid CLI :

 

virsh qemu-monitor-command "NAME_OF_THE_DOMAIN" block_resize  drive-virtio-disk2  100G --hmp

In this command, the "NAME_OF_THE_DOMAIN" is what you have in the GUI when creating/editing a VM (Name).  The "drive-virtio-disk2" is usually the disk (can be any other disk too). 

 

It would be really nice if you could add "right-click" resize disk menu on a Running VM and then select one of the disk that could show-up in a submenu and then ask for the new size (in GB).

 

After that, it's up to the user to go inside his VM (thru RDP or VNC) and rescan the disk (Disk Management in windows) and then "extend" the Partition :)

 

You can find the "virtio-disk" from looking the XML view when editing a VM in the Unraid GUI.  Look for "alias" and you then prepend "drive-" before when running the command to extend the size.   

 

   <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/user/domains/Windows 10/vdisk1.img'/>
      <backingStore/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <alias name='virtio-disk2'/>

 

 

Edited by Pducharme
Link to comment
12 hours ago, bastl said:

Does it work for reduce the size off the vdisk? If so, than thats the easiest way to break your VM. 🤨

 

did not try, but probably.  I needed only to increase the size.  If they add it to GUI, they could know the actual size (they display it) and then they could allow only greater size ;) this way it's sure it won't break.

Link to comment

@Pducharme You can resize a vdisk via the gui for a long time already if you not noticed it. But only if the VM is turned off. Leftclick the name of the VM in the VMs tab and you can see the actual size of the VM. Click the number and you can change the value. Last time I tried to reduce the size this way it worked. The issue is, unraid maybe knows how much is allocated, but it doesn't know where blocks are so to say. If your data is at the end of the file, unraid will cut it of. I know, you can reduce the partition size inside the VM and than reduce it, but still thats not a accurate way to do it.

Link to comment
On 8/6/2019 at 7:40 AM, bastl said:

@Pducharme You can resize a vdisk via the gui for a long time already if you not noticed it. But only if the VM is turned off. Leftclick the name of the VM in the VMs tab and you can see the actual size of the VM. Click the number and you can change the value. Last time I tried to reduce the size this way it worked. The issue is, unraid maybe knows how much is allocated, but it doesn't know where blocks are so to say. If your data is at the end of the file, unraid will cut it of. I know, you can reduce the partition size inside the VM and than reduce it, but still thats not a accurate way to do it.

Having already created a script what increase and decreases the img file its easier and more productive not to turn a running vm , time lost booting . shutting down and reloading all the programs up from boot , could take 10 mins or so , a simple increase by decrease by would be so beneficial to say the least time taken 5 seconds , thats productivity ... and no down time if running servers on vms 

Link to comment
14 hours ago, Whizadree said:

Having already created a script what increase and decreases the img file its easier and more productive not to turn a running vm , time lost booting . shutting down and reloading all the programs up from boot , could take 10 mins or so , a simple increase by decrease by would be so beneficial to say the least time taken 5 seconds , thats productivity ... and no down time if running servers on vms

Serious question, how often do you change the size of your VMs? 100 times a day? 😂

 

The majority of users of Unraid, let me guess 95% or even more using Unraid in their home environment or in small offices. That small portion of "office people" will never use that feature as a "productivity" feature as you called it. To have that feature available via the GUI for everyone would be great as long as it is save. Don't get me wrong, but I have read a lot of people here in the chat that already broke there VMs by reducing the size of a vdisk.

Link to comment
31 minutes ago, -Daedalus said:

I have a base VM images that I use when deploying different OSs. Usually these are minimum size, and get expanded as required depending on use-case.

Not discounting the value of the suggestion, which I personally have no need for but certainly can see a valid use case, but I'm wondering about your workflow. Normally vdisk files are sparse, so no matter how large or small you allocate, they only take up as much space as actually used by the files inside. So, why not just set up the base images with the size you need to begin with? It's not going to change the amount of space they occupy.

  • Like 1
Link to comment
On 8/8/2019 at 7:51 AM, bastl said:

Serious question, how often do you change the size of your VMs? 100 times a day? 😂

 

The majority of users of Unraid, let me guess 95% or even more using Unraid in their home environment or in small offices. That small portion of "office people" will never use that feature as a "productivity" feature as you called it. To have that feature available via the GUI for everyone would be great as long as it is save. Don't get me wrong, but I have read a lot of people here in the chat that already broke there VMs by reducing the size of a vdisk.

no abt 3 times a month and also testing servers so once the standard 30gb is complete then its current long winded to keep expanding , just added another 12tb 6tb x 2 so i dont go all in i keep expanding them by 500gb until the user wishes to add more only when and only when do they really need it i will expand , my wife vm , sons vm . security system ,gaming vm/ steam os / and my remote backup linux system for when im away are only upgraded as and when it reduces the want to download and install everything online and in sight 

at present i just use separate scripts to expand 500g at a time , for each vm and i also do a copy prior  , no screwups ever  as the img gets automatically dumped into the 20TB Backup once the script runs again it removes the previous 

regarding reducing , thats something you have to fully understand , !! WARNING !! it theres no difference in accidentally removing and removing vm + disk . 

truthfully i have never gone down only expanded , yet if a feature would ever exist a double confirm is all thats needed and maybe a backup just incase . 

regarding the % of users 5% is not a bad amount of users considering how many  use ups settings , the use of CA and installing an incorrect plugin that you dont know how to properly operate can kill a server as quickly as a negative downgrade in vm image . its a setting thats there for usefulness to some not all . its also the users operational knowledge and competency , if you dont know what you are doing and you ^^^^ it up , do users have to go without because of the few that bork their systems through no fault of their own ?

 

Edited by Whizadree
Link to comment
6 hours ago, Squid said:

If you don't switch the vdisk type, the image will always grow, and never shrink, as space once allocated is never released by the vdisk.  This lets the vdisk shrink automatically.

https://forums.unraid.net/topic/51703-vm-faq/#comment-557606

 

theres a note there that says 
 

>>>Note: If after this you edit the VM using the GUI editor these changes will be lost and will need to be redone.

if the option was in the GUI to add that unmap option , would it help?

 

 

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.