Manipulate image file of VM (make it smaller?)


m4f1050

Recommended Posts

Is there a way I can make my image file smaller after I uninstall several apps that take up a lot of space (or reset Windows 10 and start from scratch?)

Maybe creating a new image from the original image (BUT somehow only copy data sectors and not free sectors?)

 

Right now my image file is 110 gigs, it's set to grow, but I uninstalled a lot of apps and deleted a lot of install files and files that took a lot of space, and right now I am only using 50~60 gigs worth, not 110 gigs.

 

Thanks!

Edited by m4f1050
Link to comment

I ran defrag on Windows 2008R2 then I ran SDelete -z to simulate a "TRIM" by zeroing the free space

Also I went ahead and took a further step, I reconverted the image with compression:
 

mv win10.img win10.img.bak
qemu-img convert -O qcow2 win10.img.bak win10.img

mv win2k.img win2k.img.bak
qemu-img convert -O qcow2 win2k.img.bak win2k.img

 


Win 10 from a 135gigs image it compressed to a 58gigs image (the OS is using 95gigs)
Win 2008R2 from a 130gigs image it compressed to a 60gigs image (the OS is using 63gigs) -- No trim, used SDelete from Sysinternals to zero empty sectors.

Got another question, is the docker.img file QCOW2?  Thinking about compressing that one too.   🙂

 

EDIT:  ***DO NOT USE SDelete***  It made the image bigger.  I did SDelete on the Win 10 and then compressed it and from 58gigs it went to 97gigs -- NOT WORTH IT -- I bet if I wouldn't have SDelete'd the Win 2k image it would've compressed even more.

 

Adding a 2nd drive to each VM, cloning the drives then doing the qemu-img convet -O qcow2 and leaving them alone after that.

 

Edited by m4f1050
Link to comment
On 9/13/2018 at 5:29 PM, bonienl said:
On 9/13/2018 at 5:24 PM, johnnie.black said:

Yes, I've been meaning to edit that entry, will try to do it soon.

soon™ :)

Done, also changed the way to install the SCSI controller so you only need to edit the XML to add "discard=unmap", everything else is done using the form view, also made the feature request about that so when done no need to use XML view at all.

Link to comment
16 minutes ago, johnnie.black said:

Done, also changed the way to install the SCSI controller so you only need to edit the XML to add "discard=unmap", everything else is done using the form view, also made the feature request about that so when done no need to use XML view at all.

I want to add to that...  If you are already using VirtIO on Windows 2008 R2 (my case,) you need to add a Manual SCSI drive (1 meg should be ok, you can delete afterwards, just to get drivers installed first) then you can swap the type or your Windows 2008 R2 won't boot, it will blue-screen.  After I created the 1 meg drive and booted and installed the drivers, I was able to switch from VirtIO to SCSI without blue-screen.

Link to comment
I want to add to that...  If you are already using VirtIO on Windows 2008 R2 (my case,) you need to add a Manual SCSI drive (1 meg should be ok, you can delete afterwards, just to get drivers installed first) then you can swap the type or your Windows 2008 R2 won't boot, it will blue-screen.  After I created the 1 meg drive and booted and installed the drivers, I was able to switch from VirtIO to SCSI without blue-screen.

Yep, that's the same procedure I changed it to, you can add a 2nd small vdisk or for example use the exiting OS install CD-rom if still present to install the SCSI driver.

 

 

  • Upvote 1
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.