Showing posts with label VMware. Show all posts
Showing posts with label VMware. Show all posts

Friday, July 8, 2022

VMware Fusion - How to power off suspeneded Virtual Machine

 Today I upgraded VMware Fusion and a suspended Virtual Machine would not start.  The recommendation was to change some CPU advanced settings and restart, however, my VM was in a Suspended state and would not start and would not power down in a typical way.

I found this little trick to power down the VM. 

If your VM has been suspended and you can't make the above changes, then you can go to the menu 

-> Virtual Machines -> Hold down the Option (Windows users -> Alt) key and choose "Power Off".

After that, you should be able to make the changes so you can boot your VM again.

NOTE: When I first brought up the menu, "Power Off" was greyed out but sure enough, when you hold the option key (OSX) you are able to select it.  


Wednesday, November 17, 2010

VMWare 2.0.2 Install on Debian Squeeze

These instructions are vital in order to get a working copy of VMWare on Debian Squeeze.  This information was originally available at http//:wiki.debian.org/VMware.  Please check there first for any further updates or information.  The document listed below is for my reference and in the event the wiki is unavailable. 

Installing VMware Server 2 on Squeeze


In general the installation is similiar to that in Lenny, with the following differences:
  • There are different versions of the linux kernel and gcc.
  • Different patches are required for the installer and the modules.
Instructions:
  1. Get the VMWare Server archive (at least version 2.0.2) and your license. Hopefully the issues will be fixed in later versions.
  2. Install the prerequisites (including kernel-headers for your version, and gcc version 4.3).
  3. Unzip the VMWare archive, install VMWare, but do not configure it yet, i. e. answer the question to run "vmware-config.pl" with "no".
  4. Patch vmware-config.pl using a file from the patch archive (choose the directory where you installed the binaries, if not "/usr/bin").
cd /usr/bin
patch -p3 < vmware-config.patch

  1. Patch the module sources using another file from the patch archive (choose the directory where you installed the libraries, if not "/usr/lib").
cd /usr/lib/vmware/modules/source
for i in *.tar ; do tar xpf $i ; done
patch -p4 < vmware-server-2.0.2-203138-update.patch
for i in vmci vmmon vmnet vsock ; do tar cpf $i.tar $i-only ; done

  1. Now run vmware-config.pl.
After that the installation is complete, but a bug related to Tomcat/Java may prevent the web admin interface at http://localhost:8222 from being operational. If you get the message "Error 503: Service unavailable", then continue patching.
[Note: If you want to learn more about this issue, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572048. As Java is embedded in VMWare, switching to a current version is no option, neither should be disabling IPv6.]
  1. IPv6 must be disabled for the "WebAccess" service only. Create a patch file named "vmware.patch" (see the "Lenny" section for how to do this using an editor):
--- vmware.orig 2010-05-24 17:05:09.251864323 +0200
+++ vmware      2010-05-24 21:40:37.563871986 +0200
@@ -675,7 +675,7 @@
 watchdog="${vmdb_answer_BINDIR}/vmware-watchdog"
 webAccessServiceName="VMware Virtual Infrastructure Web Access"
 CATALINA_HOME="${vmdb_answer_LIBDIR}/webAccess/tomcat/apache-tomcat-6.0.16"
-webAccessOpts="-client -Xmx64m -XX:MinHeapFreeRatio=30 -XX:MaxHeapFreeRatio=30 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=$CATALINA_HOME/common/endorsed -classpath $CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/commons-logging-api.jar -Dcatalina.base=$CATALINA_HOME -Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$CATALINA_HOME/temp org.apache.catalina.startup.Bootstrap"
+webAccessOpts="-Djava.net.preferIPv4Stack=true -client -Xmx64m -XX:MinHeapFreeRatio=30 -XX:MaxHeapFreeRatio=30 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=$CATALINA_HOME/common/endorsed -classpath $CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/commons-logging-api.jar -Dcatalina.base=$CATALINA_HOME -Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$CATALINA_HOME/temp org.apache.catalina.startup.Bootstrap"
 
 #
 # Utilities

  1. Patch /etc/init.d/vmware, and restart the daemon.
cd /etc/init.d
patch < vmware.patch
./vmware-mgmt restart 
Done.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013 - Squeeze Update
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After running VMware install but BEFORE the configuration....


3. Patching vmware-server-2.0.2

At this point we need to patch vmware-config.pl file as well as vmware modules. First download and decompress patch provided by: Radu Cotescu:
# cd
# wget http://linuxconfig.org/images/files/2.6.3x-vmware-patch.tar.bz2
# tar xjf 2.6.3x-vmware-patch.tar.bz2
Apply patch:
First apply patch to vmware-config:
# cd /usr/bin/
# patch -p3 < ~/2.6.3x-vmware-patch/config.patch
203138-update.patch
config.patch
LICENSE
README
start-VMware-console.sh
vmware-server-2.0.x-kernel-2.6.3x-install.sh
Apply patch to all modules:
# cd /usr/lib/vmware/modules/source
# for f in *.tar ; do tar pxf $f ; done
# patch -p4 < ~/2.6.3x-vmware-patch/203138-update.patch
patching file vmci-only/include/pgtbl.h
patching file vmnet-only/vnetUserListener.c
patching file vmci-only/Makefile
patching file vmmon-only/common/vmx86.c
patching file vmmon-only/include/compat_cred.h
patching file vmmon-only/include/x86svm.h
patching file vmmon-only/linux/driver.c
patching file vmmon-only/linux/hostif.c
patching file vmmon-only/Makefile
patching file vmnet-only/Makefile
patching file vmnet-only/netif.c
patching file vsock-only/Makefile
# for f in vmci vmmon vmnet vsock ; do tar pcf $f.tar $f-only ; done
# rm -fr *-only

4. Set correct gcc version

The kernel on Debian squeeze was compiled with gcc 4.3 and this is the version of gcc we want to use. By default gcc is set to gcc version 4.4:
# ls -l `which gcc`
lrwxrwxrwx 1 root root 7 Mar 20 11:15 /usr/bin/gcc -> gcc-4.4 
Therefore, we need to change gcc compiler to match our kernel compiler version. The easiest way is to set CC environmental variable to point to gcc v4.3.
The second option is to create a new symlink ( when you finish do not forget to put everything where it belongs ) :
# ln -fs /usr/bin/gcc-4.3 /usr/bin/gcc
# ls -l `which gcc`
lrwxrwxrwx 1 root root 16 Mar 20 12:09 /usr/bin/gcc -> /usr/bin/gcc-4.3

5. Configure vmware-server-2.0.2

We are almost done. At this stage we need to configure vmware-server. Follow vmware-config.pl and change default values where appropriate. Start configuration with:
# vmware-config.pl
After successful build you should see:
Enjoy,

--the VMware team

Starting VMware services:
   Virtual machine monitor                                             done
   Virtual machine communication interface                             done
   VM communication interface socket family:                           done
   Virtual ethernet                                                    done
   Bridged networking on /dev/vmnet0                                   done
   Host-only networking on /dev/vmnet1 (background)                    done
   DHCP server on /dev/vmnet1                                          done
   Host-only networking on /dev/vmnet8 (background)                    done
   DHCP server on /dev/vmnet8                                          done
   NAT service on /dev/vmnet8                                          done
   VMware Server Authentication Daemon (background)                    done
   Shared Memory Available                                             done
Starting VMware management services:
   VMware Server Host Agent (background)                               done
   VMware Virtual Infrastructure Web Access
Starting VMware autostart virtual machines:
   Virtual machines                                                    done

The configuration of VMware Server 2.0.2 build-203138 for Linux for this 
running kernel completed successfully.



Thursday, July 22, 2010

Steps to remember when copying a Virtual Machine

I recently copied a VM to reuse and encountered a networking issue.  Part of the process of editing the .vmx file prior to starting the VM should include changing the MAC address of the Network Card.

Simply adjust the .vmx file with the necessary changes ie "nvram, and displayName" along with adding the example below to the end of the file.

Example (to avoid an ipv6 address conflict):

ethernet0.address = "00:50:56:00:00:01"

VMware Server 2.0 - Tuning

I made the following enhancements in an attempt to improve my VMware performance on a Debian 2.6.26-1-686-bigmem. 

Edit VMware configuration file and add the following:

vi /etc/vmware/config

mainMem.useNamedFile tells VMWare where to put it's temporary workspace file. This file contains the content of the Virtual Machine memory which is not used. By default it is placed in the directory with the virtual machine, however that can seriously impact performance so we'll turn it off.
mainMem.useNamedFile = FALSE

tmpDirectory is the default path for any temp files. We need to change that to be a shared memory filesystem (in RAM).
tmpDirectory="/dev/shm"

prefvmx.useRecommendedLockedMemSize and prefvmx.minVmMemPct tell VMWare to either use a fixed sized memory chunk or balloon and shrink memory as needed. With 4GB of memory we'll use a fixed size of memory to reduce disk IO.

prefvmx.useRecommendedLockedMemSize="TRUE"
prefvmx.minVmMemPct="100"


Be sure to install VMware tools followed by:

Set the time in the Virtual Machine to the hosts time.

tools.syncTime = "TRUE"

Force gracefully stop on each VM.

autostop = "softpoweroff"

I don't care about collapsing memory into a shared pool, this tells the VM to not share which saves CPU cycles:

mem.ShareScanTotal=0
mem.ShareScanVM=0
mem.ShareScanThreshold=4096
sched.mem.maxmemctl=0
sched.mem.pshare.enable = "FALSE"


This basically performs the same action as the configuration I put in /etc/vmware/config by telling the VM to eliminate the temp files and not to balooning and shrink memory, however it doesn't hurt anything to have it in both locations:

mainMem.useNamedFile = "FALSE"
MemTrimRate = "0"
MemAllowAutoScaleDown = "FALSE"


In order for the VMWare configuration to work properly with shared memory, you'll need to increase the default shared memory size for tmpfs to match the amount of memory in your system. This can be done by editing /etc/default/tmpfs:

SHM_SIZE=4096

Monday, June 21, 2010

VMware Command Line Tools

To start a VM from the command line, issue the following command:

vmrun -T server -h 'https://nameofserver.com:8333' -u root -p 'password here' start "[DataStoreNameHere] Debian/Debian_Lenny.vmx"


I had trouble determining the "DataStore" name and found it listed in one of the Vmware files.  The default seems to be "standard".

Thursday, March 25, 2010

Convert FUSION Virtual Machine to VMWare Server

While moving Virtual Machines created on my Mac using FUSION to a Linux VMware Server environment, I found that it was necessary to remove the following line from the MyVirtualMachineName.vmx file.

serial0.fileType = "thinprint"

After doing so, I was then able to successfully add my Virtual Machines to the "Inventory" of the Linux VMware server.

Sunday, October 4, 2009

VMware - Convert between growable and preallocated (*.vmdk)

A VMDK file can be converted into another formate while no VM is using it. The operation will copy the old disk into a new one.

vmware-vdiskmanager -r <source-disk> -t <type> <target-disk>

Disk type can be one of:

0                 : single growable virtual disk
1                 : growable virtual disk split in 2Gb files
2                 : preallocated virtual disk
3                 : preallocated virtual disk split in 2Gb files

VMware - Grow an existing virtual disk (*.vmdk)

A VMDK file can be grown while no virtual machine is using it. Growng the VMDK only makes the virtual harddrive bigger - filesystem within the VMDK must still be grown with other methods (for instance on Windows, diskpart).

On ESX:
vmkfstools -X <newsize>G filename.vmdk

On ESX 3.5, you can also edit the VM settings and edit the harddrive when the VM is not running.

Note that on ESX the filename.vmdk file is just a  file containing metainformation and "filename-flat.vmdk" is the actual data file. However, vmkfstools operations are used on the metafile

On VMware Server Workstation and VMware Fusion:

vmware-vdiskmanager -x Gb filename.vmdk

For instance, if growing an existing vmdk file named "server1.vmdk" and it is to be grown so it's new size is 20GB, the command would be:

On ESX:

vmkfstools -X 20GB server1.vmdk

On Server/Workstation/Fusion

vmware-vdiskmanager -x 20Gb server1.vmdk

On Fusion vmware-vdiskmanager is located by default at /Library/Application Support/VMware Fusion/vmware-vdiskmanager

VMware Performance Tuning - Linux Guest

Linux guests' performance may be improved if they have been created without much thought.
  • Always use a single VCPU when the CPU capacity requirement of the VM allows it.
  • Install VMware Tools and keep it updated.
  • Add the options "nosmp noapic nolapic clock=pit" to the guest's kernel (2.6) parameters. Don't add "nosmp" if using more than one VCPU.Note clock=pit is depracted since kernel 2.6.16. Use clocksource=pit instead if your kernel is newer than that.
  • On RHEL 5.1 (and variants such as CentOS 5.1) add the option divider=10 to the kernel boot parameters. This causes the default clock tick rate, 1000HZ to be divided by 10, so HZ=100. On other distros, try using a kernel with Hz=100. Most 2.6 desktop distros are using HZ=1000, while the server distros tend to use HZ=100 or HZ=250.

VMware Performance Tuning

While in search of tuning information for VMware, I came across much of the following information and have found it to be extremely beneficial.

Windows Configuration

Windows VM:
1024MB Ram 10GB SCSI disk, 1 Ethernet device, USB

It's recommended by VMWare that Windows VMs be configured to use IDE, however in my reading,  the Virtual IDE devices use tons more CPU time than the SCSI device. This is due to the emulation level done and lack of I/O threading in VMWare's IDE controller. I have to assume that this is a problem with IDE in general, as it's never been very good at multithreaded I/O (this is one big reason it's never been used for servers). Additionally,it is recommended to use the LSILogic controller. It supports multithreaded IO while the Buslogic controller doesn't.

Print Server Setup
Printing to a USB printer directly connected to the VMWare server.  Ubuntu doesn't configure USBFS out of the box. This can be corrected by editing a few files:

Add to fstab:
usbfs /proc/bus/usb usbfs auto 0 0

Edit /etc/init.d/mountdevsubfs.sh, and uncomment the following lines:

#mkdir -p /dev/bus/usb/.usbfs
#domount usbfs "" /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
#ln -s .usbfs/devices /dev/bus/usb/devices
#mount --rbind /dev/bus/usb /proc/bus/usb


This is done by removing the # from the front of each line. Once this is done, go ahead and run the script.

/etc/init.d/mountdevsubfs.sh start

In the Virtual Machine configuration, to ensure that the printer was always connected on startup, insert the following configuration into that Virtual Machine's VMX file:

usb.present = "TRUE"
usb.generic.autoconnect = "FALSE"
usb.autoConnect.device0 = "0x0000:x0000"
usb.autoConnect.device1 = "0x04e8:0x327e"
usb.generic.skipsetconfig = "TRUE"


You can get the IDs for your devices by issuing an lsusb on the VMWare Server, this command will output similar to the following:

Bus 002 Device 002: ID 04e8:327e Samsung Electronics Co., Ltd
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000


Additionally, I blacklisted usblp on the VMWare Server so the host didn't connect to the printer making it unavailable to the guest.

echo "blacklist usblp" >>/etc/modprobe.d/blacklist

Printing now "just works" after rebooting. Of course for it to "just work" you also need to configure CUPS or Windows printer shareing, but that is out of the scope of this article.

Add each of these to /etc/vmware/config:

mainMem.useNamedFile tells VMWare where to put it's temporary workspace file. This file contains the content of the Virtual Machine memory which is not used. By default it is placed in the directory with the virtual machine, however that can seriously impact performance so we'll turn it off.

mainMem.useNamedFile = FALSE

tmpDirectory is the default path for any temp files. We need to change that to be a shared memory filesystem (in RAM).

tmpDirectory="/dev/shm"

prefvmx.useRecommendedLockedMemSize and prefvmx.minVmMemPct tell VMWare to either use a fixed sized memory chunk or balloon and shrink memory as needed. Since I have 8GB of memory in this server I want to make sure that I use a fixed chunk of memory to reduce disk IO.

prefvmx.useRecommendedLockedMemSize="TRUE"
prefvmx.minVmMemPct="100"


To tune each Virtual Machine, I installed VMWare tools and then made the following changes to each VMX file:

Set the time in the Virtual Machine to the hosts time (I use NTP on the host):

tools.syncTime = "TRUE"

When I reboot the host, I want to gracefully stop each VM instead of just powering it off:

autostop = "softpoweroff"

This tells the VM to not share which saves CPU cycles:

mem.ShareScanTotal=0
mem.ShareScanVM=0
mem.ShareScanThreshold=4096
sched.mem.maxmemctl=0
sched.mem.pshare.enable = "FALSE"


This basically performs the same action as the configuration I put in /etc/vmware/config by telling the VM to eliminate the temp files and not to balooning and shrink memory, however it doesn't hurt anything to have it in both locations:

mainMem.useNamedFile = "FALSE"
MemTrimRate = "0"
MemAllowAutoScaleDown = "FALSE"


In order for the VMWare configuration to work properly with shared memory, you'll need to increase the default shared memory size for tmpfs to match the amount of memory in your system. This can be done by editing /etc/default/tmpfs:

SHM_SIZE=5G

You can use 'mount -o remount /dev/shm' and 'df -h' to implement and verify the change.

Or if needed...Create an in-memory temp drive

Configure /etc/sysctl.conf on the VMWare Server which configures the kernel to perform better as a Virtual Server by inserting the following configuration:

vm.swappiness = 0
vm.overcommit_memory = 1
vm.dirty_background_ratio = 5
vm.dirty_ratio = 10
vm.dirty_expire_centisecs = 1000
dev.rtc.max-user-freq = 1024


Lastly, I disable the tickless kernel option in kernel 2.6.26 which further reduces the Virtual Machine I/O constraints by reverting back to using ticks which is better supported by VMWare. This can be done by adding the following option to the kernel options line in /boot/grub/menu.lst or /etc/lilo.conf:

nohz=off

Example:   
kernel   /vmlinuz-2.6.26-1-686-bigmem root=/dev/sda3 ro quiet hdb=noprobe nohz=off