1 2 Previous Next 24 Replies Latest reply on Jul 10, 2016 12:21 PM by aaronfranke Go to original post
      • 15. Re: How to shrink a pre-allocated vmdk?
        Eugene Muzychenko Enthusiast

        What is wrong in the last case? You have 0.3 GB, 30 GB and 2 GB partitions on 32 GB disk. Of course, there is no free room to shrink the VMDK. shrinkvd does not affect partitions at all, it only shrinks VMDK files. To use shrinkvd, you should resize/move partitions first, making room at the end of VMDK.

        • 16. Re: How to shrink a pre-allocated vmdk?
          ExoticHadron Novice

          What is wrong in the last case? You have 0.3 GB, 30 GB and 2 GB partitions on 32 GB disk. Of course, there is no free room to shrink the VMDK. shrinkvd does not affect partitions at all, it only shrinks VMDK files. To use shrinkvd, you should resize/move partitions first, making room at the end of VMDK.

          Ah, now I see. I must have forgotten to use resize2fs to create unallocated space before shrinking like I did so before using vmware-vdiskmanager.exe -k.

           

          I have now managed to successfully shrink the disk with shrinkvd:

           

          F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit>shrinkvd.exe CentOS-6.3-64bit.vmdk
          Desc file: "F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit.vmdk"
          Disk file: "F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit-flat.vmdk"
          Disk partitions:
          0: boot=y, sys=83,     614400 secs (2048-616447), 0 Gb, 300 Mb
          1: boot=n, sys=83,   16777216 secs (616448-17393663), 8 Gb, 8192 Mb
          2: boot=n, sys=82,    4128768 secs (17393664-21522431), 2 Gb, 2016 Mb
          Total sectors used:  21522432 (10 Gb, 10509 Mb)
          Rounded cylinders: 1340 (21527100 sectors)
          Disk file size will be set to 21527100 sectors (10 Gb, 10511 Mb)
          Are you sure? (Y/N) y
          Operation completed successfully, old descriptor renamed to CentOS-6.3-64bit.vmd
          k.bak

          I however can't understand why there's difference in files shrinked with shrinkdvd and vmware-diskmanager:

           

           

          F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit>dir *.vmdk
          Volume in drive F is Storage
          Volume Serial Number is XXXX-XXXX

          Directory of F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit

          18.03.2013  19:39    11 021 875 200 CentOS-6.3-64bit-flat.vmdk //prepared with shrinkdvd
          03.03.2013  20:35     8 007 647 232 CentOS-6.3-64bit-Growable.vmdk //prepared with vmware-diskmanager
          18.03.2013  19:39               542 CentOS-6.3-64bit.vmdk
                         3 File(s) 19 029 522 974 bytes

           

          The difference must have been caused by difference in swap partition, which was probably missing in the virtual disk that was shunk with vmware-diskmanager.

          The question was more in the service message returned by the shrinkdvd tool:

           

           

          Total sectors used:  67108864 (32 Gb, 32768 Mb)
          Computed number of sectors is greater than current (67108864)


          It would've been better to have something like:

           

          there is no room to shrink the VMDK

          Don't you think it would?

           

          Anyway, thank you for your help and support.

          • 17. Re: How to shrink a pre-allocated vmdk?
            Eugene Muzychenko Enthusiast

            shrinkvd is completely different from vdiskmanager. If you don't understand clearly how shrinkvd works, please don't use it. Since your tasks can be successfully solved by vdiskmanager, you don't need shrinkvd at all.

            • 18. Re: How to shrink a pre-allocated vmdk?
              ExoticHadron Novice

              But when it worked fine, why would I worry drilling into details?

               

              BTW, I have no idea how could I clearly understand how the tool works when it does not have any documentation that would give any explanations.

               

              Do you by chance clearly understand how does your car engine work? Does it stop you from driving it when you don't know how to alter voltage angle to fine-tune ignition system?

               

              Cheers,

              EH

              • 19. Re: How to shrink a pre-allocated vmdk?
                Eugene Muzychenko Enthusiast

                It works fine as described. You expected things that are not described nor promised.

                 

                Shrinkvd package contains the readme file, why not to read it?

                 

                The car engine example is not similar to our situation. Much better example would be the ABS: if your car is equipped with it, you can just pedal and continue steering, otherwise you must have some knowledge and experience to prevent a drift.

                • 20. Re: How to shrink a pre-allocated vmdk?
                  Neil1T Novice

                  I faced this problem recently and did not find this article until after I'd solved the problem myself.

                   

                  Whilst I am full of admiration for anyone who can develop a tool which can do this kind of work, I also would like to know a little about how the tool works before I would use it.  Given that the Author clearly thinks this is an unacceptable response, here is how I resolved the problem myself, it also resolves the multi volume issue and, in the end, probably means less steps.

                   

                  In my instance I had a 40gb vmdk with one 40gb volume on it.  It only had 9gb of data in it and I needed to send the file over the internet to use it on another machine.

                   

                  This is what I did.

                   

                  I created a new 10gb Microsoft vhd and attached it to windows.

                   

                  I used the excellent Starwind v2v program to convert my pre allocated ESX vmdk to vhd.

                   

                  I attached the second vhd to windows.

                   

                  I then used Acronis Trueimage Home 2014 to clone the old 40gb drive to the new 10gb one.  Trueimage will copy and resize multiple volumes within one disk image to another disk.  It can do the work automatically or you can select the sizes manually.

                   

                  Once cloned I detached both drives and used v2v to convert my new 10gb vhd back into a pre allocated esx vmdk.

                   

                  This process will work for all vmdk files supported by v2v.

                   

                  Hope it helps anyone else who is facing the same issue.

                  • 21. Re: How to shrink a pre-allocated vmdk?
                    tshved Lurker

                    Neil1T, thanks for mentioning us.

                     

                    Just wanted to add that a new release of StarWind V2V converter is almost ready. It contains a new hardware conversion patch that will allow users to avoid problems with booting of VM's that were converted between very different environments.

                    • 22. Re: How to shrink a pre-allocated vmdk?
                      Novice

                      VMware supports both growable and pre-allocated virtual disks. In addition, the disks can be specified to be contained in a single file, or divided into multiple 2GB files.

                      The virtual disk type is defined at the point that the disk is created. Whilst this is generally not a problem, VMware Server does not support the shrinking of pre-allocated virtual disks. Before a pre-allocated disk can be reduced in size, therefore, it is necessary to first convert it to a growable disk. This can be performed using the Virtual manager tool (vmware-vdiskmanager).

                      For virtual type conversion

                      The vmware-vdiskmanager command requires a number of arugments perform a virtual disk type conversion. The syntax for a type conversion is as follows:

                      vmware-vdiskmanager -r <oldfilename>.vmdk -t <type> <newfilename>.vmdk

                      where <oldfilename>.vmdk is the name of the virtual disk image file to be converted, <type> is the number from the above table indicating the target virtual disk type, and <newfilename>.vmdk is the name of the new, converted file.

                      For example, to convert a virtual disk image file called win2008-1_2.vmdk to a growable disk called new.vmdk the following command would need to be executed:

                      vmware-vdiskmanager -r  win2008-1_2.vmdk -t 0 new.vmdk  Creating disk 'new.vmdk' Convert: 100% done. Virtual disk conversion successful. 

                      Once the conversion is completed, the virtual machine will need to be configured to use the converted disk, or the new disk renamed to have the name of the original disk.

                      • 23. Re: How to shrink a pre-allocated vmdk?
                        Neil1T Novice

                        Whilst I think this answers the OP's original question, what I required was a new ESXi preallocated vmdk file which was 30gb smaller than the original.

                         

                        What this command does is create a copy of the preallocated vmdk as a growable vmdk, of the same disk size but smaller footprint.  So you would not be able to convert it back to preallocated without taking up exactly the space it did before.  Also you would not be able to control the growth of the file on the system you put it on.

                         

                        For instance, in my case, my 50gb SSD had failed after power failure (common error I now know) and I only had 30GB left on the other volume.  So I had to do two things.

                         

                        1. make the vmkd smaller

                        2. ensure the vmdk did not grow beyond the volume size and impact all the other VM's.

                         

                        Hence why I posted an alternative.

                        • 24. Re: How to shrink a pre-allocated vmdk?
                          aaronfranke Lurker

                          Please realize that this will NOT decrease the maximum size of the virtual hard disk - it will still remain 40 GB.  Just that the space taken up on your host will be smaller.  If you want to decrease the max. size of the disk, you need to create a new, smaller disk; attach it to the guest; run a disk imaging utility to copy the original disk to the new one; make the new disk active; switch the disk order/drop the original disk; boot up and make sure it works before deleting the original disk.

                          Which disk imaging utility would you recommend?

                           

                          CloneZilla doesn't work in this instance, when copying device-to-device it won't allow me to copy to a smaller device, and when copying partition-to-partition, my guest Windows OS cannot boot properly, it complains with the error that it cannot find the file "\Windows\system32\winload.exe".

                           

                          Why doesn't VMware just support decreasing the maximum size of the virtual hard disk? This sounds like it'd be a basic feature. We're able to increase it, but have no way of going the other way around?

                          1 2 Previous Next