1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Stand Alone ESXi: offline copy and register to inventory, answering "I Copied It" while first power on VM with command line.

Last updated at Posted at 2019-12-18

Stand Alone ESXi: offline copy and register to inventory, answering "I Copied It" while first power on VM with command line.

Objectives:

  • personal memo

Refs:

Target System:

  • ESXi 6.7 (stand alone free licensed)

Operation:

Get VM ID

vim-cmd vmsvc/getallvms | grep -i <VM NAME>

Power Off VM (if needed)

vim-cmd vmsvc/power.getstate <VMID>

vim-cmd vmsvc/power.shutdown <VMID>

vim-cmd vmsvc/power.getstate <VMID>

Get file path

vim-cmd vmsvc/get.summary <VMID> | grep vmPathName
vim-cmd vmsvc/get.filelayout <VMID> | less

Create Target Folder

example
mkdir /vmfs/volumes/datastore3/rancher-server01

Copy medadata and config file

example
cd /vmfs/volumes/datastore2/centos7-test01
cp -p centos7-test01.vmsd /vmfs/volumes/datastore3/rancher-server01/.
cp -p centos7-test01.vmxf /vmfs/volumes/datastore3/rancher-server01/.
cp -p centos7-test01.vmx /vmfs/volumes/datastore3/rancher-server01/.

Clone VMDK file

  • Use absolute path for each vmdk file paths.
example
vmkfstools -i /vmfs/volumes/datastore2/centos7-test01/centos7-test01.vm
dk /vmfs/volumes/datastore3/rancher-server01/centos7-test01.vmdk
output-example
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/datastore2/centos7-test01/centos7-test01.vmdk'...
Clone: 100% done.

Rename

example
cd /vmfs/volumes/datastore3/rancher-server01/
vmkfstools -E centos7-test01.vmdk rancher01.vmdk
cp centos7-test01.vmx rancher01.vmx
  • edit old name related lines
example
vi rancher01.vmx
  • if use sed
sed -i 's/<previous name>/<new name>/g' <new name>.vmx

Register VM to inventory

example
vim-cmd solo/registervm /vmfs/volumes/datastore3/rancher-server01/rancher01.vmx
  • stdout is VMID
  • if have some trouble, unregister
vim-cmd /vmsvc/unregister <VMID>

Power On VM

vim-cmd vmsvc/power.getstate <VMID>
vim-cmd vmsvc/power.on <VMID>
  • prompt is waiting ...

Answer with command line

  • start another ssh session
vim-cmd vmsvc/message <VMID>
vim-cmd vmsvc/message <VMID> <MESSAGE ID> <ANSWER ID>
example
vim-cmd vmsvc/message 8

Virtual machine message 121402125:
This virtual machine might have been moved or copied. In order to configure certain management and networking features, VMware ESX needs to know if this virtual machine was moved or copied. If you don't know, answer "I Copied It".
   0. button.uuid.cancel (Cancel)
   1. button.uuid.movedTheVM (I Moved It)
   2. button.uuid.copiedTheVM (I Copied It) [default]

vim-cmd vmsvc/message 8 121402125 2
  • power.on prompt should return now

Get IP address from vmware tools

vim-cmd vmsvc/get.summary <VMID> | grep ipAddress
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?