Archive for the ‘VM’ Category

Shrink VMware virtual disks

February 20, 2011

Virtual disks usually only expand, their sizes won’t get reduced even files are removed.
The problem originates from the fact how files are managed by a file system. When a file is removed from a disk, its contents remain, only spaces taken by the removed file are reclaimed by the file system.

I used Virtual PC, VirtualBox and QEMU, and is using VMware Fusion exclusively on Mac (sorry, Parallels).
I don’t know there is a single step process to shrink virtual disks, but here’s how I manage to get my virtual machines’ sizes in control by:
1. On VM, remove unnecessary files such as browser’s cache, temporary files, etc.
2. defragging disks for Windows VMs. Linux ext3 and ext4 file systems don’t need defrag.
The purpose of defragmentation is to improve file I/O performance, and have a better opportunity to shrink size more.
Enter the following from Console to launch Disk Defragmenter.
For XP Windows VM, such as XP or Windows 2003, type “dfrg.msc”:

XP or Windows 2003 Disk Defragmenter

For Windows 7 VM, including Windows Server 2008, type “dfrgui”:

Win7 or Windows Server 2008 Disk Defragmenter

3. On VM, zeros out previously used and reclaimed disk spaces.
For Windows, you can find Sysinternals SDelete. To zero out, say c: drive, you can launch it from Console as: “sdelete -c c:”.

SDelete

For Linux, navigate to any folder within the disk you want to zero out, and run the following command as a super or root user: “cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill”.
It may take some time to finish. You will see a disk full message. It is OK, the generated file is removed right away.

Zeros

4. On host, shrink virtual disks. You can use UI to do it, as the following screen shots.

VM Settings

VM Disks

Or, it can be done by the command line tool vmware-vdiskmanager with -k option, which is located at:
/Library/Application Support/VMware Fusion. You only need specify the master virtual disk (Disk DescriptorFile).
My xubunty.vmdk is split into 2 GB files, and here’s how to shrink it:

vdiskmanager

Change VMware virtual machine’s MAC address

February 9, 2010

When I try out evaluation software, such as ARM RVDS4 Professional, TI CCS4, I would often run them on different platforms, say Fedora, Ubuntu, and/or XP. The problem is that licenses are often locked on particular machine per ethernet MAC address.
After couple of tries and googling, I figured out how to change MAC address for VMware virtual machines. My host is a Macbook Pro/OS X 10.6, VMware Fusion 3.0.1. My ethernet device is listed as ethernet0. Here’s what I did.
Open virtual machine’s configuration file, .vmx file in your favorite editor, change two lines:
1) ethernet0.addressType = “generated” to “static”, and
2) ethernet0.generatedAddress = “your existing MAC address” to
ethernet0.address = “you new MAC address”

This gives me better opportunity to evaluate software before making the purchase call.

I found out, in another day, that by using MAC address type of vpx, it allows you to use address in the range of “00:50:56:xx:xx:xx.”