You are on page 1of 9

5/31/2017 VMDKArchivesMattWharton

MATT WHARTON
ABOUT

TAG: VMDK

JUL HOW TO SHRINK A VMDK: SHRINKING A TOP POSTS &

31 VIRTUAL DISK IN VMWARE ESXI PAGES

2015 POSTED IN COMPUTING, VMWARE


HOW TO
by
Matt Wharton
First open up Disk Management in Computer Management in your WHITELIST A
guest Windows environment. DOMAIN IN OFFICE
365 EXCHANGE
Right click the volume on the disk you want to shrink. ONLINE

THE REDO LOG IS


Windows will inform you the maximum amount it can shrink the
disk by. Choose an amount that you wish to actually shrink it by CORRUPTED. IF
and click Shrink. THE PROBLEM
PERSISTS,
DISCARD THE
REDO LOG.

PROMOTING A
WINDOWS SERVER
2012 RODC TO
BECOME A
WRITEABLE
DOMAIN
CONTROLLER

SUBSCRIBE TO
BLOG VIA EMAIL

http://www.mattwharton.co.uk/tag/vmdk 1/9
5/31/2017 VMDKArchivesMattWharton

Windows will start the shrinking process and it might take some
Enter your email
time and appear to be hanging as Windows will actually be
address to subscribe to
defragmenting the disk in order to consolidate the free space
this blog and receive
towards the end of the disk before resizing the volume.
noti cations of new
posts by email.
Once it is done and you are satis ed that the volume on the disk
is the size you want it then you need to shut down the VM.
Email Address
SSH into the host and copy the VMDK le to make a backup of it,
just the descriptor le not the at le. Subscribe

cpvmname.vmdkvmnameoriginal.vmdk

Open up the VMDK le in a text editor and nd the line that CATEGORIES
describes the size of the at le. Similar to the following
ACTIVE DIRECTORY
#Extentdescription
BOOKS
RW209715200VMFSvmnameflat.vmdk
CERTIFICATION

The number is the size of the virtual disk in terms of disk sectors, COMPUTING
where each sector is 512 bytes. So a 100GB virtual disk is
MICROSOFT
209715200 sectors.
OFFICE 365
You will need to change this number to correspond to the new
disk size where x = size in GB
REVIEWS

TWEETS
vmdk_size = [x * (1024*1024*1024)] / 512 UNCATEGORIZED
I have chosen to shrink my disk to 60gb, so my new Extent VMWARE
description now reads as follows:
LINKS
#Extentdescription

ABOUT.ME PROFILE
RW125829120VMFSvmnameflat.vmdk
LINKEDIN
You now need to clone the drive to get it to the new size:
PERSONAL BLOG
vmkfstoolsivmname.vmdkvmnamenew.vmdk SPICEWORKS PROFILE

The bit we are interested in is the newly created vmname-new-


TWITTER
at.vmdk le.
MY WIFE AMY
Rename the old at le from vmname- at.vmdk to vmname- at-
old.vmdk TWITTER

VERY MUCH SO
and rename the vmname-new- at.vmdk le to vmname- at.vmdk

MAY 2017
http://www.mattwharton.co.uk/tag/vmdk 2/9
5/31/2017 VMDKArchivesMattWharton

Start the VM up and it should show the new smaller disk. When
you are satis ed that everything is working you can now delete M T W T F S S
the old unneeded les from your datastore. 1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
FEB

JAN THE REDO LOG IS CORRUPTED. IF THE RECENT POSTS


31 PROBLEM PERSISTS, DISCARD THE REDO
2014 LOG. WINDOWS 10 CANNOT
by ACCESS TCP/IPV4
Matt Wharton POSTED IN COMPUTING, VMWARE
PROPERTIES ON A PPTP
VPN CONNECTION

WINDOWS 10 ROLL-OUT:
WSUS, GROUP POLICY
AND INSTALLATION

SHAREPOINT ONLINE
LOGIN FAILURE. ISSUE
TYPE: USER NOT IN
Yesterday about an hour before the end of my work day one of our DIRECTORY
critical servers fell over and was displaying the following message
MICROSOFTS WINDOWS
in the vSphere client.
10 HARDWARE EVENT IN
9 MINUTES
The redo log of VisualSVNServer_1-000001.vmdk is corrupted. If
the problem persists, discard the redo log. UNITRENDS DRAAS:
DISASTER RECOVERY AS
The error message refers to a redo log, but this is legacy VMware A SERVICE
terminology. VMware have from ESXi 3.1 started to use the term
snapshot to mean the same thing but for some reason the error META
messages still use the old term.

LOG IN
The server was named Subversion and was a VisualSVN Server.
ENTRIES RSS
There was a snapshot dated from 15th December 2013 in the
COMMENTS RSS
Snapshot manager for the Subversion VM so returning to this
snapshot would have meant returning to a point several weeks WORDPRESS.ORG
ago and then trying to import the backup of the repository that
was made the night of 29th January.

The underlying cause of the corruption cannot be de nitively


determined but I think was due to the amount of disk activity on
the physical disk that constitutes datastore 3_2 on the host server
S003-ESXi. This caused the system to fail to write to the log and

http://www.mattwharton.co.uk/tag/vmdk 3/9
5/31/2017 VMDKArchivesMattWharton

to create updated delta disks which contain all the changes to the
disks since the point of the snapshot.

I believe that if there had not been a snapshot the data corruption
probably wouldnt have happened. I have since educated staff that
taking snapshots in vSphere is really not the same as backing up
the server and they shouldnt be doing it on the Subversion server
at all.

I resolved the issue with Subversion by carrying out the following


steps.

I clicked OK to the error message in the slim hope that the VM


could overcome the glitch itself upon a simple reboot.

This didnt work. So I started the process of backing up the VM by


forcing a shutdown of the machine by virtually cutting off the
power and then making a copy of the virtual machine folder on
the datastore.

Whilst the copy process was going I checked Virtual Machine


Logs, vmware-3.log was completely corrupt and the vmware.log
was showing some corruption.

The copy process took over an hour as it was 150GB in total size.
Mostly due to the two virtual disks the rst VisualSVNServer.vmdk
which constitutes the C: drive of the server is 40GB and the
second VisualSVNServer_1.vmdk which is the E: drive is 100GB.

Having made a copy of everything I attempted to x the


snapshots. I made sure that there was suf cient space on the
datastore and then using Snapshot Manager in vSphere created a
new snapshot of the Subversion VM.

This operation was successful, so I then tried to commit the


changes and to consolidate the disks. This worked for
VisualSVNServer.vmdk merging all the changes, but not entirely
for VisualSVNServer_1.vmdk, however it did reduce the size of the
delta disks signi cantly meaning that there was likely to be only
minimal data lost.

Nothing more could be done through the vSphere client so I then


started a process of trying to manually consolidate the following
disks into a single disk.
VisualSVNServer_1.vmdk
VisualSVNServer_1-000001.vmdk
VisualSVNServer_1-000002.vmdk

http://www.mattwharton.co.uk/tag/vmdk 4/9
5/31/2017 VMDKArchivesMattWharton

Enabled SSH on the host server s003-esxi.

Using PuTTY I logged into the command line of the host and
changed the directory to the relevant directory that contained the
virtual machine les for Subversion
/vmfs/volumes/Datastore3_2/VisualSVNServer

Then ran the command ls *.vmdk lrt to display all virtual disk
components.

Then starting with the highest number snapshot ran the following
command to clone the disk in a way that would merge the delta
disks into a copy of the main disk.

vmkfstools i VisualSVNServer_1-000002.vmdk VisualSVNServer-


Recovered_1.vmdk

This process took another hour or so as it was trying to create a


100GB le.

This failed with the following error message displayed:

Failed to clone disk: Bad File descriptor (589833)

Then starting with the next highest number snapshot I ran


command to clone the disk without the most recent changes.

vmkfstools i VisualSVNServer_1-000001.vmdk VisualSVNServer-


Recovered_1.vmdk

This process again took about hour as again it was trying to create
a 100GB le.

Again this failed with the following error message displayed:


Failed to clone disk: Bad File descriptor (589833)

Abandoned the idea of merging the disks I removed the VM from


the inventory in vSphere and then moved all but the following
les into a separate folder.
VisualSVNServer.nvram
VisualSVNServer.vmx
VisualSVNServer.vmdk
VisualSVNServer_1.vmdk

I could then recreate the VM from these les. I downloaded the


le VisualSVNServer.vmx which is the virtual machines
con guration le and stores the settings regarding the virtual
devices that make up a virtual machine. I edited the le to change

http://www.mattwharton.co.uk/tag/vmdk 5/9
5/31/2017 VMDKArchivesMattWharton

all references to VisualSVNServer_1-000002.vmdk to


VisualSVNServer_1.vmdk so that the machine could be booted up
ignoring the delta disks and any data they might contain.

Added the VM back into the inventory and then booted up the
machine. It booted up ne, checked the E: drive and there
appeared to be data written to the disk all the way up to the time
that the server fell over so it appeared that there was minimal if
any data lost.

Thanks to XtraVirt for the necessary steps.

MAY VMDK RECONSTRUCTION


29 POSTED IN COMPUTING, VMWARE
2013
The of ce move meant shutting down the VMware hosts and one
by
Matt Wharton of the side effects of this was that a couple of the virtual
machines that had been happily running didnt come back up.

One didnt matter at all so I could safely ignore it, but the other
was a demo server used by one of the company directors to show
off our software to prospective clients and therefore needed to be
working asap.

I was faced with quite a mystery as it seemed to have disappeared


completely, it wasnt listed in the inventory of the host in Vsphere
and the datastores connected to the host didnt contain the
expected les either.

However I wasnt completely at a loss as there was a message in


the hosts inventory indicating that something had gone wrong
and a virtual machine it had been hosting was missing and I knew
that some of our VMs have been renamed and so the
corresponding les in the datastores do not have matching names.

So I went looking for some orphan les. I found the les in


question but it was just the VMDK les and they seemed to have
been missing the VMDK metadata les also.

http://www.mattwharton.co.uk/tag/vmdk 6/9
5/31/2017 VMDKArchivesMattWharton

So in order to rebuild the virtual machine I needed to reconstruct


the VMDK les so that I had usable virtual hard disk to the attach
a new virtual machine to and given that we are using the free
vSphere ESXi 4.0 version this meant using the unsupported Tech
Support Mode and instructions from here
http://kb.vmware.com/selfservice/microsites/search.do?
language=en_US&cmd=displayKC&externalId=1002511

To use Tech Support Mode:

LogintoyourESXihostattheconsole.
Press Alt+F1 to switch to the console window.
Enter unsupported to start the Tech Support Mode login process.
Note that no text will appear on the console window.
Enter the password for the root user. Tech Support Mode is now
active.
Complete tasks in Tech Support Mode.
Enter the command clear to clear the screen of any residual data
from step 5. This may be required by your local security policies.
Enter the command exit to exit Tech Support Mode.
Press Alt+F2 to return the server to DCUI mode.

So I logged into the terminal of the ESXi host.

Then to recreate the virtual machine disks I navigated to the


directory that contained the virtual machine disks with the
missing descriptor le using the following command (having
previously found the relevant volume from browsing Storage in
the vSphere client on my PC:

cd"/vmfs/volumes/4bfd0ee148e6535e7d30
0026b97ee7d2/CRJtest/"

The instructions then asked me to identify the type of SCSI


controller the virtual disk is using by examining the virtual
machine con guration le (.vmx). But I didnt have the .vmx le so
I took a look at similar VMs and they used the SCSI controller type
lsilogic.

I identi ed and recorded the exact size of the - at le using the


command:

#lslVS030Srv08Tmplflat.vmdk
rw1rootroot32212254720May2912:30
VS030Srv08Tmplflat.vmdk

Then used the vmkfstools command to create a new virtual disk:

http://www.mattwharton.co.uk/tag/vmdk 7/9
5/31/2017 VMDKArchivesMattWharton

#vmkfstoolsc32212254720alsilogicdthin
temp.vmdk

This command uses these ags:


-c (This is the size of the virtual disk).
-a (Whether the virtual disk was con gured to work with BusLogic
or LSILogic).
-d thin (This creates the disk in a thin-provisioned format).

Note: To save disk space, the disk was created in a thin-


provisioned format using the type thin. The resulting at le then
consumes minimal amounts of space (1MB) instead of
immediately assuming the capacity speci ed with the -c switch.
The only consequence, however, is the descriptor le contains an
extra line that must be removed manually in a later step.

The les temp.vmdk and temp- at.vmdk were created as a result.

I deleted the unneeded temp- at.vmdk using the command:

#rmtempflat.vmdk

And renamed temp.vmdk to the name that match the orphaned


. at le (or VS030-Srv08Tmpl- at.vmdk, in my case):

# mv temp.vmdk VS030-Srv08Tmpl- at.vmdk

Then the descriptor le needed to be edited to match the . at le:

Under the Extent Description section, change the name of the . at


le to match the orphaned . at le you have.

Find and remove the line ddb.thinProvisioned = 1 if the original


.vmdk was not a thin disk. If it was, retain this line.

This completed the reconstruction of the rst virtual hard disk, I


did the same for the second disk and then I was in a position to
rebuild the machine.

Building the VM was straightforward and not worth writing in any


great detail as it is simply a case of using the wizard in the
vSphere client and then selecting Use Existing option instead of
Create New when it gets to the section about virtual hard disks.

http://www.mattwharton.co.uk/tag/vmdk 8/9
5/31/2017 VMDKArchivesMattWharton

CURRENTLY RECENT CATEGORIES


STUDYING POSTS
ACTIVE DIRECTORY

Microsoft's Know it. WINDOWS 10 CANNOT BOOKS


Prove It. ACCESS TCP/IPV4
CERTIFICATION
Identity & Access PROPERTIES ON A PPTP
VPN CONNECTION COMPUTING
Management
WINDOWS 10 ROLL-OUT: MICROSOFT
PowerShell via Don WSUS, GROUP POLICY AND
OFFICE 365
Jones's excellent book INSTALLATION
Learn Windows REVIEWS
SHAREPOINT ONLINE LOGIN
PowerShell in a Month FAILURE. ISSUE TYPE: USER TWEETS
of Lunches NOT IN DIRECTORY
UNCATEGORIZED
MICROSOFTS WINDOWS
10 HARDWARE EVENT IN 9 VMWARE
MINUTES
UNITRENDS DRAAS:
DISASTER RECOVERY AS A
SERVICE

GOOGLE+

Copyright 2015-2017 Matt Wharton | Powered by WordPress | Design by About

Iceable Themes

http://www.mattwharton.co.uk/tag/vmdk 9/9

You might also like