• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 11344
  • Last Modified:

Best way to Shrink VMDK file on ESXi datastore that is almost out of space

I am doing some testing of VMWare ESXi 4.1 and I created one VM on my test host that uses 450 GB of total space.  My plans were that I would have more disk space by now but I have run into a problem on the VM and I haven't been able to add any additional disk space yet.  The problem is that I have run out of disk space on the only partition on the ESXi host and this caused the VM to go down.  I was able to temporarily fix this issue by decreasing the RAM allocated to the machine from 8GB to 4GB so as to lower the amount of swap file space taken up and give the host an additional 4GB of space on the disk partition to allow the VM to boot.

Now I am trying to find a way to shrink the VMDK file on the host from 450 GB to around 400GB as I just want this server to have enough room to function continuously and not go down because of disk space issues.  I have been reading that you can use VMWare VCenter Converter which I have downloaded in its standalone version to shrink a VMDK during the coversion process doing a V2V conversion.  This seems like the safest route but I am now wondering if I can get away with doing a V2V conversion to the same disk partition that I have run out of space on.  It seems unlikely that I can do this since I would think the the conversion would write a vmdk file of the "new" disk to the same partition and I wouldn't have any space there for the necessary files to be written.  Still I wanted to check.  So is this method possible?

If not what are my other options?  I would like to not have to rebuild this server if possible.  I plan to order some more disk space for this server but I wasn't planning on making that order for another month or so.  If I do get more hard drive space I was going to create a second datastore on the ESXi host and then just move the VM to that datastore which will be much larger.  Is that as easy as just shutting down the VM and copying the VM folder on datastore1 to the new datastore2?  I'm sure there are a couple of other tasks I might need to do for the transfer from one datastore to the other but I wanted to get a basic idea of how to do it anyways.

Thanks in advance for your advice or suggestions.
0
ITPIP
Asked:
ITPIP
  • 18
  • 9
1 Solution
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Use VMware vCenter Converter  

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
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
You are not using Snapshots are you?

0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
If you have no space, you are looking at a Export and Import.
0
Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
How much used space is on the 450GB disk?
0
 
ITPIPAuthor Commented:
I will start reading through the links you provided.

In answer to your questions:
I had taken one snapshot of the machine as a test but I do not have continuous snapshots being taken.

Space used on the 450GB disk is ~105GB.  I would like to keep about 300-400GB free as this is a server that I am testing and will slowly move some production websites to as I wrap up testing.  Once in production I can see the need for the 300-400GB but as of now it is only using that 105GB.

So Export and Import is a fuction of what?  VCenter converter or the VSphere client?  While waiting for responses I will start reading the documentation you provided and see if that answers this question as well.

Thanks for your help.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
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.


0
 
ITPIPAuthor Commented:
Sorry if I misunderstood your question about how much space on the datastore I have.  I really don't have much of any space on the current datastore at the moment but I had planned to add a second datastore with almost 2TB of space when all said and done.  Those disks have not been ordered yet but they are in the works for purchase very soon.

If I don't have any space on the datastore then it sounds like your suggestion is Export then Import but I am not sure what this means yet.

Thanks.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
When I mean Export and Import, I mean the use of VMware Converter.

Do you have vSphere vCenter Server?

oh you are very low on disk space, any chance you could allocate some temporary storage on a Windows Server using NFS? (setup a NFS server for use with ESXi - beyond the scope of this question, but an idea).

Otherwise I think your only choice, would be to VMware Convert off the server, delete the Server, and put back again via VMware Converter.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
You will have to use VMware Converter to Convert off the server to a server or workstation, and then delete the Virtual Server, and then use VMware Converter to Import it again, but this time change the disks size to 400GB.
0
 
ITPIPAuthor Commented:
I think I follow what you are suggesting.  So Converter will let me specify any desitination for the Coversion even if it isn't another ESXi host?  So I can point it to a UNC path on my Windows 2008 Storage Server and place the Exported VM in that storage space and then delete the VM on the host and then use Converter again to import?

All of that makes sense I was just unaware that you could use converter to Export a VM to anything other than Attached Storage or NFS storage.  But I hadn't read through all of the documentation for converter yet so I would probably find that answer in there.

Just to re-iterate I would I install the standalone converter on the VM I want to Export then run the converter, then point it to the UNC path where I want the export to go, then run the conversuib, then shut down the VM, and then delete the VM?  Then use converter standalone installed on my Workstation to Import the VM back to the host?  I assume somewhere in that process I would be able to specify the new size.

Anything I am missing here.  Are there any limitations because of the VM OS(Win 2k8R2)?

Just want to make sure I am understanding your suggestion.

Thanks again for the help.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
That is correct. VM Convertor is best installed on the machine you want to convert, this is Best Practice, as it avoids many issues, rather than a remote conversion.
0
 
ITPIPAuthor Commented:
Cool.  I will read through the documentation and attempt this.  If I have any more questions I will let you know.  After completed I will award points.

Thanks.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Good Luck with the conversion.

Make sure you have a backup of the VM.
0
 
ITPIPAuthor Commented:
That brings up another question.  I use Backup Exec for the majority of my backups and I have successfully backed up this machine just like I would a physical machine using backup exec but should I also make a copy of the entire folder for my VM from the datastore?  Since I am only testing and do not have VCenter Server installed I found a product called Veam Backup and FastSCP that will allow me to copy files from the datastore and move them somwhere else.  I haven't attempted this yet but it seems that all I have to do to copy the entire VM from the datastore is use this software and then paste that VM folder to some open storage space on my Windows storage server.

Is this the kind of backup you are talking about or are you just suggesting a backup using whatever solution I like?
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Veeam FastSCP is a product which many people use to copy VMs to a local disk for backup.

I would make a copy just in case!
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
But any backup will do, just make sure you have one. I think you may find Veeam FastSCP quicker to backup and restore than Backup Exec.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Yes, that will work.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Once you have your Veeam Backup, you may want to proceed, and see if you can re-import that using Convertor and change the size of the disk from 450GB to 400GB. (as you'll already have a copy of it on lock storage, saves the copy twice!)
0
 
ITPIPAuthor Commented:
Great suggestions.  Thanks for all the input!  I proabably won't have any results till Monday but I really appreciate the quick response.
0
 
ITPIPAuthor Commented:
Something else I just came across as I was preparing for this.

I was still going to copy the VM to my Storage Server using Veam but I wanted to run some tests with Converter first.  I have installed the standalone coverter client on the VM that I want to shrink the size on.  I then choose that I would be converting the local machine.  When I came to the destination selection part of the conversion wizard I am asked to select a destination type.  My choices are VMware Infrastructure Virtual Machine and VMware Workstation or other VMware virtual machine.  Since I am wanting to send this to a UNC file path on my Windows 2008 Storage Server I am assuming that I would select the second option VMware Workstation or other VMware virtual machine.  However once I choose that option now I am asked to select the VMware product.  My options are VMware workstation 7.0.x through 5.0.x, VMware Fusion, Player, and Server all versions listed.  Since I am only running the conversion to create the needed files on a seperate file storage location so I can delete the current VM on my ESXi host datastore which product would I choose?  Does it matter?  

I am leaning towards it might not might matter because in preparation for this I have also installed the standalone client on the Windows Storage server.  This machine will be used for the "Import" and when selecting the Source in the converter software I have the option to choose a VMware Workstation or other VMware virtual machine.  I then am given the option to browse the local disks on the storage server and choose the correct Virtual Machine file.  I am assuming that whatever I choose on the conversion of the source machine to the disk storage it will be compatible with my Import from the standalone coverter running on the Windows Storage Server.  Is this the correct assumption?

Either way it looks like my Veam backup will be compatible with the Import as it will take all of the needed VM files and place them in my temporary location but I thought I would check on the Export functionality of converter as well.

Sorry if this is confusing I just wanted to try and confirm a couple things before I run any more tests.

Thanks.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Yes, your assumptions are correct, because Converter will Convert the format for the correct target format.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Yes, your assumptions are correct, because Converter will Convert the format for the correct target format. As long as it's VMware.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
sorry, about the double post, something weird with EE!
0
 
ITPIPAuthor Commented:
Thanks for confirming that information for me.  Hopefully all will go well and I will have success to report on Monday.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
ok. have a good weekend.
0
 
ITPIPAuthor Commented:
Wanted to get back and report that your suggestions worked perfectly.  I tested two different ways of backing up.  

First I shutdown the VM and used Veam Backup and FastSCP to do a basic copy of the entire VM folder to network storage.  

Then I tested an export using VMware Standalone converter.  When using this I specified a smaller partition size for the destination VM.  This process worked without issue as well and looked to shrink the specified partition correctly.  

Once I had tested these two backup methods I shutdown the VM one more time and deleted it from the datastore.  I then used VMware standalone converter installed on my storage server to do the "Import" using my Veam folder backup.  I specified the smaller partition size for the destination Infrastructure VM and started the conversion.  It took about 2.5 hours to complete the import.  Once the import was done I checked to make sure the VMDK size was smaller on the datastore.  Then booted the imported VM.  The machine booted successfully and has been running perfectly since.

Thanks again for your suggestions.  
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
No problems, glad it's all working for you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 18
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now