ESXi 4.1 u1 - what's the best way to decrease a VMDK size?

IT_Group1
IT_Group1 used Ask the Experts™
on
Thx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Paul SolovyovskySenior IT Advisor
Top Expert 2008

Commented:
The easiest way is to perform a V2V (virtual to virtual) migration using VMWare Converter.  During the process resize the vmdk as needed.  
if you configured the disk using thin provisioning then it's easy enough...
just shut down the machine, edit the disk and enter new value

if it's thick provisioned, then you will need to convert it to thin, and then shrink it.
to do so:
shut down vm
log in to shell(ssh) of esx host
cd /volumes/>yourdatastore</>vmname<
when in the correct folder:
enter this: vmkfstools -i yourthickdisk.vmdk -d thin yourthindisk.vmdk
when it's done you can just remove the thick disk from the vm(DO NOT delete it yet, just disconnect it from the vm) and then connect the new thin disk, edit the disk for size requirement

and boot the vm, if all seems well you can discard the thick(old) vmdk
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
Use VMware Converter Standalone.

Download VMware vCenter Converter here

http://downloads.vmware.com/d/info/datacenter_downloads/vmware_vcenter_converter_standalone/4_0

VMware vCenter Converter Standalone 4.x Documentation

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

VMware vCenter Converter Standalone 4.3 User Guide

http://www.vmware.com/pdf/convsa_43_guide.pdf

For the conversion steps, read fellow Expert Bestway's article.

http://www.experts-exchange.com/Software/VMWare/A_3639-VMware-vConverter-P2V-for-Windows-Servers.html

Best Practice Video Guide here

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1004588

If all else fails do the following as it has helped me over a hundred times when converter fails

1.  Download trial copy of Symantec Backup Exec System Recovery
2.  Install and take an image of the server
3.  Use VMware Converter to convert image (it knows it natively) to a VM
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
this is another method, if you like command lines

Before VMware Convertor was developed which is very easy to use and shrink disks, this is how we would do it.

1. Firstly, using Partition/Server Magic or Gparted Live CDROM (http://gparted.sourceforge.net/livecd.php).

2. Use GParted to shrink NTFS (assuming windows) partition from xx GB to yy GB. You'll need to shutdown, and attach iso to VM, and reboot and boot from cdrom.

3.  Create blank yy GB VMDK (this is why I asked how much space you have remaining on your datastore to do this)

4. vmkfstools -c yyG -d thick new-yygdisk.vmdk

5. Copy the first xx contents of xx GB disk to new yy GB disk using DD

6. dd if=xx-flat.vmdk of=new-yygdisk-flat.vmdk bs=1048576 count=10240

7. bs and count are 10GB  in this example.

8. done.

but you need the space do do this operation on the datastore.
Please note that if you use converter to shrink your vmdk, the resulting vm will be an *new* vm.
You might want to keep your original vm and connect the resulting disk to the original vm.
Working with a new vm (new UUID) might have several drawbacks for backup software and so on.

Author

Commented:
Thx all!
When running VMware Convertor on the host, and selecting the correct guest (which is powered-down), the following error appear:

Unable  to obtain hardware information for the selected machine.

The Guest  is an SBS 2011 w/ 1 VMDK of 256GB.
Thx
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
VMware Converter must be run, either installed on the host or connected to the host whilst it is powered on.

Is the machine you need to convert OFF?
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
You could also use vConverter in vCenter (if you have it available), to Export and Import the Guest back to vCenter, changing disk size, but the VM must still be OFF.

Author

Commented:
Ok passed through it I change the VM type to server 2003 R2 x64 and the error disappears. Clearly this is a converter bug.

The issue now, when i want to decrease the disk size, it only shows as data cop type: copy all disks and maintain layout, and i can choose either Flat or Thin.
I beleive i should choose thin, and after conversation over, it'll let me decrease it right?

BTW, the converstion is taking place on the same host
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
It should allow you to specify a size, you don't want to maintain layout.
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
Are you using Converter Standalone, or Converter Export in vCenter?

Author

Commented:
Converter Standalone. Doesn't allow to change size..

Author

Commented:
Will Thin provisioning allow me to change disk size after completion?
yes it will, but i really don't see why you don't just clone the disk to thin as i said before... you would've been done by now
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
No, the conversion process must reduce the disk size.

(but if you actually want to reduce the size to the OS, you'll need to convert)

Depends on the reasons to decrease VMDK size.

Obviously going from thick to thin, will reduce the storage space, until you use it all again.

Author

Commented:
It's just not my lucky day.
setasoujiro: I've followed your advice and tried to clone the disk to thin. Although as you can guess it wasn't a successful attempt, since the vmkfstools didn't cooperate..

The exact command I've entered was: vmkfstools -i SBS 2K11.vmdk -d thin SBSTHIN 2K11.vmdk
Maybe it didn't went well because we have a space between the SBS and the 2k11?

hanccocka: I'm running the conversion now (thin, no size change) - let's hope I'll be able to reduce the size.

Thx
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
Screenshot the Converter you are using?

Author

Commented:
Version 4.0.1 Build-161434
Screenshot attached.

Strange, it's runiing for almost an hour, yet no estimated end time. Is there a way to monitor its progress?
Convert.JPG
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:

Author

Commented:
We didnt installed the vcenter yet. Is there a newer stanalone version?
VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017
Commented:
Mistyped that is VMware Converter Standalone (sorry)

4.3 is the latest.

http://downloads.vmware.com/d/info/datacenter_downloads/vmware_vcenter_converter_standalone/4_0

Author

Commented:
Thx, will try.
Do you happen to know if there are major fixes?
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
support for Win2k8 and Win7 is the major one.

Author

Commented:
Can i upgrade the current one, or perform a fresh install?
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
It's a re-install, I believe.
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
Actually, I am correct is full title is know as VMware vCenter Converter Standalone!
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
Okay, I've just checked for you.

When you get to the Destination Locations, this is where you change the size

(it's available in all Standalone versions)

See pick, you need to use the drop down, and enter a new size for the VMDK

 VMware vCenter Converter Standalone Destinations Location - This is where you change the disk size

Author

Commented:
hanccocka, many many thx. I'll install the 4.3 ASAP,
And lets hope it'll let us change size.
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
If you follow the options in picture, you should be able to change the size.

Author

Commented:
It's working !! You're a bloody darn good magician ain't you?
THX
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
Yes, we do lots of "voodoo here".
the command didn"t do well because you didn't quote the names "sbs disk.vmdk"
because it has spaces
btw pressing tab in shell autocompletes :)

Author

Commented:
THE MAN. Period

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial