How to Activate nested virtualization on a VM in ESXi

I am consolidating here a couple of instructions (here and here, and here for the ESXi shell activation part) I found to activate nested virtualization on a VM in an ESXi server without access to the server vmware part. You need to:

  1. Check that the ESXi will support it (BIOS, hypervisor…). Look for nestedHVSupported in the output of https://[your-esxi-host-ip-address]/mob/?moid=ha-host&doPath=capability after authenticating.
  2. Enable the ESXi shell (you need this so that you can edit the VM definition later):
    1. Use the vSphere Client to enable local and remote access to the ESXi Shell:
    2. Log in to a vCenter Server system using the vSphere Client.
    3. Select the host in the Inventory panel.
    4. Click the Configuration tab and click Security Profile.
    5. In the Services section, click Properties.
    6. Select ESXi Shell from this list:
    7. Click Options and select Start and stop manually. Note: When you select Start and stop manually, the service does not start when you reboot the host. If you want the service to start when you reboot the host, select Start and stop with host.
    8. Click Start to enable the service.
    9. Click OK.
  3. Log in to the shell with credentials and Alt-F1
  4. Add the vhv.enable = “TRUE” at the end of the .vmx file corresponding to the VM that you want to activate the nested virtualization on…
  5. Identify the  hypervisor vm ID and reload it’s configuration with the vim-cmd esxi command:

    ~ # vim-cmd vmsvc/getallvms | grep -i ubun 44 VM6-Ubuntu-KVM [datastore1] VM6-Ubuntu-KVM/VM6-Ubuntu-KVM.vmx ubuntu64Guest vmx-08

    ~ # vim-cmd vmsvc/reload 44

  6. Check within the VM as root that it sees the “hardware virtualization” with:

    egrep -c ‘(vmx|svm)’ /proc/cpuinfo