vmware modify the virtual machine name

The original virtual machine name: OLD_VMNAME
need to be modified to: NEW_VMNAME

When vmware create a virtual machine, and stores the corresponding disk to the virtual machine configuration file name. If you change the name of the virtual machine is stored only on the client name vcenter interface is not modified (only modify .vmx file displayName), so after leaving for operation and maintenance risks. End may be modified to store a name corresponding to the following manner.


First, the virtual machine machine, and remove from the list


Second, modify the virtual machine directory name
ssh login host, enter the directory to store the virtual machine resides
mv OLD_VMNAME / NEW_VMNAME
cd NEW_VMNAME


Third, modify the folder of all the virtual machines associated with the file name
mv OLD_VMNAME.vmx NEW_VMNAME.vmx
mv OLD_VMNAME.vmdk NEW_VMNAME.vmdk
mv OLD_VMNAME-flat.vmdk NEW_VMNAME-flat.vmdk
...


Fourth, modify the virtual machine configuration file (xxx.vmx)
Sed -i 'S NEW_VMNAME # # # OLD_VMNAME G' NEW_VMNAME.vmx

Fifth, modify disk configuration file
disk file is associated with the end of .vmdk, roughly the following categories

 

5.1 modify the configuration file system disk
sed -i 's # OLD_VMNAME # NEW_VMNAME # g' NEW_VMNAME.vmdk

# If you also need to modify the configuration snapshot snapshot (typically name-00000N.vmdk vm_name)
Sed -i 'S NEW_VMNAME # # # OLD_VMNAME G' NEW_VMNAME-000002.vmdk
Sed -i 'S NEW_VMNAME # # # OLD_VMNAME G' 000003.vmdk-NEW_VMNAME
...
Sed -i 'S NEW_VMNAME # # # OLD_VMNAME G' NEW_VMNAME-00000N.vmdk


5.2 modify the data disk configuration file (if no data disc, this step can be ignored)
Sed -i '# S # OLD_VMNAME_N G # NEW_VMNAME_N 'NEW_VMNAME_M.vmdk

# disk if there is a snapshot of the data also need to modify the configuration snapshot (typically name-00000N.vmdk VM_NAME_M)
Sed -i' S NEW_VMNAME # # # OLD_VMNAME G 'NEW_VMNAME-000002.vmdk
Sed -i 'S NEW_VMNAME # # # OLD_VMNAME G' NEW_VMNAME-000003.vmdk
...
Sed -i 'S NEW_VMNAME # # # OLD_VMNAME G' NEW_VMNAME-00000N.vmdk


six, modify the snapshot profile
VMNAME.vmsd summary information to all snapshots, record snapshot directory structure, as follows:

VMNAME-SnapshotN.vmsn details for each snapshot (N represents the number of snapshots).

6.1 vmsd modify the configuration file
sed -i 's # OLD_VMNAME # NEW_VMNAME # g' NEW_VMNAME.vmsd

6.2 修改.vmsn配置文件
sed -i 's#OLD_VMNAME#NEW_VMNAME#g' NEW_VMNAME-Snapshot1.vmsn
sed -i 's#OLD_VMNAME#NEW_VMNAME#g' NEW_VMNAME-Snapshot3.vmsn
...
sed -i 's#OLD_VMNAME#NEW_VMNAME#g' NEW_VMNAME-SnapshotN.vmsn


Note: For step above the virtual machine has snapshots in the environment of operation VSPHERE6.5, when switching tasks in the snapshot prompt "can not access the file snapshot", view the log (/storage/log/vmware/vpxd/vpxd.log) News the following errors:
----------------------------------------------- -------------------------------------------------- -------------------------------------------------- -
VpxLRO] - ERROR Task-10169 - VM-439 - vim.VirtualMachine.revertToCurrentSnapshot: vim.fault.CannotAccessFile:
-> the Result:
-> (vim.fault.CannotAccessFile) {
-> = faultCause (vmodl.MethodFault) null,
-> faultMessage = (vmodl.LocalizableMessage) [
-> (vmodl.LocalizableMessage) {
-> Key = "msg.snapshot.vigor.revert.error",
-> Arg = ( vmodl.KeyAnyValue) [
-> (vmodl.KeyAnyValue) {
-> Key = ". 1",
-> value = "msg.snapshot.error-DUMPER"
--> }
--> ],
--> message = "An error occurred while reverting to a snapshot: Unable to open the snapshot file."
--> }
--> ],
--> file = "snapshot"
--> msg = "Unable to access file snapshot"
-------------------------------------------------------------------------------------------------------------------------------------------------------

Because xxx-SnapshotX.vmsn file some are garbled, what is not clear, distortion and speculation about the contents.

Solution:
1. Create a new snapshot;
2. Replace the original snapshot files (cp new.vmsn old.vmsn) using the new snapshot file (.vmsn); (to replace the need to record scsi0: 0.fileName information)
3. after the replacement is completed, the snapshot point modified parent disk;
as scsi0: 0.fileName = "VMNAME-00000X.vmdk"


Process under way to restore the snapshot:
1. When restore a snapshot, vmware will first read the snapshot profile (VMNAME-SnapshotN.vmsn) in scsi0: 0.fileName (disk1)
2. VMware will modify the virtual machine configuration file (VMNAME.vmx), generates a new disk disk2, disk name VMNAME-00000N.vmdk, and modify the corresponding configuration (scsi0: 0.fileName = "VMNAME- 00000N.vmdk")

disk2 the parent disk is disk1 (can be viewed by disk2 disk description file), the new data will fall on disk2.

Guess you like

Origin www.cnblogs.com/skyshao/p/11389018.html