VMware vSphere

 View Only
Expand all | Collapse all

How can I shrink the hard drive size of my guest? (Ubuntu server)

  • 1.  How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 09:51 AM

    Hi all,

    When I built my VM guest (Ubuntu Server 12.04) on VMware ESXi 5.1 I was a little over zealous and create it with a 500GB hard drive. I have found now that a 100GB would easily suffice.

    I would like to reduce the hard drive down to 100GB. How can I do this? It seems pretty obvious how to do it on Windows using the Standalone converter but under Ubuntu server? I've no idea where to begin and I can't find any info!

    Could someone also please explain why the real used disk space of this guest on the host is 500GB? When using VMWorkstation the file size just grows with the actual used disk space of the guest. Whereas under ESXi the file size begins at the size you have specified for the server. Can this be changed?

    Many thanks in advance.



  • 2.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 11:47 AM

    Space is allocated depending on the vHDD provisioning you select.  Looks like you have thick provisioned your drive rather than thin, which grows as the data grows.  I believe you can go from thin provisioned to thick but not the other way around, maybe someone can confirm that?

    So far as reducing space, not sure.   You might need to use the VMW Converter to do it. 



  • 3.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 11:57 AM

    Hi,

    Even for Ubuntu, you should be able to  use converter to reduce the size of vmdk. It look like you are using thick provision disk, which allocate disk space on at front. Where are thin provision allocate space on demand by guest.

    Refer this KB to  for thick to thin conversion http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2014832

    How to shrink a VMDK using VMware Converter - TechRepublic

    Regards

    Mohammed Emaad



  • 4.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 04:41 PM

    Hi, so I used the VMware converter and it worked as far as I managed to convert it into a new guest with a 200GB thin provision but I still have two problems:

    1. The VMDK file is using the whole hard drive size (200GB). I was expecting it to only be the size of what the Ubuntu guest has used (about 50GB).

    2. I was also warned by someone once that for best practise the VMDK should be saved into 2GB portions. I don't see anywhere to configure this though!

    Any ideas? Thanks for any advise.



  • 5.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 04:57 PM
    1. Are you sure it's using the whole space. Depending on where you check the size, you may see the provisioned size rather than the physical size.
    2. The 2GB Sparse files are only used for hosted products like VMware Workstation, Player or Fusion.

    André



  • 6.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 05:03 PM

    1. Yes I'm sure. I have checked the file size via ftp.

    2. Thank you that answers my question.



  • 7.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 05:18 PM

    ssh results:

    /vmfs/volumes/51a4982f-cad13f07-b441-a4badb3d9e4d/morrison # ls -l

    -rw-------    1 root     root     223333253120 Nov  3 15:10 morrison-flat.vmdk



  • 8.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 05:38 PM

    Please run ls -ls to see the allocated size or take a look at the Datastore Browser which shows both, the provisioned as well as the current size.

    André



  • 9.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 05:46 PM

    /vmfs/volumes/51a4982f-cad13f07-b441-a4badb3d9e4d/morrison # ls -ls

    47998976 -rw-------    1 root     root     223333253120 Nov  3 15:10 morrison-flat.vmdk

      1024 -rw-------    1 root     root          8684 Nov  3 15:10 morrison.nvram

         0 -rw-------    1 root     root           634 Nov  3 12:49 morrison.vmdk

         0 -rw-r--r--    1 root     root             0 Nov  3 12:48 morrison.vmsd

         8 -rwxr-xr-x    1 root     root          2266 Nov  3 15:10 morrison.vmx

         0 -rw-r--r--    1 root     root           274 Nov  3 15:10 morrison.vmxf

      1024 -rw-r--r--    1 root     root        174521 Nov  3 15:10 vmware.log



  • 10.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 09:11 PM

    That's still a 200 GB file. You can use ls -allh to view it in a readable format. When you used te converter, did you select the option for thin provisioning?



  • 11.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 03, 2013 09:55 PM

    Yes I definitely used thin provisioning accept I specified a reduced destination disk size of 200GB (source = 500GB). I'm making a second attempt to convert again now but with a minimised thin provision (48,32GB). In theory, with a thin provisioned disk it should just increase the size of the VMDK file as and when the guest requires more space, right? I will try increasing the hard drive size limit in the VM's settings after the conversion.



  • 12.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 04, 2013 09:36 AM

    47998976 -rw------- 1 root root 223333253120 Nov 3 15:10 morrison-flat.vmdk

    The real size on disk for this file is 47,998,976 kB which equals ~46GB. The right part will always show the provisioned size since the thin files use the file system's sparse format.

    If you want use ls -lsh to show the human readable output which show this more clearly.

    André



  • 13.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 04, 2013 05:08 PM

    Ok but how does this work in terms of making backups of the vmdk file? Because as far as my ftp client is concerned I'm requesting to copy 200GB which is considerably more work that 47GB!

    I wanted to back up my guest to a USB drive. Doesn't this mean as far as my USB drive is concerned, 200GB have been used?  Would setting the conversion to minimal (47GB) before backing up be a solution?



  • 14.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 04, 2013 05:09 PM

    You can do an export of the VM. That should take the 47 GB file.



  • 15.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 04, 2013 05:19 PM

    How can I export the VM? I am using the free hypervisor (ESXi 5.1) and I have not found any solution apart from simply copying the directory via ftp



  • 16.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 04, 2013 05:26 PM

    Shutdown the VM and do file -> export.



  • 17.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 04, 2013 05:31 PM

    On the free hypervisor (vsphere 5.1) there is no such option to export the VM



  • 18.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)
    Best Answer

    Posted Nov 04, 2013 05:51 PM

    Export OVF Template is the one you want. This allows you to backup the entire VM to single or multiple files (you want single).



  • 19.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 04, 2013 06:16 PM

    Thank you all for answering my questions!



  • 20.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 04, 2013 05:52 PM

    The export option is the one in the screenshot, i.e. Export OVF Template.

    Another option is to use a backup application. Take a look at e.g. Trilead's VM Explorer (http://www.trilead.com/) which even works with the free Hypervisor.


    André



  • 21.  RE: How can I shrink the hard drive size of my guest? (Ubuntu server)

    Posted Nov 04, 2013 06:24 AM

    And what did you configure under destination layout?