Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Resize down an ESXi VMDK?

Options
  • 05-12-2011 5:44pm
    #1
    Registered Users Posts: 385 ✭✭
    Boycott Israeli Goods & Services


    Hi everyone, looking for advice from someone with good VMWare ESXi experience.

    I have a VM on ESXi that was originally created using P to V conversion, and has had over time a large amount of data removed.

    I need to get back the disk space that was originally used for this machine to give it to another VM by reducing the VMDK size (by about 450 GB).

    I've reduced the partitons on the Windows server so that this 450 GB is now shown as unallocated, but does anyone know how I can reduce the VMDK to take out the unallocated space without effecting the live partitions?


Comments

  • Registered Users Posts: 3,537 ✭✭✭swampgas


    Zirconia wrote: »
    Hi everyone, looking for advice from someone with good VMWare ESXi experience.

    I have a VM on ESXi that was originally created using P to V conversion, and has had over time a large amount of data removed.

    I need to get back the disk space that was originally used for this machine to give it to another VM by reducing the VMDK size (by about 450 GB).

    I've reduced the partitons on the Windows server so that this 450 GB is now shown as unallocated, but does anyone know how I can reduce the VMDK to take out the unallocated space without effecting the live partitions?

    There is no way to shrink a vmdk file within vSphere Client. The best way is to use VMware Converter again and do a V2V of the VM, this will allow you to reduce the size of the disk as part of the conversion. You can even do another "P2V", pointing at the current VM as the "physical" host.


  • Registered Users Posts: 10,256 ✭✭✭✭Standard Toaster


    Need more info. Are you using Thin Provisioned disks? What version of esx you running?

    Top of my head....within the VM run sdelete with the -c switch to zero out any 'free' space.

    Then you could storage vMotion the vm to another Datastore and back again. You could also ghost the box and re-ghost back again to get same results.


  • Registered Users Posts: 3,537 ✭✭✭swampgas


    If you decide the make a Ghost image of the VM, you can then import the image with converter. Just be aware that not all versions of ghost are supported.

    http://kb.vmware.com/kb/1003228


  • Registered Users Posts: 385 ✭✭Zirconia
    Boycott Israeli Goods & Services


    The VM is running on VMware ESXi 4.1.0, i.e. the free version so the vMotion option isn't available.

    I might try swampgas's original suggestion and user the VMWare Standalone Converter to see if I can do a "Physical" to virtual conversion.

    The main problem I have is down to the original reason I needed to do this: I'll have to PtoV to the same machine, and it's got almost no space left. I'll have to try and temporarily mount another drive and set it up as a datastore to do it. It'll be a weekend job then :-(


  • Registered Users Posts: 3,537 ✭✭✭swampgas


    Zirconia wrote: »
    The VM is running on VMware ESXi 4.1.0, i.e. the free version so the vMotion option isn't available.

    I might try swampgas's original suggestion and user the VMWare Standalone Converter to see if I can do a "Physical" to virtual conversion.

    The main problem I have is down to the original reason I needed to do this: I'll have to PtoV to the same machine, and it's got almost no space left. I'll have to try and temporarily mount another drive and set it up as a datastore to do it. It'll be a weekend job then :-(

    An easy way to add temporary storage is to set up a big NFS share and connect it as a datastore. I have used Ubuntu for this quite a few times - either on a physical server or in a VM. Just remember to export the temporary space with no_root_squash.


  • Advertisement
  • Registered Users Posts: 10,256 ✭✭✭✭Standard Toaster


    In that case ssh onto the host and use vmkfstools to convert the disk to a thin provisioned one and rename/replace the original. Delete if happy.

    vmkfstools -i DISK1.vmdk -d thin DISK1_thin.vmdk

    and use the 'thin' disk.

    Will of course need to be done with the vm offline.


  • Registered Users Posts: 385 ✭✭Zirconia
    Boycott Israeli Goods & Services


    Hi all, all sorted now, so I just wanted to let you know what I did. As per Swampgas's suggestion, I used VMWare Standalone Converter and ran it in the VM I needed to downsize and exported it to a new VM located on a temporary Datastore.

    After that I shutdown the original VM and verified the new VM was good, I then deleted the original VM and copied the new one the the permanent datastore (with loads of extra free datastore space).

    Thanks everyone for your suggestions, particularly Swampgas and also Standard Toaster for making me aware of other things you can do with vmkfstools. :)


  • Registered Users Posts: 10,256 ✭✭✭✭Standard Toaster


    Nice one Zirconia, always a good feeling to beat a problem. :)

    Having my own issues atm not too dissimilar with your own. Downsizing a linux vm with LVM partitions...convertor not an option!


  • Registered Users Posts: 13,016 ✭✭✭✭vibe666


    glad you got it sorted. :)

    it's not impossible to resize and existing vmdk, but the amount of time and mental energy required to do it just isn't worth the hassle imho.

    i was at the vmware presentation at the fitzwilliam hotel last week and i suggested it as a potential feature, along with being able to schedule virtual hardware changes (i.e. ram, cpu & disk resizing) upon a reboot of a vm, and it seemed like a popular idea so who knows what we'll see in the future. :)

    anyway, for now just running it through converter again and resizing the disk(s) and thin provisioning them is definitely the easiest option that requires minimal interaction if you have the free disk space to do it.


  • Registered Users Posts: 2,355 ✭✭✭cruhoortwunk


    Hey lads, I'm re-opening an old question here. But I'm in a similar situation. I have a CentOS VM on ESXi 4.1 The vhd is thin provisioned, but it's 50GB. I have used gparted to get it down to about 20GB. If I use df -h in the VM, I can see that the total is down to 20GB. But the provisioned size is still 50GB, and so is the vmdk.
    As far as I know, it hasn't got any simpler since 2011 to shrink a vmdk and reclaim space. Converter is not an option in this environment.
    Any ideas on how to reclaim that 30GB? I'm copying up a ghost iso at the moment, as I believe it'll work.


  • Advertisement
  • Registered Users Posts: 13,016 ✭✭✭✭vibe666


    two answers, one question. :)

    thin provisioning won't shrink a vm, it will only grow it.

    ghost isn't going to shrink a vmdk.

    why is converter not an option?


  • Registered Users Posts: 2,355 ✭✭✭cruhoortwunk


    No converter as it is managed by a vcentre box on a different network, so when I try converter I get a problem where the helper VM cant get an IP. Which I think is down to some traffic that is passing between the 2 networks during conversion is being blocked.
    I ended up just setting up a new Centos vm from scratch.
    I suppose the end solution would be to install a vcentre box on the same network, then use converter.


Advertisement