Vmware: Difference between revisions

From miki
Jump to navigation Jump to search
 
(26 intermediate revisions by the same user not shown)
Line 1: Line 1:
See also: [[VirtualBox]] — [[Vmware]] — [[Kvm]] — [[Qemu]]

== Install ==

=== Linux guests ===

After install, you must install:
* Either VMWare tools, which comes as an ISO file downloaded on request by VMWare.
* Or, which is recommended, install open-source package {{deb|open-vm-tools}} (and package {{deb|open-vm-tools-desktop}} for GUI environment):
<source lang=bash>
sudo apt install open-vm-tools
sudo apt install open-vm-tools-desktop # If using Xfce, Gnome...
</source>

=== Compile modules vmmon / vmnet on recent kernels (and secure boot) ===

;Compile
* Compile the modules for the selected version of vmware and kernel
* Clone from https://github.com/mkubecek/vmware-host-modules.git.
<source lang="bash">
mkdir -p ~/build
cd ~/build
git clone https://github.com/mkubecek/vmware-host-modules.git
cd vmware-host-modules
# Eg. for VMWare 16.2.1 and Kernel 5.16
# Note: BETTER to checkout the branch instead. Eg. on linux 6.1, w16.2.5, we check out origin/workstation-16.2.5
git checkout origin/workstation-16.2.5
make
sudo make install
</source>

;Sign the module (when secure boot is enabled / alternatively disable secure boot)
* Loading the modules may fail if secure boot is enabled
<source lang="bash">
sudo modprobe vmmon
# modprobe: ERROR: could not insert 'vmmon': Operation not permitted
</source>
* Instruction from https://kb.vmware.com/s/article/2146460
* Create a key, sign the modules, and enroll the key
<source lang="bash">
sudo su -
mkdir -p ~/build/mok
cd ~/build/mok
# Generate a signing key
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VMware/"
# Sign the modules (this will change the module binaries!, ie. /lib/modules/5.16.0-6-amd64/misc/vmmon.ko)
/usr/src/linux-headers-`uname -r`/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vmmon)
/usr/src/linux-headers-`uname -r`/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vmnet)
# Import the public key to the system's MOK list by running this command
mokutil --import MOK.der
# Confirm a password for this MOK enrollment request.
# Reboot your machine. Follow the instructions to complete the enrollment from the UEFI console.
</source>

== Tips ==
== Tips ==

=== Enable copy-paste in Linux GUI guests ===
Install package {{deb|open-vm-tools-desktop}} to enable copy-paste in Xfce / Gnome:

<source lang=bash>
sudo apt install open-vm-tools-desktop # If using Xfce, Gnome...
</source>


=== Mount shared folders ===
=== Mount shared folders ===
Line 28: Line 89:
;Notes
;Notes
* VMWare mounts the share automatically when it is created and '''the VM is running'''. If the VM was off, first '''power on the VM, then disable and enable back the shared folders.''' However this has to be done everytime the VM is rebooted.
* VMWare mounts the share automatically when it is created and '''the VM is running'''. If the VM was off, first '''power on the VM, then disable and enable back the shared folders.''' However this has to be done everytime the VM is rebooted.
* Don't forget to '''exclude shared folders from locate / mlocate scan'''.


=== Enable 3D acceleration (<code>No 3D support is available from the host</code> / <code>Hardware graphics acceleration is not available</code>)===
=== Compile modules vmmon / vmnet on recent kernels ===
See https://github.com/mkubecek/vmware-host-modules.git.

=== Enable 3D acceleration (<code>No 3D support is available from the host</code>)===
Add to {{file|~/.vmware/preferences}} [https://askubuntu.com/questions/537787/enable-3d-hw-acceleration-on-vmware-workstation-10-on-ubuntu-14-04]:
Add to {{file|~/.vmware/preferences}} [https://askubuntu.com/questions/537787/enable-3d-hw-acceleration-on-vmware-workstation-10-on-ubuntu-14-04]:
mks.gl.allowBlacklistedDrivers = "TRUE"
mks.gl.allowBlacklistedDrivers = "TRUE"


== Hide Menu Bar in Guest ==
=== Hide Menu Bar in Guest ===
Edit {{file|.vmware/preferences}} [https://superuser.com/questions/246644/can-i-completely-hide-toolbar-in-vmware-workstation]:
Edit {{file|.vmware/preferences}} [https://superuser.com/questions/246644/can-i-completely-hide-toolbar-in-vmware-workstation]:


pref.vmplayer.fullscreen.nobar = "TRUE"
pref.vmplayer.fullscreen.nobar = "TRUE"

=== Exclude shared folders from mlocate scan ===
Assuming the shared folders are mounted on {{file|/mnt/hgfs}}, edit {{file|/etc/updatedb.conf}} and add <code>/mnt/hgfs</code> to pruned dir list:
<source lang="diff">
-PRUNEPATHS="/tmp /var/spool /media /var/lib/os-prober /var/lib/ceph"
+PRUNEPATHS="/tmp /var/spool /media /var/lib/os-prober /var/lib/ceph /mnt/hgfs"
</source>

=== Enable network promiscuous mode on Debian ===
Create file {{file|/etc/systemd/system/vmware-promiscuous.service}}:
<source lang="bash">
[Unit]
Description=Enable vmware promiscuous mode
After=vmware.service

[Service]
Type=oneshot
ExecStart=/bin/bash -c "chgrp vmnet /dev/vmnet0; chmod g+rw /dev/vmnet0"
ExecStop=/bin/bash -c "chgrp root /dev/vmnet0; chmod g-rw /dev/vmnet0"
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
</source>

Then enable and start it:
<source lang="bash">
sudo systemctl enable vmware-promiscuous.service
sudo systemctl start vmware-promiscuous.service
</source>

Note:
* <code>vmware.service</code> is a generated service, generated by <code>systemd-sysv-generator</code> from {{file|/etc/init.d/vmware}}. Unit file is found in {{file|/run/systemd/generator.late/vmware.service}}.

=== Enable symbolic links in Shared Folders on Windows Guest ===
Solution from [https://kb.vmware.com/s/article/1007277 VMWare KB].

Assume the following entries in the VMX file:
<source lang="text">
sharedFolder0.hostPath = "/users/test"
sharedFolder0.guestName = "share"
sharedFolder0.expiration = "never"
</source>

To enable symlinks, add:

<source lang="text">
sharedFolder0.followSymlinks = "TRUE"
</source>

=== Disable clipboard integration in VMWare Player ===
Add to {{file|.vmx}} file (VM powered off):
isolation.tools.copy.disable = "true"
isolation.tools.paste.disable = "true"

=== Flickering / stuttering mouse in remote desktop connection (RDP) ===
* Symptom: When using a Windows RDP, the mouse pointer in a virtual machine flickers / stutters / moves back and forth on screen.
* See https://communities.vmware.com/t5/VMware-Workstation-Pro/VMware-Workstation-15-1-mouse-issue-with-RDP-and-Windows-10-1903/td-p/2227175/page/2
* This seems related to Win 10, 1903 or 1909 update, and using WDDM instead of XDDM.
* Fix: In remote host system (the controlled system), change the policy of the host:
GPEDIT.msc
Local Computer Policy
Computer Configuration
Administrative Templates
Windows Components
Remote Desktop Service
Remote Desktop Session Host
Remote Session Environment
Use WDDM graphics display driver for Remote Desktop Connections to DISABLED

=== Bluescreen when starting VMWare Player in Windows 10 ===
* The issue is likely due to a too old VMWare Player (15.5 or older). [https://communities.vmware.com/t5/VMware-Workstation-Pro/Win10-pro-will-get-BSOD-everytime-when-I-start-any-VM-virtural/td-p/2853108]
* Try VMWare Player 15.5.7 or later.

=== Keyboard not working after VMWare Converter (Win10) ===
* This is due to a conflicting registry setting [https://communities.vmware.com/t5/VMware-Workstation-Pro/Win10-pro-will-get-BSOD-everytime-when-I-start-any-VM-virtural/td-p/2853108]
* Go to <code>SYSTEM\CurrentControlSet\Control\Class\{4D36E96B-E325-11CE-BFC1-08002BE10318}</code>, and in REG_MULTI_SZ value <code>UpperFilters</code>, make sure it only contains <code>kbdclass</code>.
* Go to <code>SYSTEM\CurrentControlSet\Control\Class\{4D36E96F-E325-11CE-BFC1-08002BE10318}</code>, and in REG_MULTI_SZ value <code>UpperFilters</code>, make sure it only contains <code>mouclass</code>.

Note that this can be done by attaching the guest VM disk to another working Win10 VM.
* Add the disk.
* Launch {{file|regedt32}}.
* Select <code>LOCAL_MACHINE</code>
* In Menu, select '''load hive'''.
* Mount {{file|/Windows/System32/config/SYSTEM}}.

=== Refreshing VM hardware while keeping VM identifiers ===
Sometimes we want to create a new fresh VM, keeping only the hard disk content.
When doing so, we must keep some of the old VM identifiers to make sure the new VM will boot.

At least keeping the following identifiers is enough (from {{file|*.vmx}} files):
<source lang="text">
uuid.bios = "xx xx xx xx xx xx xx xx-xx xx xx xx xx xx xx xx"
uuid.location = "xx xx xx xx xx xx xx xx-xx xx xx xx xx xx xx xx"
scsi0.sasWWID = "xx xx xx xx xx xx xx xx"
csi0:0.redo = ""
scsi0.pciSlotNumber = "xxx"
ethernet0.generatedAddress = "xx:xx:xx:xx:xx:xx"
ethernet0.generatedAddressOffset = "0"
</source>

=== Upgrade virtual HW ===
See https://kb.vmware.com/s/article/1003746.

=== Prevent VM freeze due to kcompactd0 ===
{{note|Not sure this works yet though.}}

Add to {{file|*.vmx}} file (EDIT FILE WHEN VM IS OFF, or changes will be lost):

# Fix problem where vmware battles with kcompactd0
vm.compaction_proactiveness=0

Also, the following may help as well:

<source lang="bash">
echo never > /sys/kernel/mm/transparent_hugepage/defrag # was 'madvise'
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag # was '1'
echo never > /sys/kernel/mm/transparent_hugepage/enabled # was 'always'
</source>

The above doesn't work well. Other potential solutions:
* Decrease 3D graphics memory (eg. 256MB).
* Use '''Reserved Memory''' and don't let it be swapped (requires '''VMWare Workstation''').

=== Hide toolbar (Workstation) ===
* Go to Edit &rarr; preferences &rarr; Display:
:* Uncheck ''Combine tabls with toolbar in full screen''.
:* Uncheck ''Show toolbar edge when unpinned in full screen''.

=== Temporarily disable all vmware modules / services ===
* Remove modules from modules folder (black listing doesn't work because they are not loaded at boot):
<source lang="bash">
sudo su -
mv /lib/modules/$(uname -r)/misc/{vmnet,vmmon}. ko ~/
</source>
* Disable vmware services:
<source lang="bash">
systemctl disable vmware.service
systemctl disable vmware-promiscuous.service
systemctl disable vmware-USBArbitrator.service # Check /etc/rcX.d to make sure nothing's left
</source>

Do the opposite operations to restore vmware.

* For modules, must run <code>depmod</code> first:
<source lang="bash">
sudo su -
mv ~/{vmnet,vmmon}.ko /lib/modules/$(uname -r)/misc/
depmod
modprobe vmnet vmmon
</source>

=== Mount a VMDK ===
From [https://stackoverflow.com/questions/22327728/mounting-vmdk-disk-image SO]:

<source lang="bash">
# sudo apt install libguestfs-tools
LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest
</source>

Latest revision as of 14:02, 15 April 2024

See also: VirtualBoxVmwareKvmQemu

Install

Linux guests

After install, you must install:

  • Either VMWare tools, which comes as an ISO file downloaded on request by VMWare.
  • Or, which is recommended, install open-source package open-vm-tools (and package open-vm-tools-desktop for GUI environment):
sudo apt install open-vm-tools
sudo apt install open-vm-tools-desktop   # If using Xfce, Gnome...

Compile modules vmmon / vmnet on recent kernels (and secure boot)

Compile
mkdir -p ~/build
cd ~/build
git clone https://github.com/mkubecek/vmware-host-modules.git
cd vmware-host-modules
# Eg. for VMWare 16.2.1 and Kernel 5.16
# Note: BETTER to checkout the branch instead. Eg. on linux 6.1, w16.2.5, we check out origin/workstation-16.2.5
git checkout origin/workstation-16.2.5
make
sudo make install
Sign the module (when secure boot is enabled / alternatively disable secure boot)
  • Loading the modules may fail if secure boot is enabled
sudo modprobe vmmon
# modprobe: ERROR: could not insert 'vmmon': Operation not permitted
sudo su -
mkdir -p ~/build/mok
cd ~/build/mok
# Generate a signing key
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VMware/"
# Sign the modules (this will change the module binaries!, ie. /lib/modules/5.16.0-6-amd64/misc/vmmon.ko)
/usr/src/linux-headers-`uname -r`/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vmmon)
/usr/src/linux-headers-`uname -r`/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vmnet)
# Import the public key to the system's MOK list by running this command
mokutil --import MOK.der
# Confirm a password for this MOK enrollment request.
# Reboot your machine. Follow the instructions to complete the enrollment from the UEFI console.

Tips

Enable copy-paste in Linux GUI guests

Install package open-vm-tools-desktop to enable copy-paste in Xfce / Gnome:

sudo apt install open-vm-tools-desktop   # If using Xfce, Gnome...

Mount shared folders

  • First, install VM tools, or on Linux guest, install package open-vm-tools.
sudo apt install open-vm-tools
  • Then create a shared folder in the VM settings.

To mount the shared folders in the guest [1]:

sudo vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other -o uid=0

For mount this at started, add to /etc/fstab:

# Use shared folders between VMWare guest and host
.host:/    /mnt/hgfs/    fuse.vmhgfs-fuse    defaults,allow_other,uid=0     0    0

Some say the share has an impact on the VM performance. In that case, use option noauto:

# Use shared folders between VMWare guest and host
.host:/    /mnt/hgfs/    fuse.vmhgfs-fuse    defaults,allow_other,uid=0,noauto     0    0

Then mount the share manually with sudo mount /mnt/hgfs.

Notes
  • VMWare mounts the share automatically when it is created and the VM is running. If the VM was off, first power on the VM, then disable and enable back the shared folders. However this has to be done everytime the VM is rebooted.
  • Don't forget to exclude shared folders from locate / mlocate scan.

Enable 3D acceleration (No 3D support is available from the host / Hardware graphics acceleration is not available)

Add to ~/.vmware/preferences [2]:

mks.gl.allowBlacklistedDrivers = "TRUE"

Hide Menu Bar in Guest

Edit .vmware/preferences [3]:

pref.vmplayer.fullscreen.nobar = "TRUE"

Exclude shared folders from mlocate scan

Assuming the shared folders are mounted on /mnt/hgfs, edit /etc/updatedb.conf and add /mnt/hgfs to pruned dir list:

-PRUNEPATHS="/tmp /var/spool /media /var/lib/os-prober /var/lib/ceph"
+PRUNEPATHS="/tmp /var/spool /media /var/lib/os-prober /var/lib/ceph /mnt/hgfs"

Enable network promiscuous mode on Debian

Create file /etc/systemd/system/vmware-promiscuous.service:

[Unit]
Description=Enable vmware promiscuous mode
After=vmware.service

[Service]
Type=oneshot
ExecStart=/bin/bash -c "chgrp vmnet /dev/vmnet0; chmod g+rw /dev/vmnet0"
ExecStop=/bin/bash -c "chgrp root /dev/vmnet0; chmod g-rw /dev/vmnet0"
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Then enable and start it:

sudo systemctl enable vmware-promiscuous.service
sudo systemctl start vmware-promiscuous.service

Note:

  • vmware.service is a generated service, generated by systemd-sysv-generator from /etc/init.d/vmware. Unit file is found in /run/systemd/generator.late/vmware.service.

Enable symbolic links in Shared Folders on Windows Guest

Solution from VMWare KB.

Assume the following entries in the VMX file:

sharedFolder0.hostPath = "/users/test"
sharedFolder0.guestName = "share"
sharedFolder0.expiration = "never"

To enable symlinks, add:

sharedFolder0.followSymlinks = "TRUE"

Disable clipboard integration in VMWare Player

Add to .vmx file (VM powered off):

isolation.tools.copy.disable = "true"
isolation.tools.paste.disable = "true"

Flickering / stuttering mouse in remote desktop connection (RDP)

GPEDIT.msc
Local Computer Policy
Computer Configuration
  Administrative Templates
   Windows Components
    Remote Desktop Service
     Remote Desktop Session Host
       Remote Session Environment
        Use WDDM graphics display driver for Remote Desktop Connections  to DISABLED

Bluescreen when starting VMWare Player in Windows 10

  • The issue is likely due to a too old VMWare Player (15.5 or older). [4]
  • Try VMWare Player 15.5.7 or later.

Keyboard not working after VMWare Converter (Win10)

  • This is due to a conflicting registry setting [5]
  • Go to SYSTEM\CurrentControlSet\Control\Class\{4D36E96B-E325-11CE-BFC1-08002BE10318}, and in REG_MULTI_SZ value UpperFilters, make sure it only contains kbdclass.
  • Go to SYSTEM\CurrentControlSet\Control\Class\{4D36E96F-E325-11CE-BFC1-08002BE10318}, and in REG_MULTI_SZ value UpperFilters, make sure it only contains mouclass.

Note that this can be done by attaching the guest VM disk to another working Win10 VM.

  • Add the disk.
  • Launch regedt32.
  • Select LOCAL_MACHINE
  • In Menu, select load hive.
  • Mount /Windows/System32/config/SYSTEM.

Refreshing VM hardware while keeping VM identifiers

Sometimes we want to create a new fresh VM, keeping only the hard disk content. When doing so, we must keep some of the old VM identifiers to make sure the new VM will boot.

At least keeping the following identifiers is enough (from *.vmx files):

uuid.bios = "xx xx xx xx xx xx xx xx-xx xx xx xx xx xx xx xx"
uuid.location = "xx xx xx xx xx xx xx xx-xx xx xx xx xx xx xx xx"
scsi0.sasWWID = "xx xx xx xx xx xx xx xx"
csi0:0.redo = ""
scsi0.pciSlotNumber = "xxx"
ethernet0.generatedAddress = "xx:xx:xx:xx:xx:xx"
ethernet0.generatedAddressOffset = "0"

Upgrade virtual HW

See https://kb.vmware.com/s/article/1003746.

Prevent VM freeze due to kcompactd0

 ✐  Not sure this works yet though.

Add to *.vmx file (EDIT FILE WHEN VM IS OFF, or changes will be lost):

# Fix problem where vmware battles with kcompactd0
vm.compaction_proactiveness=0

Also, the following may help as well:

echo never > /sys/kernel/mm/transparent_hugepage/defrag        # was 'madvise'
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag # was '1'
echo never > /sys/kernel/mm/transparent_hugepage/enabled       # was 'always'

The above doesn't work well. Other potential solutions:

  • Decrease 3D graphics memory (eg. 256MB).
  • Use Reserved Memory and don't let it be swapped (requires VMWare Workstation).

Hide toolbar (Workstation)

  • Go to Edit → preferences → Display:
  • Uncheck Combine tabls with toolbar in full screen.
  • Uncheck Show toolbar edge when unpinned in full screen.

Temporarily disable all vmware modules / services

  • Remove modules from modules folder (black listing doesn't work because they are not loaded at boot):
sudo su -
mv /lib/modules/$(uname -r)/misc/{vmnet,vmmon}. ko ~/
  • Disable vmware services:
systemctl disable vmware.service
systemctl disable vmware-promiscuous.service
systemctl disable vmware-USBArbitrator.service # Check /etc/rcX.d to make sure nothing's left

Do the opposite operations to restore vmware.

  • For modules, must run depmod first:
sudo su -
mv ~/{vmnet,vmmon}.ko /lib/modules/$(uname -r)/misc/
depmod
modprobe vmnet vmmon

Mount a VMDK

From SO:

# sudo apt install libguestfs-tools
LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest