Virtual Kim

@Kim_Bottu … Virtually Gung Ho

Recreate a VMX file from the log file of a VM

Rarely you might come across a situation where you discover that a VM is running without a VMX file. The link to the VMKB document: how do you solve this? 

I have used this and it works really well!

You will have to rebuild the VMX file but how do you do that? The following is a procedure on how to accomplish exactly that.

1. Shutdown the VM but do not remove it from the inventory.

2. create the following script: vmxrebuild.sh in the directory of the VM.

vi vmxrebuild.sh

Add the following code, type i to insert text

LOGFILE=vmware.log

VMXFILENAME=$(sed -n ‘s/^.*Config file: .*\/\(.\+\)$/\1/p’ ${LOGFILE})

echo -e

“#41/usr/bin/vmware” > ${VMXFILENAME}

echo ‘.encoding = “UTF-8″‘ >> ${VMXFILENAME}

sed -n ‘/DICT — CONFIGURATION/,/DICT —/ s/^.*DICT \+\(.\+\) = \(.\+\)$/\1 = “\2″/p’ ${LOGFILE} >> ${VMXFILENAME}

NEWUUID=$(sed -n “s/^.*UUID: Writing uuid.location value: ‘\(.\+\)’.*$/\1/p” ${LOGFILE})

if [ “${NEWUUID}” ]

then

sed -i “s/uuid.location = .*$/uuid.location = \”${NEWUUID}\”/” ${VMXFILENAME}

fi

To exit the text editor click ESC and type :wq!

:wq!

Enable the script for execution

chmod +x vmxrebuild.sh

RUN THE SCRIPT

./vmxrebuild.sh

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on August 11, 2015 by in VM, VMX and tagged , .
Follow Virtual Kim on WordPress.com

Blog Stats

  • 26,798 hits
%d bloggers like this: