VMWare-Fusion-Shrink-Linux-Disk

Shrink VMWare Fusion Linux Guest Virtual Disk

Right! VMWare Fusion on Mac OSX allows you to shrink virtual disks easily for Windows virtual machines right from the graphical interface – Virtual Machine -> Settings -> General -> Clean Up Virtual Machine… but how about for Linux guests? There isn’t such option to do this from the graphical interface, so Terminal here we go!

[wp_ad_camp_3]

If you have a virtual disk that grows as data is added, you can shrink it as described below. If you allocated all the space for your virtual disk at the time you created it, you cannot shrink it.

vmware-fusion-virtual-hard-drive

When you delete files from your virtual machine, Fusion does not return the space to your Mac. Shrinking the virtual machine by cleaning up the hard disk returns that freed space to your Mac.
Cleaning up the virtual hard disk also consolidates any unconsolidated snapshot files left on the virtual machine. Unconsolidated snapshot files can be left on the virtual machine when manually deleting a snapshot fails.

There are a couple things we want to do before shrinking the virtual disk; cleaning the clutter (deleting unnecessary files), defragmenting the drive and wiping the free space clean so the shrinker will know what is free to get rid of, to recover as much disk space as possible.

So, boot up your Linux Virtual machine, delete all old files, ISO images, empty the trash and fire up a Terminal window.

Preparing Linux Guest Virtual Machine

1- Defrag guest virtual disk (usually sda1, sdb1) – Listing in Terminal: ls -la /dev/sd*

Note: Defragmenting the virtual disk will tax the host and guest I/Os. Both, your Mac and the Guest OS may become slow or unresponsive while this process is taking place. Be patient.

sudo e4defrag /dev/sda1

Defrag Guest virtual disk

2- Wipe the guest virtual disk free space clean so the shrinker will know what is free to get rid of:

Note: Wiping the virtual disk free space clean will tax the host and guest I/Os. Both, your Mac and the Guest OS may become slow or unresponsive while this process is taking place. Again, be patient!

dd if=/dev/zero of=wipefile bs=1024x1024; rm wipefile

Wipe guest free space

We’re now ready to shrink the virtual disk but we can’t reclaim space with the virtual machine running, so shut it down first (Power off).

Shrink VMWare Fusion Linux Guest Virtual Disk

Open Mac OS X Terminal and change directory to /Applications/VMware/Fusion.app/Contents/Library/

cd /Applications/VMware\ Fusion.app/Contents/Library/

OSX Terminal

Next browse to your Virtual Machine in Finder, right click it and select “Show Package Contents

Show Package Contents

Package Contents

In Terminal, type ./vmware-vdiskmanager -k and drag & drop the virtual disk to Terminal for its path to be autocompleted as shown below:

Virtual Disk Path

Press enter and be patient while your Linux virtual disk is shrank :)

Virtual Disk Shrink Completed

Virtual Disk size shrank

Cheers!

[wp_ad_camp_5]

Related Post

re0: Watchdog Timeout Error fix for FreeNAS 11.2 It is no secret that FreeNAS is a popular NAS solution used by many. The latest FreeNAS-11.2-U2.1 (Build Date: Feb 27, 2019) showed up with several im...
Helping with a Linux Mint Mirror I've been using Mint for a little while; a friendly Linux distribution that has gained quite some popularity for its easy of use and out-of-the-bo...
Bypass pkexec password prompt for admin accounts So, you want to bypass polkit password prompt in Linux Lite globally. There is a million and some reasons in terms of security why you should think tw...

Leave a Reply