The Computer Oracle

How to reduce the size of VMware disk

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Music Box Puzzles

--

Chapters
00:00 How To Reduce The Size Of Vmware Disk
00:34 Accepted Answer Score 20
00:49 Answer 2 Score 4
01:28 Answer 3 Score 3
01:45 Answer 4 Score 41
02:18 Thank you

--

Full question
https://superuser.com/questions/211798/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#vmware #vmwareworkstation #vmwareplayer #esxi #vmdk

#avk47



ANSWER 1

Score 41


There are three steps:

  1. Defragment (no need to un/remount anything)

    sudo e4defrag /

    Ignore any errors. Some files like symlinks and device files can't be defragmented.

  2. Zero-fill all unused space so VMware knows it's indeed unused:

    dd if=/dev/zero of=wipefile bs=1M; sync; /bin/rm wipefile

  3. Run the shrink operation:

    sudo vmware-toolbox-cmd disk shrinkonly




ACCEPTED ANSWER

Score 20


I've found the solution – you have to compact your hard drive:

Virtual Machine - Settings - General - Clean Up Virtual Machine




ANSWER 3

Score 4


Open VMware Toolbox in the guest (as root) and shrink the disk. (Documentation)


If you don't have VMware Tools, you can shrink the disk manually in two steps. First, clear the free space on the virtual disk using a tool like zerofree. Zerofree is available in Ubuntu, but since it requires the guest OS filesystem to be mounted read-only you may want to run it off a live CD. Parted Magic reportedly includes zerofree.

After zeroing the free space, open Virtual Machine Settings and compact the virtual disk.




ANSWER 4

Score 3


Use

sudo vmware-toolbox-cmd disk shrinkonly

from the command prompt in your Ubuntu guest.

(Tested on Ubuntu 14.04 LTS guest + Windows 10 Host + VMWare Workstation 12.1.1 )