1 2 Previous Next 24 Replies Latest reply on Jul 10, 2016 12:21 PM by aaronfranke

    How to shrink a pre-allocated vmdk?

    JeffRozzzzz Enthusiast

      I created a Win2k3 server with a pre-allocated 40GB SCSI partition on a 250GB HD. When I boot into Win2k3 and open up VM Tools, the Shrink tab says it is disabled for pre-allocated disks (and other factors).

       

      I am only using 15GB out of the 40 and would like to shrink the disk down to 20GB.

       

      How can I do this? Thanks!

        • 1. Re: How to shrink a pre-allocated vmdk?
          KevinG Guru

          You can not use the VMware shrink option on a preallocated virtual disk.

           

          You could use vmware-vdiskmanager to convert the virtual disk to a growable virtual disk This conversion will create a *.vmdk file on the host that should be equal to the size of the data in the virtual disk, but will not change the Max size that the virtual disk can grow to, in your case this would be 40GB.

           

          The other option would be to use am imaging software like ghost to make an image of the disk and restore it into a smaller size virtual disk.

          • 2. Re: How to shrink a pre-allocated vmdk?
            JeffRozzzzz Enthusiast

            Great! That'll work. Where do I find more information on vmware-vdiskmanager and the syntax to do just that?

            • 3. Re: How to shrink a pre-allocated vmdk?
              KevinG Guru

              You can type vmware-vdiskmanger from the command line without any options to display the usage screen or you can refer to the VMware Server documentation.

               

              “Using VMware Virtual Disk Manager” on page 139

              http://www.vmware.com/pdfs/server_vm_manual.pdf

               

              http://www.vmware.com/support/pubs/server_pubs.html

              • 4. Re: How to shrink a pre-allocated vmdk?
                JeffRozzzzz Enthusiast

                Is the file installed as part of another toolkit or something? I did a search for "vmware-vdiskmanger.exe" and couldn't find it. I looked in the help file for VMware Server and it didn't find it, either.

                 

                Whoops. Misspelled exe. Found it...

                 

                Message was edited by:

                        JeffRozzzzz

                • 5. Re: How to shrink a pre-allocated vmdk?
                  RDPetruska Guru
                  vExpertUser Moderators

                  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.

                  Also, you never said what your host OS is.  If you are on a Windows host you may want to use my GUI wrapper for the vmware-vdiskmanager utility.  See my profile for website.

                  Rob

                  • 6. Re: How to shrink a pre-allocated vmdk?
                    KevinG Guru

                    Please realize that this will NOT decrease the maximum size of the virtual hard disk - it will still remain 40 GB.

                     

                    Yes, as explained in my first posting to the user.

                     

                    >This conversion will create a *.vmdk file on the host that should be equal to the size of the data in the virtual disk, but will not change the Max size that the virtual disk can grow to, in your case this would be 40GB.

                    • 7. Re: How to shrink a pre-allocated vmdk?
                      RDPetruska Guru
                      User ModeratorsvExpert

                      >Yes, as explained in my first posting to the user.

                      No problem.  I just wanted to spell it out in case he hadn't noticed that part. 

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

                        After five years, the problem was not gone. In 2009, I wrote "shrinkvd" utility for this purpose but I'm afraid it is not known here. It is available on SoftPedia.

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

                          Hi, Eugene

                           

                          Thanks for the shrinkvd tool! Could you please specify how would I use it?

                          I am trying to use the tool to shrink a 32 gig VMDK that I have but the tool doesn't seem to work. What am I doing wrong?

                           

                          Here's the output I get:

                          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"
                          Line 3: unknown parameter "encoding"

                          F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit>shrinkvd.exe CentOS-6.3-64bit-flat.vmdk
                          Desc file: "F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit-flat.vmdk"
                          Line 1 - no parameter name

                           

                           

                          [Windows][Hyper-V] Shrinking VMware VMDK.PNG

                           

                          So I have two VMDK files here:

                           

                          02.03.2013  23:25    34 359 738 368 CentOS-6.3-64bit-flat.vmdk

                           

                          02.03.2013  23:24               519 CentOS-6.3-64bit.vmdk

                           

                          Could that be the problem?

                           

                          How do I work around this?


                          Thank you.

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

                            You are using shrinkvd 1.0 that doesn't know about VirtualHW 8. Please donwload 1.1 from the software page or SoftPedia.

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

                              Hi Eugene,

                               

                              Thanks for responding.

                               

                              If only that was true. I ain't no VM guy but I usually think before I ask, so unfortunately, I am using the most recent version:

                              [Windows][Hyper-V] Shrinking VMware VMDK-01.PNG

                               

                              The SHA-1 footprint for the image I use:  E8888242B4CC0F0B98C1203490DBF44899453518

                               

                              It's the recent one avalable on your web site. Any clue?

                               

                              Currently I blame Linux that messed up with <CR><LF> of the VMDK responsible for disk layout; when I looked at the VMDK with layout info using Notepad, I noticed all configuration options were going in-line, obviosly that's the result of VMDK's originating OS which, as I suppose, was Linux. I should pass the layout VMDK and NOT the data disk, the -flat.vmdk one, correct? Anyways, I've tried passing the *-flat.vmdk with the same result.

                               

                              I ended up with using Virtual Disk Manager:

                               

                              C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -d "F:\
                              VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit.vmdk"
                              Defragmentation completed successfully.

                              C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -r "F:\
                              VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit.vmdk" -t 0 "F:\VM\CentOS 6.3
                              x64\CentOS-6.3-64bit\CentOS-6.3-64bit-Growable.vmdk"
                              Creating disk 'F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit-Growable.v
                              mdk'
                                Convert: 100% done.
                              Virtual disk conversion successful.

                              C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -k "F:\
                              VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit-Growable.vmdk"
                                Shrink: 100% done.
                              Shrink completed successfully.


                              What I noticed is that you MUST use the vmware-vdiskmanager.exe bundled with the VMware Workstation; I downloaded the recent Virtual Disk Development Kit from there and that did NOT work. Instead, that Virtual Disk Manager shipped with SDK was giving me plenty of errors like

                               

                              C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-vdi
                              skmanager.exe /d "F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit-flat.vm
                              dk"
                              Failed to analyze snapshot chain 'F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6
                              .3-64bit.vmx'.
                              Will not be able to make an informed decision based on partial information.

                               

                              C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-vdi
                              skmanager.exe /d "F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit.vmdk"
                              Failed to analyze snapshot chain 'F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6
                              .3-64bit.vmx'.
                              Will not be able to make an informed decision based on partial information.

                               

                              C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-vdi
                              skmanager.exe -k "F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit-flat.vm
                              dk"
                              Failed to open the disk 'F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit-
                              flat.vmdk' : The file specified is not a virtual disk (0xf00003ebf).
                              Failed to shrink the disk 'F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bi
                              t-flat.vmdk' : The file specified is not a virtual disk (0xf00003ebf).

                               

                              C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-vdi
                              kmanager.exe -k "F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit.vmdk"
                              ailed to open the disk 'F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit.
                              mdk' : Disk encoding error (0x3d00003ebd).
                              ailed to shrink the disk 'F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bi
                              .vmdk' : Disk encoding error (0x3d00003ebd).


                              Once I've tried the Virtual Disk Manager tool that's located under VMware Workstation's program folder, it worked fine. Go figure! Poor job, VMware... They could've prepared more legible error messages, they could've tested the input VMDK and notify that the file is incompatible with the Virtual Disk Manager I use.

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

                                Please excuse me, I added "ddb.encoding" to 1.1 but forgot to add "encoding" for the header. Just uploaded 1.2, please try it.

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

                                  Thanks, Eugene, for the swift response, and for sharing the new tool; I'll give it a try.

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

                                    Hi Eugene,

                                     

                                    Thank you for your support. I am sort of late on responding, but here's my experience with the recent version you've built. Unfortnately, I get the following:

                                     

                                     

                                    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,   62363648 secs (616448-62980095), 30 Gb, 30451 Mb
                                    2: boot=n, sys=82,    4128768 secs (62980096-67108863), 2 Gb, 2016 Mb
                                    Total sectors used:  67108864 (32 Gb, 32768 Mb)
                                    Computed number of sectors is greater than current (67108864)

                                     

                                    It seems like geometry data for the virtual disk screwed up in the CentOS-6.3-64bit.vmdk somehow. Ironically, vmware-vdiskmanager.exe worked well without producing any errors for the same disk layout file:

                                     

                                     

                                    C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -d "F:\
                                    VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit.vmdk"
                                    Defragmentation completed successfully.

                                    C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -r "F:\
                                    VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit.vmdk" -t 0 "F:\VM\CentOS 6.3
                                    x64\CentOS-6.3-64bit\CentOS-6.3-64bit-Growable.vmdk"
                                    Creating disk 'F:\VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit-Growable.v
                                    mdk'
                                      Convert: 100% done.
                                    Virtual disk conversion successful.

                                    C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -k "F:\
                                    VM\CentOS 6.3 x64\CentOS-6.3-64bit\CentOS-6.3-64bit-Growable.vmdk"
                                      Shrink: 100% done.
                                    Shrink completed successfully.

                                     

                                    Any clue on what could be the issue?

                                     

                                    Thank you.

                                    1 2 Previous Next