Virtualization Station img File shrink and defrag
-
- New here
- Posts: 6
- Joined: Sat Jan 15, 2011 6:34 pm
Virtualization Station img File shrink and defrag
Hi!
Is there any way to free up unused Space within *.img File?
It also seems like some of the *.img Files i'm using are really slow. Is it possible that they are fragmented a lot?
Thanks for help!
Regards,
Markus
Is there any way to free up unused Space within *.img File?
It also seems like some of the *.img Files i'm using are really slow. Is it possible that they are fragmented a lot?
Thanks for help!
Regards,
Markus
-
- Starting out
- Posts: 10
- Joined: Thu Nov 20, 2014 4:11 pm
Re: Virtualization Station img File shrink and defrag
Did anyone get an answer to this as I created a Windows vm which has been shrunk in the OS but want to reduce in virtualisation station and hence remove unused disks in the OS
I have asked qnap support
I have asked qnap support
-
- New here
- Posts: 6
- Joined: Sat Jan 15, 2011 6:34 pm
Re: Virtualization Station img File shrink and defrag
Actually, No
Still an open question for me.
There is a way via VMWare Converter Utlity. However, this means exporting shrinking and reimporting VM.
Bye,
Maxx
Still an open question for me.
There is a way via VMWare Converter Utlity. However, this means exporting shrinking and reimporting VM.
Bye,
Maxx
-
- Starting out
- Posts: 10
- Joined: Thu Nov 20, 2014 4:11 pm
Re: Virtualization Station img File shrink and defrag
Thank you
I didn't think of that but know as it's an office line activity it may take some time
I didn't think of that but know as it's an office line activity it may take some time
-
- Starting out
- Posts: 11
- Joined: Sat Jan 28, 2017 3:34 am
Re: Virtualization Station img File shrink and defrag
I also am looking for an answer to this. There seems to be an option is the Virtualization Station settings but ti's asking me to delete all snapshots first?
- razormoon
- Easy as a breeze
- Posts: 465
- Joined: Fri Feb 13, 2015 5:05 am
- Location: Denver, CO
Re: Virtualization Station img File shrink and defrag
[quote="orgetorix"There seems to be an option is the Virtualization Station settings but ti's asking me to delete all snapshots first?[/quote]
Where are you seeing this option??
Where are you seeing this option??
-
- Starting out
- Posts: 11
- Joined: Sat Jan 28, 2017 3:34 am
Re: Virtualization Station img File shrink and defrag
It's under the settings tab of the VM. It's under storage. There is a slider, but I cannot change the size. I had originally set it to 2048 GB but have halved it in the OS. Virtualization Station won't let me shrink the volume.Where are you seeing this option??
When I try to shrink I get the message "The HDD size cannot be decreased"
You do not have the required permissions to view the files attached to this post.
- razormoon
- Easy as a breeze
- Posts: 465
- Joined: Fri Feb 13, 2015 5:05 am
- Location: Denver, CO
Re: RE: Re: Virtualization Station img File shrink and defrag
Ah. No, that is a completely different function. That refers to the size of the drive as it appears to the VM as physical space. You can increase space, but not the other way around. The drive will start a small file and increase until the size you set when creating it. What OP was referring to was the fact that the file will not get smaller as you delete files on the virtual disk and how to reclaim that space. It's totally different than what you pointed out.orgetorix wrote:It's under the settings tab of the VM. It's under storage. There is a slider, but I cannot change the size. I had originally set it to 2048 GB but have halved it in the OS. Virtualization Station won't let me shrink the volume.Where are you seeing this option??
When I try to shrink I get the message "The HDD size cannot be decreased"
-
- Starting out
- Posts: 11
- Joined: Sat Jan 28, 2017 3:34 am
Re: Virtualization Station img File shrink and defrag
I see. I guess I figured that creating a VM with a 2 TB HDD would create am IMG file that size and if I shrunk the volume in the OS that it would shrink the IMG as well.
-
- Starting out
- Posts: 39
- Joined: Mon Nov 28, 2016 6:53 am
'direct' solution to shrinking virtual HDDs created in Virtualization Station
This started out as having an IMG file created in Virtualization Station that contains a virtual HDD that was 64GB in size and I wanted to shrink it down to 16GB so that Virtualization Station sees it that way.
So, shrinking it down by 48GB. Note, the actual SIZE of the IMG file will not change, because the size of the IMG file only reflects what files you actually have on the virtual HDD, not its virtual size.
FIRST, before you do this you must boot the VM to an ISO image loaded into the virtual CD drive (like GParted or PartedMagic) that allows you to resize the virtual HDD partitions. You cannot skip this step.
Using the above-mentioned utility, you must move all allocated space to the beginning of the virtual drive and then de-allocate the space you want to shrink the virtual HDD by.
ALL de-allocated space you're getting rid of to shrink the virtual HDD must all be at the END. The utility you will be using below starts at the end of the virtual HDD and works backwards to shrink it.
SECOND...
I found out how to shrink the virtual HDD in the most 'direct' way possible. That is, I first looked at the header of a small IMG file created in Virtualization Station that I have to see what the file signature was.
The first four bytes appear this way in a hex editor that shows the hexidecimal view as well as the text view: 51 46 49 FB QFIû
When I looked that up online I found: IMG QEMU Qcow Disk Image
The utility that is able to directly modify the file (without first changing formats to another type of file) is part of Qemu for Windows and is called qemu-img.
NOTE: It runs at the command line so it's not a GUI application.
Source for binary files:
https://qemu.weilnetz.de/w64/ <-- Qemu 64-bit (32-bit also available) for Windows -- you will need to extract the qemu-img.exe executable and the following 20 DLL files it needs to run:
iconv.dll
libbz2-1.dll
libcurl-4.dll
libffi-6.dll
libgcc_s_seh-1.dll
libglib-2.0-0.dll
libgmp-10.dll
libgnutls-30.dll
libhogweed-4.dll
libidn2-0.dll
libintl-8.dll
libnettle-6.dll
libnghttp2-14.dll
libp11-kit-0.dll
libpcre-1.dll
libssh2-1.dll
libtasn1-6.dll
libunistring-2.dll
libwinpthread-1.dll
ssleay32.dll
If you need the pre-extracted package, please send me a message and I'll send the zipped file to you.
Instructions for using qemu-img:
https://qemu.weilnetz.de/doc/qemu-doc.h ... invocation <-- check near bottom of section 2.8.4, just before 2.8.5 and you'll see the resize switch options
Example command line to shrink a virtual HDD inside an image file (filename.img) from 64Gb down to 16Gb:
qemu-img resize --shrink filename.img 16G
Replace filename.img with your existing image file's name. Replace 16G with whatever size you have already reduced the allocated space to on the virtual HDD in the first step above.
I tested the qemu-img command above and it worked perfectly to shrink the virtual HDD within the IMG file from 64GB to 16GB.
Key is to make sure when you move/resize partitions in the first step that total allocated space is contiguous and at the FRONT and is no more than the size you're shrinking to (preferably a little less) or the VM won't boot.
Save the newly-shrunk IMG file to a place where you can easily get to it for the next step.
Delete the old IMG file and copy the new IMG file in its place. Keep the existing folder and other files in place.
(Note: you should just be able to pop the modified IMG in the original IMG's place and it works. What I did instead is start over and create a barebones VM using no image but with the correct virtual HDD size as the modified IMG has.)
I tested and it booted fine, and the image info in Virtualization Station now says the virtual HDD is 16GB instead of 64GB. Good, since you could not shrink it there!
DONE!
So, shrinking it down by 48GB. Note, the actual SIZE of the IMG file will not change, because the size of the IMG file only reflects what files you actually have on the virtual HDD, not its virtual size.
FIRST, before you do this you must boot the VM to an ISO image loaded into the virtual CD drive (like GParted or PartedMagic) that allows you to resize the virtual HDD partitions. You cannot skip this step.
Using the above-mentioned utility, you must move all allocated space to the beginning of the virtual drive and then de-allocate the space you want to shrink the virtual HDD by.
ALL de-allocated space you're getting rid of to shrink the virtual HDD must all be at the END. The utility you will be using below starts at the end of the virtual HDD and works backwards to shrink it.
SECOND...
I found out how to shrink the virtual HDD in the most 'direct' way possible. That is, I first looked at the header of a small IMG file created in Virtualization Station that I have to see what the file signature was.
The first four bytes appear this way in a hex editor that shows the hexidecimal view as well as the text view: 51 46 49 FB QFIû
When I looked that up online I found: IMG QEMU Qcow Disk Image
The utility that is able to directly modify the file (without first changing formats to another type of file) is part of Qemu for Windows and is called qemu-img.
NOTE: It runs at the command line so it's not a GUI application.
Source for binary files:
https://qemu.weilnetz.de/w64/ <-- Qemu 64-bit (32-bit also available) for Windows -- you will need to extract the qemu-img.exe executable and the following 20 DLL files it needs to run:
iconv.dll
libbz2-1.dll
libcurl-4.dll
libffi-6.dll
libgcc_s_seh-1.dll
libglib-2.0-0.dll
libgmp-10.dll
libgnutls-30.dll
libhogweed-4.dll
libidn2-0.dll
libintl-8.dll
libnettle-6.dll
libnghttp2-14.dll
libp11-kit-0.dll
libpcre-1.dll
libssh2-1.dll
libtasn1-6.dll
libunistring-2.dll
libwinpthread-1.dll
ssleay32.dll
If you need the pre-extracted package, please send me a message and I'll send the zipped file to you.
Instructions for using qemu-img:
https://qemu.weilnetz.de/doc/qemu-doc.h ... invocation <-- check near bottom of section 2.8.4, just before 2.8.5 and you'll see the resize switch options
Example command line to shrink a virtual HDD inside an image file (filename.img) from 64Gb down to 16Gb:
qemu-img resize --shrink filename.img 16G
Replace filename.img with your existing image file's name. Replace 16G with whatever size you have already reduced the allocated space to on the virtual HDD in the first step above.
I tested the qemu-img command above and it worked perfectly to shrink the virtual HDD within the IMG file from 64GB to 16GB.
Key is to make sure when you move/resize partitions in the first step that total allocated space is contiguous and at the FRONT and is no more than the size you're shrinking to (preferably a little less) or the VM won't boot.
Save the newly-shrunk IMG file to a place where you can easily get to it for the next step.
Delete the old IMG file and copy the new IMG file in its place. Keep the existing folder and other files in place.
(Note: you should just be able to pop the modified IMG in the original IMG's place and it works. What I did instead is start over and create a barebones VM using no image but with the correct virtual HDD size as the modified IMG has.)
I tested and it booted fine, and the image info in Virtualization Station now says the virtual HDD is 16GB instead of 64GB. Good, since you could not shrink it there!
DONE!
-
- Starting out
- Posts: 17
- Joined: Sun Dec 20, 2015 3:30 pm
Re: 'direct' solution to shrinking virtual HDDs created in Virtualization Station
The URL above no longer resolves, is this the correct page??ssybesma wrote: ↑Wed Aug 07, 2019 12:37 pm [snip]
Instructions for using qemu-img:
https://qemu.weilnetz.de/doc/qemu-doc.h ... invocation <-- check near bottom of section 2.8.4, just before 2.8.5 and you'll see the resize switch options
https://www.qemu.org/docs/master/tools/qemu-img.html
Thanks for the work!
- OneCD
- Guru
- Posts: 12146
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
Re: Virtualization Station img File shrink and defrag
* topic locked to prevent further necroposting *