VMware Cloud Community
morecw
Contributor
Contributor
Jump to solution

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

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.

VMware ESXi 5.1 Guest: Ubuntu Server 12.04
Tags (4)
Reply
0 Kudos
1 Solution

Accepted Solutions
tomtom901
Commander
Commander
Jump to solution

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

View solution in original post

Reply
0 Kudos
20 Replies
FJ1200
Enthusiast
Enthusiast
Jump to solution

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. 

memaad
Virtuoso
Virtuoso
Jump to solution

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=201483...

How to shrink a VMDK using VMware Converter - TechRepublic

Regards

Mohammed Emaad

Mohammed | Mark it as helpful or correct if my suggestion is useful.
morecw
Contributor
Contributor
Jump to solution

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.

VMware ESXi 5.1 Guest: Ubuntu Server 12.04
Reply
0 Kudos
a_p_
Leadership
Leadership
Jump to solution

  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é

Reply
0 Kudos
morecw
Contributor
Contributor
Jump to solution

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

2. Thank you that answers my question.

VMware ESXi 5.1 Guest: Ubuntu Server 12.04
Reply
0 Kudos
morecw
Contributor
Contributor
Jump to solution

ssh results:

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

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

VMware ESXi 5.1 Guest: Ubuntu Server 12.04
Reply
0 Kudos
a_p_
Leadership
Leadership
Jump to solution

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é

Reply
0 Kudos
morecw
Contributor
Contributor
Jump to solution

/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

VMware ESXi 5.1 Guest: Ubuntu Server 12.04
Reply
0 Kudos
tomtom901
Commander
Commander
Jump to solution

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?

Reply
0 Kudos
morecw
Contributor
Contributor
Jump to solution

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.

Bildschirmfoto 2013-11-03 um 22.47.18.png

Bildschirmfoto 2013-11-03 um 22.47.03.png

VMware ESXi 5.1 Guest: Ubuntu Server 12.04
Reply
0 Kudos
tomtom901
Commander
Commander
Jump to solution

And what did you configure under destination layout?

Reply
0 Kudos
a_p_
Leadership
Leadership
Jump to solution

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é

Reply
0 Kudos
morecw
Contributor
Contributor
Jump to solution

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?

VMware ESXi 5.1 Guest: Ubuntu Server 12.04
Reply
0 Kudos
tomtom901
Commander
Commander
Jump to solution

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

Reply
0 Kudos
morecw
Contributor
Contributor
Jump to solution

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

VMware ESXi 5.1 Guest: Ubuntu Server 12.04
Reply
0 Kudos
tomtom901
Commander
Commander
Jump to solution

Shutdown the VM and do file -> export.

Reply
0 Kudos
morecw
Contributor
Contributor
Jump to solution

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

sshot-23.png

VMware ESXi 5.1 Guest: Ubuntu Server 12.04
Reply
0 Kudos
tomtom901
Commander
Commander
Jump to solution

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

Reply
0 Kudos
a_p_
Leadership
Leadership
Jump to solution

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é

Reply
0 Kudos