Today, I would like to share a howto reduce or shrink a VMware VMDK file (aka hard disk) for a Windows VM . Bare in mind that this is not reducing or shrinking a volume in Windows and leaving a free partition space. For this howto, I will be reducing or shrinking the Hard Disk 2 for a Windows VM from 30GB to 5GB whereby the example VMDK file name will be sourcedisk_1.vmdk which is D:\ drive. Logon to your Windows VM and shrink the target disk 30GB to 5GB. In the Disk Management, right click on the partition that you want to shrink and select “Shrink Volume” from the menu.

Continue reading

Today, I would like to share how to retrieve ESX host network info using vSphere PowerCLI. Make sure you are connected to a vCenter. Below is the one liner command you can retrieve the ESX host network info and export to a CSV file: –

Get-VMHost | Where { $_.ConnectionState -eq "Connected"} | Get-VMHostNetwork | Select Hostname, DomainName, ConsoleGateway, DNSAddress -ExpandProperty ConsoleNic | Select Hostname, DomainName, PortGroupName, IP, SubnetMask, ConsoleGateway, Devicename | Export-Csv -NoTypeInformation C:\Temp\ESXHost.csv

Today, I would like to share how to change VMware virtual machine (VM) network adapter type using vSphere PowerCLI. Make sure the VM is shutdown. Below is the one liner command you can change the network adapter type: –

get-vm virtual_machine_name | get-networkadapter | set-networkadapter -type "vmxnet3"

To know what network adapter available, you can visit VMware KB1001805. You need to power up the VM after the successful change of network adapter type. Thank you and enjoy.

After years of using VMware products, be it VMware Server, VMware Workstation, VMware Infrastructure and VMware vSphere, I haven’t encounter failure on booting a Windows OS. But, one fine day this week itself, one of the Windows Server 2003 virtual machine (VM) can’t boot up because of missing boot.ini file.

Without any delay, I download the Virtual Disk Development Kit 1.2.1 from http://www.vmware.com/support/developer/vddk/ and I copy out the virtual disk from the shared storage which is virtual_machine_name-flat.vmdk (file name is an example only) with the filesize of 20GB. I tried mounting the VMDK file locally but failed. After several tries, I decided to copy the rest of the files in the VM folder from the share storage. Woot woot, I am able to mount the VMDK file using the command below: –

# vmware-mount X: "C:\VM\virtual_machine_name.vmdk"

Now, the VMDK file is mounted as X: drive letter locally so I begin to copy a good copy of boot.ini file. Copying those files to the shared storage is a pain because I have to wait 30 mins. Once the copying is completed, I begin to power on the VM but it failed to boot up telling me that NTDETECT.com is missing. What the heck, I have to copy thoses file again from shared :(

After, copying a good copy of NTDETECT.com and a successfully boot up of the VM then I was relief. Its time for me to hack the remote mount a VMDK file. Indeed, I successfully mount the VMDK remotely. Yatta. Please use the command below: –

# vmware-mount X: "[Shared_Storage] virtual_machine_name/virtual_machine_name.vmdk" /i:"DataCenter/vm/Servers/virtual_machine_name" /h:VCenterName /u:"domain\user_name" /s:your_password

With the command above, the VMDK is mounted as X: drive letter. Please take note as below: –

[Shared_Storage] virtual_machine_name/virtual_machine_name.vmdk = you can get this path in vSphere Client, Edit Settings on the VM and select the virtual disk
/i:”DataCenter/vm/Servers/virtual_machine_name” = you can get this in the tree view of vShphere Client, the “vm” in this path is complusory

To list/view mounted volume(s), run the command below: –

# vmware-mount /L

To umount a mounted volume, run the command below: –

# vmware-mount X: /d

I hope the commands above will help you in your daily VMware job. Please feel free to give comments and suggestions to the commands I shared. Thank you.

Found this great software for writing boot disk image file from USB drive, Roadkil’s Disk Image. Let me start with a simple steps below: –

1. Run the software (I downloaded the standalone version).

2. Click “Store Image” tab and select the correct drive to read the image from.

3. Click “Browse” button and locate the place you want to store the disk image target file.

4. Once done, click the “Start” button to proceed.

Is that simple? Thank you for reading.

If you found these helpful, please contribute to help: