إضغط لتفاصيل الإعلانات



Results 1 to 1 of 1
Share
  1. #1
    Join Date
    Nov 2007
    Location
    Arab world!
    Posts
    6,168
    Blog Entries
    4
    Rep Power
    10

    Thumbs up Rebuilding the virtual machine's .vmx file from vmware.log

    Rebuilding the virtual machine's .vmx file from vmware.log (1023880)
    Also version 6.5 is covered below

    Purpose

    You may want to rebuild the .vmx file of a virtual machine and recover its contents if the .vmx is missing or has lost its configuration.

    This article provides a shell script that rebuilds the .vmx file from the vmware.log file.



    Resolution

    To rebuild the virtual machine's .vmx file using a shell script which parses the information from the vmware.log file:

    Notes:

    • VMware does not guarantee that this script will recover every .vmx file. This is only an option to try if the operation becomes necessary. For example, if the virtual machine configuration is changed after the last power on, then that information is not logged in the vmware.log and the .vmx file may not be accurate.
    • Ensure to take a backup of the .vmx file before proceeding.
    • Ensure that you run the commands or the script from the virtual machine working directory. To determine the working directory, right-click the virtual machine and click Edit Settings, then click Options > Virtual Machine Working Location.Run this command to create a new file using a text editor and give it execute permissions:
    • Code:
      touch vmxrebuild.sh && chmod +x vmxrebuild.sh






    1. Copy and paste this script to the file:
      Note: for version 6.5 use the second patch instead.

      Code:
      VMXFILENAME=$(sed -n 's/^.*Config file: .*\/\(.\+\)$/\1/p' vmware.log)
      echo -e "#\041/usr/bin/vmware" > ${VMXFILENAME}
      echo '.encoding = "UTF-8"' >> ${VMXFILENAME}
      sed -n '/DICT --- CONFIGURATION/,/DICT ---/ s/^.*DICT \+\(.\+\) = \(.\+\)$/\1 = "\2"/p' vmware.log >> ${VMXFILENAME}
      

      1. Save the file, ensuring that it has an .sh extension.

      For version 6.5 please run the patch below instead.


      Code:
      VMXFILENAME=$(sed -n 's/^.*Config file: .*\/\(.\+\)$/\1/p' vmware.log)
      echo -e "#\041/usr/bin/vmware" > ${VMXFILENAME}
      echo '.encoding = "UTF-8"' >> ${VMXFILENAME}
      sed -n '/DICT --- CONFIGURATION/,/DICT ---/ s/^.*DICT \+\(.\+\) = \(.\+\)$/\1 = \2/p' vmware.log >> ${VMXFILENAME}

    2. If the uuid.location has changed due to operations such as cloning or Storage vMotion, run this command to get the new UUID:

      Code:
      NEWUUID=$(sed -n "s/^.*UUID: Writing uuid.location value: '\(.\+\)'.*$/\1/p" vmware.log)

      Note: Whenever possible, use the latest vmware.log file.
    3. Run this command to replace the old UUID in the .vmx file with the new one:

      Code:
      if [ "${NEWUUID}" ] then sed -i "s/uuid.location = .*$/uuid.location = \"${NEWUUID}\"/" ${VMXFILENAME} fi
      
      
    4. Run the script using this command:

      Code:
      ./vmxrebuild.sh

    For more information, see Recovery of a lost or deleted virtual machine configuration file .vmx on an ESXi/ESX host (1002294).



    Last edited by Mohamed Fouad; 29-05-2018 at 11:47 AM.


  2. Facebook Comments - تعليقـك على الفيس بوك يسعدنا ويطور مجهوداتنـا


  3. Forum Ads:

  4. Forum Ads:

    اضفط هنا لمعرفة تفاصيل الإعلانات بالموقع


  5. Forum Ads:

    -->

Similar Threads

  1. Replies: 0
    Last Post: 11-03-2014, 04:47 PM
  2. Unlock the VMware VM vmdk file
    By Mohamed Fouad in forum VMware
    Replies: 0
    Last Post: 01-11-2013, 02:49 PM
  3. Replies: 0
    Last Post: 01-11-2013, 12:30 PM
  4. Replies: 0
    Last Post: 29-08-2011, 09:11 PM
  5. Replies: 12
    Last Post: 12-10-2010, 08:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

أقسام المنتدى

الروابط النصية

تابع جروبنا على الفيس بوك

صفحة Egypt Engineers على الفيس بوك

تابعنا على linkedin

جروبنا على الياهو جروب