VmWare/QuickReference
clone
clone virtual machines and copy their own unique vmdk image to folder
- create the new VM choose custom settings
- select the existing Virtual Machine Image (base)
- finish creating
- ssh into box
- copy vmdk using: vmkfstools -i <source> <destination> -d thin (NOT the data file -flat.vmdk)
- when copy is complete, using vi, edit .vmx file in new VM directory. Point the data store (hdd file location) to the new copy that is now in the same folder
- start up VM
- shut down vm, double check and make sure store is showing in the correct location. Virtual Machine > Edit Settings > Hard Disk > review Disk File
notes: until the virtual machine is started for the first time, the Disk File location will still show as the prior location.
i.e. /vmfs/volumes/511a8041-9e4d7168-27f2-001cc46b0828/Windows XP Pro x32 - Outlook 2003_2 # vmkfstools -i /vmfs/volumes/ datastore2\ -\ RAID5/Windows\ XP\ Pro\ x32\ -\ Outlook\ 2003/Windows\ XP\ Pro\ x32\ -\ Outlook\ 2003.vmdk /vmfs/volumes /datastore2\ -\ RAID5/Windows\ XP\ Pro\ x32\ -\ Outlook\ 2003_2/Windows\ XP\ Pro\ x32\ -\ Outlook\ 2003_2.vmdk -d thin
add cronjob to esxi 5.1
- edit /etc/rc.local.d/local.sh
/bin/kill $(cat /var/run/crond.pid) /bin/echo '5 0 * * * /full/path/to/script arguments/with/full/path > /full/path/to/logfile 2>&1' >> /var/spool/cron/crontabs/root /bin/busybox crond
expand harddisk space on winxp and other non-modifiable vms
- create a new hard disk in the vm that is the desired size
- attach ubcd to the virtual cdrom and boot off disc (esc at POST)
- using hd clone tool, copy wipe, perform a sector by sector copy from the source to the dest
- remove old hard disk from virtual machine, verify you can boot off new hard disk. It will still show as smaller disk size.
- attach ubcd to the virtaul cdrom and boot off disc (esc at POST)
- using Parted Magic, use gparted and resize the disk incorporate the new free space
- reboot and verify
CentOS6.4 VM keystrokes duplicate
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=196
- Power off the virtual machine
- Right click virtual machine select Edit Settings
- Click Options > General > Configuration Parameters
- Click Add Row
- Under Name enter keyboard.typematicMinDelay In the Value field 2000000
- Click OK
- Power on the virtual machine
Enable copy/paste for a single VM
- power off vm
- vsphere > Settings > Options > Advanced > General > Configuration Parameters
- Add rows
isolation.tools.copy.disable – false isolation.tools.paste.disable – false
Done. power on VM
Windows 7 optimizing performance
https://pubs.vmware.com/view-50/index.jsp?topic=%2Fcom.vmware.view.administration.doc%2FGUID-E712DAE6-88DF-4208-BEFA-09513A01A26E.html
https://support.microsoft.com/en-us/kb/192806
- Enable Run command
- Disable un-needed windows components
- Start > run > type: optionalfeatures > Enter > select options listed below > OK
- uncheck: Tablet PC Components
- uncheck: Media Features
- uncheck: Windows Gadget Platform
- Start > run > type: optionalfeatures > Enter > select options listed below > OK
- Disable IPv6, unless it is needed.
- Start > run > type: control.exe /name Microsoft.NetworkAndSharingCenter > Enter > click: Local Area Connection > click: Properties > uncheck: Internet Protocol Version 6 (TCP/IPv6) > OK
- Use the File System Utility (fsutil) command to disable the setting that keeps track of the last time a file was accessed.
- Start > search: cmd.exe > right-click: select: run as administrator > Yes > type: fsutil behavior set disablelastaccess 1
- Change disk timeout from 30 to 190
- Start > regedit > change the TimeOutValue REG_DWORD in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Disk to 0x000000be(190).
- Change Power Options
- Start > run > type: control.exe /name Microsoft.PowerOptions > Select: High Performance > click: Change plan settings > complete settings listed below > Apply > Save Changes
- Turn off the display: Never
- Advanced: Hard Disk > Turn off hard disk after > Setting: 0 Minutes (never)
- Advanced: Display > Turn off display after > Setting: 0 Minutes (never)
- Start > run > type: control.exe /name Microsoft.PowerOptions > Select: High Performance > click: Change plan settings > complete settings listed below > Apply > Save Changes
- Change to windows basic theme
- Start > run > type: control.exe /name Microsoft.Personalization > select: Windows Classic Theme
- Adjust Visual Effects for best performance
- Start > run > type: control.exe /name Microsoft.PerformanceInformationAndTools > select: Adjust Visual Effects > Adjust for best performance > Apply > OK
- Disable un-needed services
- Start > run > services.msc > select services from list below > right click: properties > Startup Type: Disabled
- IP Helper: Stop and Disable
- Offline Files: Stop and Disable
- Start > run > services.msc > select services from list below > right click: properties > Startup Type: Disabled
- Disable un-needed startup services
- Start > run > msconfig > select services from the list below > uncheck > Apply > OK
- Fax
- Home Group Listener
- Home Group Provider
- Smart Card
- Smart Card Removal Policy
- Adaptive Brightness
- Tablet PC Input Service
- Parental Controls
- Start > run > msconfig > select services from the list below > uncheck > Apply > OK
- Disable Login Prompt for user (but retain password)
- Start > run > type: netplwiz > uncheck: Users must enter a username and password to use this computer > type Password x2 > Apply > OK
- Set fixed Page file
- Start > run > type: control.exe /name Microsoft.System > click: Advanced System Settings > select: Advanced Tab > click: Performance settings > select Advanced Tab > click: Virtual Memory change > uncheck: Automatically manage paging file > select: custom size > Set both min and max to 1.5x the size of physical memory. > Apply > OK
- Shut down the guest operating system and power off the virtual machine.
- Change the virtual machine video card RAM setting to 128 MB.
- Power on the virtual machine.
Windows 7 remove RDP restrictions - no download required
NOTE: This never worked right for me. I never tried the exe offered to perform this task and analyzed the results, maybe later on.
Requirements:
- hex editor for windows
- be directly connected to the windows client, not a remote desktop session.
Stop remote desktop services
- Start > Run > [type] services.msc > [click] OK
- Sort Services by name and find "Remote Desktop Services" > [right-click] Remote Desktop Services > [select] Stop > if any prompts appear about additional services that will also be stopped, [click] Yes
Backup termsrv.dll
- Start > in "search", type cmd > [right-click] cmd.exe & select run as administrator
- type: copy C:\windows\system32\termsrv.dll C:\windows\system32\termsrv.dll.bak
- check to see if termsrv.dll also exists in C:\windows\system32\dllcache\ and if so, repeat the same steps as above, but make sure to change the path (C:\windows\system32 > C:\windows\system32\dllcache)
Determine termsrv.dll version and obtain HEX replacements
Note: You'll need to determine the version of your termsrv.dll in order to get the HEX replacements before you can patch it.
First copy termsrv.dll to a location you can edit.
- Start > in "search", type cmd > [right-click] cmd.exe & select run as administrator
- type: copy C:\windows\system32\termsrv.dll %userprofile%
- Open HxD > File > Open > C:\Users\[your profile name] > [select] termsrv.ddl > Open
Looking at the text interpretation of the HEX, you should be able to find something like "F.i.l.e.V.e.r.s.i.o.n" followed by the version of termserv.dll.
I found mine near the bottom of the file, next to this HEX:
69 00 6C 00 65 00 56 00 65 00 72 00 29 00 01 00 46 00
My version turned out to by 6.1.7601.18637
From here you'll need to search google and blog/forum posts to see if someone has posted the HEX replacements. The search term I used to find mine was "windows 7 patch termsrv dll 6.1.7601.18637"
In the very first link, in the article comments, someone posted the HEX replacements for my version.
Patch termsrv.dll
Hopefully you were able to find the HEX replacements for your version.
Since in the previous step we copied termsrv.dll to a location we can edit, lets go ahead and update that file.
- Open HxD > File > Open > C:\Users\[your profile name] > [select] termsrv.ddl > Open
Note: your HEX replacements will probably be different than mine, but i'm including what I did for my version so you have a clear understanding on how to modify your termsrv.dll.
For Windows 7 x64 termsrv.dll 18637 64bit Find: 8b 87 38 06 00 00 39 87 3c 06 00 00 0f 84 eb c2 00 00 Repl: b8 00 01 00 00 90 89 87 38 06 00 00 90 90 90 90 90 90 Find: 60 bb 01 00 00 00 c7 44 Repl: 60 bb 00 00 00 00 c7 44 Find: 50 01 76 1b 48 8d 15 49 Repl: 50 00 eb 1b 48 8d 15 49
- With termsrv.dll open in HxD > Search > Replace > [select] Datatpe to "Hex-values" > [select] Search direction to "All" > [select] Prompt on replace.
- In the Search for field, input the original hex value you are trying to find.
- In the Replace with field, input the new hex value.
- [click]OK
Repeat this process for all Hex strings (generally 1-4)
- File > Save As > "termserv.dll.patched"
Replace termsrv.dll with patched version
- Start > in "search", type cmd > [right-click] cmd.exe & select run as administrator
- type: cd %userprofile%
- type: copy .\termsrv.dll.patched C:\windows\system32\
Regedit
- Start > run > "regedit"
- goto HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Terminal Server\Licensing Core (or HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Terminal Server\RCM\Licensing Core)
- create a new DWORD key "EnableConcurrentSessions" without quotes and enter its value as 1.
- goto HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
- create a new DWORD key "EnableConcurrentSessions" without quotes and enter its value as 1
- create another DWORD key "AllowMultipleTSSessions" without quotes and enter its value as 1 too.
Allow Users remote access
- Start > [right-click] Computer > [select] properties > [click] remote settings
- Under the Remote Tab, Remote Desktop group, [select] "Allow connections from computer running any version of Remote Desktop (less secure)"
- [click] "Select Users..."
- [click] Add > type in the user's name > [click] "Check Names" > [click] OK x2
Note: if your computer is on a domain, you'll need to create a batch file to run on startup every time the machine reboots. See this article but by mindful of the registry paths, you may have to modify the batch file to match your registry paths. Now right click on My Computer and go to Properties->Remote. Enable allow remote connections and select the users for whom you want to enable Remote Desktop Services.
Start remote desktop services
- Start > Run > [type] services.msc > [click] OK
- Sort Services by name and find "Remote Desktop Services" > [right-click] Remote Desktop Services > [select] Start
Restart
Restart your computer.
Reset Evaluation License
This should reset your evaluation license for another 60 days and provide you with access to the full features of ESXi.
Original source
Turn on SSH and log in to the host.
Remove the current license
~$ rm -r /etc/vmware/license.cfg
Copy over the new evaluation license, which is already on the host
~$ cp /etc/vmware/.#license.cfg /etc/vmware/license.cfg
Restart ESXi services
~$ /etc/init.d/vpxa restart
Confirm the new license
Remove password policy for esxi 6
This should only be used temporarily.
http://itfuzz.blogspot.com/2016/06/vmware-esxi-6-password-policy-change.html
~$ vi /etc/pam.d/passwd
Comment out the 1st and 3rd lines, delete use_authtok
#password requisite /lib/security/$ISA/pam_passwdqc.so retry=3 min=disabled,disabled,disabled password sufficient /lib/security/$ISA/pam_unix.so use_authtok nullok shadow sha512 #password required /lib/security/$ISA/pam_deny.so
Change the password
~$ passwd user1
TrueNas startup service
Overview
With TrueNas as a virtual machine, when the esxi server loads, it cannot resolve the details of virtual machines stored on TrueNas because the service is not up yet. Even if you delay these virtual machines from starting until after TrueNas is started, esxi still tries to resolve the vm details, which is not accessible, so it errors and then fails to start any of them.
This service intends to resolve that issue. located on a linux vm stored on the local host instead of truenas, when it starts, it waits until TrueNas is accessible and then tells esxi to rescan datastores. This should allow the virtual machines located on truenas to be accessible again and started.
service
script
Add the ssh password for the esxi host in a file that can only be read by root
~$ sudo touch /root/thjdtdh ~$ sudo vim /root/thjdtdh ~$ sudo chmod 400 /root/thjdtdh
Create the script to rescan datastores on the esxi host
~$ sudo touch /usr/sbin/esxistart ~$ sudo chown root:root /usr/sbin/esxistart ~$ sudo chmod 750 /usr/sbin/esxistart
~$ sudo vim /usr/sbin/esxistart #!/bin/bash nfsserver="truenas-server" esxiserver="esxi-server" esxiuser="truenas" esxipass="/root/thjdtdh" servers=($nfsserver $esxiserver) vms=(vmname01 vmname02) set -o errexit function installsshpass { if ! command -v sshpass &> /dev/null; then echo "$(date +"%b %d %H:%M:%S") $(hostname -s) esxistartup.sh: sshpass could not be found" >> /var/log/messages yum install -y sshpass fi } function testdns { for i in ${servers[@]}; do if ! $(getent hosts $i &> /dev/null); then echo "$(date +"%b %d %H:%M:%S") $(hostname -s) esxistartup.sh: DNS resolution failed for $i" >> /var/log/messages exit 1 fi done } function remountnfs { sshpass -v -f "$esxipass" ssh -o StrictHostKeyChecking=no $esxiuser@$esxiserver 'esxcfg-nas -r' &> /dev/null } function testnfs { if ! $(showmount -e $nfsserver &> /dev/null); then echo "$(date +"%b %d %H:%M:%S") $(hostname -s) esxistartup.sh: NFS not online" >> /var/log/messages sleep 5 remountnfs testnfs else echo "$(date +"%b %d %H:%M:%S") $(hostname -s) esxistartup.sh: NFS online, attempting to rescan adapters in 20 seconds" >> /var/log/messages sleep 20s fi } function rescanesxiadapters { while ! sshpass -v -f "$esxipass" ssh -o StrictHostKeyChecking=no $esxiuser@$esxiserver 'esxcli storage core adapter rescan --all' &> /dev/null do echo "$(date +"%b %d %H:%M:%S") $(hostname -s) esxistartup.sh: Rescanning adapters failed, sleeping for 5 seconds and reattempting." >> /var/log/messages sleep 5s done echo "$(date +"%b %d %H:%M:%S") $(hostname -s) esxistartup.sh: Sleeping 20 seconds while esxi adapter rescan completes." >> /var/log/messages sleep 20s } function turnonvms { for i in ${vms[@]}; do vmid=$(sshpass -f "$esxipass" ssh -o StrictHostKeyChecking=no $esxiuser@$esxiserver "vim-cmd vmsvc/getallvms | grep $i" | awk '{print$1}') vmstate=$(sshpass -f "$esxipass" ssh -o StrictHostKeyChecking=no $esxiuser@$esxiserver "vim-cmd vmsvc/power.getstate $vmid" | grep "Powered" | awk '{print $2}') if [ "$vmstate" = off ]; then echo "$(date +"%b %d %H:%M:%S") $(hostname -s) esxiVMstartup.sh: Powering on VM: $i" >> /var/log/messages sshpass -f "$esxipass" ssh -o StrictHostKeyChecking=no $esxiuser@$esxiserver "vim-cmd vmsvc/power.on $vmid" sleep 60s fi done } installsshpass testdns remountnfs testnfs rescanesxiadapters turnonvms
systemd
~$ sudo touch /etc/systemd/system/esxistart.service ~$ sudo chown root:root /etc/systemd/system/esxistart.service ~$ sudo chmod 644 /etc/systemd/system/esxistart.service
~$ sudo vim /etc/systemd/system/esxistart.service [Unit] Description=Remote ESXi startup script Daemon After=network.target auditd.service [Service] Type=forking ExecStart=/bin/sh -c "/usr/sbin/esxistart" ExecReload=/bin/kill -HUP $MAINPID KillMode=control-group Restart=no TimeoutSec=1200 [Install] WantedBy=multi-user.target
enable
~$ sudo systemctl daemon-reload ~$ sudo systemctl enable esxistart.service Created symlink from /etc/systemd/system/multi-user.target.wants/esxistart.service to /etc/systemd/system/esxistart.service.
fix broken vms
create vm shell
first step is to create the virtual machine shell. I'm doing this through the webui. no need to start the vm or attach an iso.
clone vmdk
ssh into esxi host, go to the datastore folder containing the new vm and delete both vmdk files:
ie. ~$ rm -rf ncwv-gitlab01_1.vmdk ~$ rm -rf ncwv-gitlab01_1-flat.vmdk
Now we can clone the vmdk from the old vm folder to the new one.
~$ vmkfstools -i ../ncwv-gitlab01/ncwv-gitlab01.vmdk ./ncwv-gitlab01_1.vmdk -d thin
power on vm
Once the old vmdk is cloned to the same vmdk name the new vm uses, it should be ready to power on.