VMware Communities
scottharper
Contributor
Contributor

Virtual Disk Size Change

Hi,

I migrated a PC to a virtual machine on my mac. The hard disk had about 80 GB worth of data on it at the time of migration. I have since gone into the virtual machine and removed all but about 25 GB worth. The problem is my mac still sees the machine as occupying 80GB worth of space. I performed the Disk Clean operation in VM Ware but that didn't seem to do the trick. The resize hard disk won't let me go below 298GB.

When I run OmniSweeper it is showing by Virtual Machine as occupying 80GB.

I am running out of space on my hard disk, so any suggestions would be very helpful and much appreciated.

Thanks!

-Scott

Reply
0 Kudos
11 Replies
Qlippoth
Contributor
Contributor

I think it may depend on whether the converted VM was set for a preallocated disk size. I only started using VMWare a few months ago, so I'm not familiar enough yet.

Anyone else got info on this?

- Qlippoth

Reply
0 Kudos
scottharper
Contributor
Contributor

I'm not sure if it was set for a pre-allocated disk size or not when it was migrated. Any idea on how I should proceed either way?

Thanks for the response.

-Scott

Reply
0 Kudos
Qlippoth
Contributor
Contributor

I'm actually very curious about this as well, as I had set up a VM with much more space than I ended up needing. that being said, I haven't done any research just yet, but I did run across this post during a brief search: http://communities.vmware.com/thread/196810

They reference this site, I added the most promising link I found on the site: http://vsphere-land.com/tips-tricks/re-sizing-virtual-disks

- Qlippoth

Reply
0 Kudos
TobiasKracht
Expert
Expert

You are using so-called thick disks - their size is pre-allocated, and also available thin disks (technology called thin provisioning) - they have a maximum size of image, but allocate only size of data. You can convert it one to another without problems

StarWind Software R&D

StarWind Software R&D http://www.starwindsoftware.com
Reply
0 Kudos
leenux_tux
Contributor
Contributor

Hi,

I think there may be a simple way around this issue. I have had to expand a disk in the past using "vmware-vdiskmanager" and GPARTED. I would imagine that both tools can be used to shrink a disk file as well.....

Make a backup of the machine before you start this process. You will also need to remove any snapshots as I don't think reduction of disks, via vmware-vdiskmanager, works when you have snapshots.

1, Reduce the amount of space used in the VM guest, I think you have already done this (25GB).

2, Download an ISO image of "GPARTED" from "http://gparted.sourceforge.net/"

3, Shutdown your VM guest

4, Alter the VM guest so that it has the ISO image attached as a CDROM drive.

5, Boot your VM. You will need to be very quick with the "ESC" key so that you can choose an alternate boot device. In fact it may take a couple of tries to get the menu option.

6, Let the boot from ISO image complete, you will be asked a couple of questions on the way about keyboard and language. You will be presented with a screen that allows you to (amongst other things) manipulate the size of a disk.

7, Reduce the amount of free space on your disk to the amount required. The screen is colour coded so you can not reduce it further than allowed.

8, Shutdown the VM guest.

9, Open up a command prompt (shell) and navigate to where the vmware-vdiskmanager program resides.

10, Use vmware-vdiskmanager -k to reduce the size of the disk. You will need to make sure that the amount you reduce by fall in line with what you did in GPARTED.

Good luck Smiley Happy

Reply
0 Kudos
khughes
Virtuoso
Virtuoso

I have not used that tool but to my knowledge you can only grow a vmdk file, not shrink it. Your easiest way might be to just import that VM to another VM (like you did your physical to virtual) and resize the hard drive space there.

If you do try and use the GPARTED tool, make sure you make a copy of your VM or clone a version off and test it on that prior.

  • Kyle

-- Kyle "RParker wrote: I guess I was wrong, everything CAN be virtualized "
Reply
0 Kudos
TobiasKracht
Expert
Expert

Yo can do it without any problems. But first need to shrink size of partition and than size of disk.

StarWind Software R&D

StarWind Software R&D http://www.starwindsoftware.com
Reply
0 Kudos
leenux_tux
Contributor
Contributor

vmware-vdiskmanager can shrink as well. Here is the output from the help, notice the "-k" option Smiley Happy

VMware Virtual Disk Manager - build 185404.

Usage: vmware-vdiskmanager.exe OPTIONS <disk-name> | <mount-point>

Offline disk manipulation utility

Operations, only one may be specified at a time:

-c : create disk. Additional creation options must

be specified. Only local virtual disks can be

created.

-d : defragment the specified virtual disk. Only

local virtual disks may be defragmented.

-k : shrink the specified virtual disk. Only local

virtual disks may be shrunk.

-n <source-disk> : rename the specified virtual disk; need to

specify destination disk-name. Only local virtual

disks may be renamed.

-p : prepare the mounted virtual disk specified by

the drive-letter for shrinking.

-r <source-disk> : convert the specified disk; need to specify

destination disk-type. For local destination disks

the disk type must be specified.

-x <new-capacity> : expand the disk to the specified capacity. Only

local virtual disks may be expanded.

-R : check a sparse virtual disk for consistency and attempt

to repair any errors.

Other Options:

-q : do not log messages

Additional options for create and convert:

-a <adapter> : (for use with -c only) adapter type

(ide, buslogic or lsilogic)

-s <size> : capacity of the virtual disk

-t <disk-type> : disk type id

Options for remote disks:

-h <hostname> : hostname of remote server

-u <username> : username for remote server

-f <filename> : file containing password

-P <port> : optional TCP port number (default: 902)

-S : specifies that the source disk is remote, by default

the remote options are assumed to refer to the

destination.

Disk types:

0 : single growable virtual disk

1 : growable virtual disk split in 2GB files

2 : preallocated virtual disk

3 : preallocated virtual disk split in 2GB files

4 : preallocated ESX-type virtual disk

5 : compressed disk optimized for streaming

The capacity can be specified in sectors, KB, MB or GB.

The acceptable ranges:

ide adapter : http://1MB, 950.0GB

scsi adapter: http://1MB, 950.0GB

ex 1: vmware-vdiskmanager.exe -c -s 850MB -a ide -t 0 myIdeDisk.vmdk

ex 2: vmware-vdiskmanager.exe -d myDisk.vmdk

ex 3: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 0 destinationDisk.vmdk

ex 4: vmware-vdiskmanager.exe -x 36GB myDisk.vmdk

ex 5: vmware-vdiskmanager.exe -n sourceName.vmdk destinationName.vmdk

ex 6: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 4 -h esx-name.mycompany.com \

-u username -f passwordfile "[storage1]/path/to/targetDisk.vmdk"

ex 7: vmware-vdiskmanager.exe -k myDisk.vmdk

ex 8: vmware-vdiskmanager.exe -p <mount-point>

(A virtual disk first needs to be mounted at <mount-point>)

Reply
0 Kudos
scottharper
Contributor
Contributor

After doing a lot of searching, why couldn't I just do this by going through VMWare Tools -> shrink ???

I'm guessing it must not be that simple but I'm trying it right now.

I found the vmware-vdiskmanager but how do I actually run it? Sorry for the novice question but I am totally lost when it comes to the command line. I opened it and saw the screen with the options you listed below, but it isn't obvious to me what I should do now that the screen is open. It says "(A virtual disk first needs to be mounted at <mount-point>)" but how do it do that?

Thanks for the help. I've been spending all week doing defrags and making sure the disk was cleaned up before digging deeper into this.

Thanks!

Reply
0 Kudos
leenux_tux
Contributor
Contributor

Hello,

Don't forget there are two sides to wanting to shrink a disk (or expand it). Just shrinking or expanding the "VMDK" does not shrink or expand the hard drive for the guest operating system. For example, if using a Windows guest shrinking the VMDK on the VMware host file system will not magically reduce the size of the "C:" drive on the VM guest. The same can be said for a Linux guest and the related file systems/Logical Volumes.

In essence it all depends upon what your goals are. If you just want to reduce the amout of disk space that the VMDK's take up you can do this from the VMware tools, or from the vmware-vdiskmanager. I believe (though I may be wrong) that the VMware tools disk reduction program just uses vmware-vdiskmanager in the background to acheive your objectives. If however you want to reduce, or increase, the amount of disk capacity which the VMware Guest Operating System can see you also need to use a tool such as "GPARTED" to manipulate the size of the file system(s) within the VM guest.

Hope this helps

Leenux_tux

Smiley Happy

Reply
0 Kudos
scottharper
Contributor
Contributor

OK. This is starting to make more sense. I'm going to try the GPARTED solution. Thanks!

Reply
0 Kudos