For my link archive: [Wayback] VMware ESXi: How to Kill an Unresponsive (Stuck) Virtual Machine | Windows OS Hub
Commands covered:
esxcli vm process listesxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumberesxtoppskill
–jeroen
Posted by jpluimers on 2022/04/21
For my link archive: [Wayback] VMware ESXi: How to Kill an Unresponsive (Stuck) Virtual Machine | Windows OS Hub
Commands covered:
esxcli vm process listesxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumberesxtoppskill–jeroen
Posted in ESXi5, ESXi5.1, ESXi5.5, ESXi6, ESXi6.5, ESXi6.7, ESXi7, Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2022/04/20
For my link archive:
–jeroen
Posted in ESXi6, ESXi6.5, ESXi6.7, Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2022/04/13
Guessing the [Wayback] Run ESXi from a USB Flash Drive: A How-To-Guide by just the abstract does not show the value enough:
A USB flash drive can be used not only for installation media – you can also run ESXi from USB flash drives or SD flash cards and boot from these devices.
In fact, the article shows way more, including:
This is very important, because every now and then, these USB and SD devices fail (see for instance [Wayback] Solved: Remount boot filesystem on a running system. – VMware Technology Network VMTN), so knowing what to do then is key and helps handling errors like this one:
Lost connectivity to the device mpx.vmhba32:C0:T0:L0 backing the boot filesystem /vmfs/devices/disks/mpx.vmhba32:C0:T0:L0. As a result, host configuration changes will not be saved to persistent storage.
A every useful article for my link archive!
Related: ESXi: storing an ISO 8601 time-stamped backup tarball locally
Posted in ESXi5, ESXi5.1, ESXi5.5, ESXi6, ESXi6.5, ESXi6.7, ESXi7, Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2022/04/12
An interesting set of scripts from [Wayback/Archive.is] No Joke IT: Graceful shutdown of an ESXi 5.1 host and guest VMs (free edition) using the shell/command line/scripting (UPS friendly).
If all ESXi virtual machines support running of VMware Tools, then the solution is a plain /sbin/shutdown.sh && /sbin/poweroff (see [Wayback/Archive.is] No Joke IT: Shut down ESXi 5.1 guest VMs and the host (free edition) via SSH – the easy way!).
Code is in the repository at [Wayback/Archive.is] sixdimensionalarray/esxidown: A shell script to shutdown VMware ESXi host servers, with these two main files:
#!/bin/sh # Runs a shell command asynchronously. if [ "$1" != "" ]; then nohup sh $1 > /dev/null 2>&1 & fi
# exit maintenance mode immediately before server has a chance to shutdown/power off # NOTE: it is possible for this to fail, leaving the server in maintenance mode on reboot! echo "Exiting maintenance mode..." if [ $TEST -eq 0 ]; then esxcli system maintenanceMode set -e false -t 0 fi
Note: the No Joke IT web-site has vanished, so only the [Wayback] and [Archive.is] links of it still work. The github code was still there at the time of writing.
Via: [Wayback] Solved: Read only Files – VMware Technology Network VMTN
Related: Some notes on replacing parts of a text file with template text using sed on a Busybox system.
–jeroen
Posted in *nix, *nix-tools, ash/dash, ash/dash development, Development, ESXi5, ESXi5.1, ESXi5.5, ESXi6, ESXi6.5, ESXi6.7, Power User, Scripting, Software Development, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2022/03/29
When virtualising your final physical Windows XP machines (just in case you need to hook up old hardware that is unsupported from newer Windows versions), you need to figure out the kind of license of each physical Windows XP machine in order to stand a chance to keep it licensed.
This answer by [Wayback] Moab [Wayback] windows xp – How to know which license version has an XP installed system – Super User helped me a lot.
I tried to make it a bit easier to read:
xxxxx-yyy-zzzzzzz-zzzzz
xxxxx: the MCP (Microsoft Product Code) describing which product version, or in case of Windows XP: what language, edition (like “Home” and “Pro”) and often some more information)yyy: the Channel ID (especially important to set apartOEMfrom other channels;OEMis not allowed to be virtualised, so would need a complete new Windows XP key to be activated as Virtual Machine; Channel IDs being neitherOEMnorVLK(volume license key) can often be re-activated, sometimes over the phone to explain the situation; I’ve not tried virtualising aVLKbased Windows XP yet.zzzzzzz-zzzzz: semi-random values[Wayback/Archive.is] Product IDs – Lunarsoft Wiki has quite detailed lists of not just the MCP and Channel ID values for Windows XP and Windows Server 2003, but also the disk volume labels and
setup.inilabel values.
Often this is easier to do from the physical machine before virtualising it, but even afterwards you can get it by running Windows in Safe Mode, then use either of these to get the Product ID:
sysdm.cpl which shows the “Product ID” us under the “Registerd to” information.reg query "hklm\software\microsoft\windows nt\currentversion" /v ProductIDI got the link from [Wayback] activate windows xp – Microsoft Community via [Wayback] windows xp – How do I activate WindowsXP now that support has ended? – Super User.
Phone (in most countries) and on-line activation should still work; it worked in 2016 (see [Wayback] license – Will I still be able to activate Windows XP after support ends? – Super User) 2019 (see [Wayback] windows xp – How do I activate WindowsXP now that support has ended? – Super User) and 2020 (see [Wayback] XP activation – Windows XP Home and Professional).
I’m not a lawyer, and Microsoft Licensing is a pain (especially for products that are out of support), but it looks like it is about three licenses:
- the original OEM license on the physical machine that allowed you to install the original Windows XP on that machine
- the non-OEM license for the Virtual Machine (if I read the thread correctly, it needs to be a Volume License that has Software Assurance) to activate it
- an access license so you can logon to the Virtual Machine or otherwise access it
Alternatively, if you started with a non-OEM license, and you could re-activate it on the virtual machine, it looks like you only need 3 (if you could not reactivate, you’d need 2 and 3)
Chris (Microsoft) had many interesting responses in the thread: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
Other interesting bits in the thread: the XP activation servers are still working, but buying new keys for it can be problem and given the right licenses, reinstalling a virtual machine is virtually indistinguishable from cloning the physical machine.
Note that it is no use searching Google for Windows XP License keys: Microsoft did and invalidated them back in the Windows XP SP1, SP2 and SP3 days: Wayback: Error message when you install Windows XP Service Pack 1 (SP1) or Service Pack 2 (SP2): “The product key used to install Windows is invalid
The 2001 Windows XP Professional License is archived in the Wayback machine as Microsoft Windows XP Professional END-USER LICENSE AGREEMENT: Windows%20XP_Professional_English_9e8a2f82-c320-4301-869f-839a853868a1.pdf (via [Wayback] Convert your existing Windows XP system into a virtual machine – TechRepublic).
Note this does not cover OEM or Volume Licenses.
–jeroen
Posted in ESXi6, ESXi6.5, ESXi6.7, Power User, Virtualization, VMware, VMware ESXi, Windows, Windows XP | Leave a Comment »
Posted by jpluimers on 2022/03/23
For my link archive (especially because when disconnecting USB devices, the path value needs to be uber-correct, while for connecting, the path value only needs to be a partial match):
Commands applicable:
lsusb/var/log/vmkernel.log file filtered on usb (in a case insensitive way)vim-cmd vmsvc/device.getdevicesvim-cmd vmsvc/device.connusbdevvim-cmd vmsvc/device.disconnusbdev–jeroen
Posted in ESXi6, ESXi6.5, ESXi6.7, Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2022/03/17
Note before you think about putting stuff in
/etc/rc.local.d/local.sh: that script will not be executed when UEFI booting.
In a very lightweight Busybox system, I wanted to modify some configuration files automatically using fragments stored in template files.
The system has diff, but no patch.
The basic idea is to use sed to insert the template files into certain spots of the configuration file when certain marker texts are not present. So I want the opposite of [Wayback] Hey Stephen Wood: Try patch instead of sed in shell scripts.
Basically the idea is a poor-man’s patch, described in Too bad: ESXi busybox has diff, but not patch « The Wiert Corner – irregular stream of stuff.
Some links that might help me with this:
One alternative would have been to use ed (which is part of the normal Busybox), but ESXi Busybox omits ed like it omits patch.
Too bad that sed commands are too different from ed commands, as I could have used diff -e on another system based on ideas here:
I might give it one more go, as vi is sort of derived from ed via ex (see vi: Creation – Wikipedia), which means that vi “colon mode” (officially command mode: [Wayback] Vim documentation: cmdline) is very similar to ed.
Another alternative would be awk, but I have done so little work with it awk, that I’m hesitating to use a new tool. Some links:
And finally, ash could be used:
Below are a few links with examples of the kind of modifications I want to make. Most patch just /etc/rc.local.d/local.sh, but some others introduce other changes as well.
Note that especially with networking settings, local.sh commands might not have any effect (for instance when having slow DHCP or other network issues), see for instance [Wayback/Archive.is] I’m running ESXi 5.5 and my persistent route in local.sh is not taking effect after boot. : vmware.
There is a very convoluted way around using local.sh by using the VIB authoring tool as described in [Wayback] How to create persistent firewall rules on ESXi. It requires lowering the software acceptance level to Community Supported (esxcli software acceptance set --level=CommunitySupported), which gives you a hard time installing ESXi updates.
I got that VIB idea from [Wayback] Solved: Re: Persistent firewall rule – VMware Technology Network VMTN, as:
The
local.shfile gets overwritten often with upgrades so it would mean another step during the process.
From the same thread comes [Wayback] Solved: Re: Persistent firewall rule – VMware Technology Network VMTN
set the sticky bit on your separate xml-file – then it will be backed up and persist through reboot:
chmod +trun backup manually before the first reboot:
/sbin/auto-backup.shbecause backup runs only once per hour
Within vSphere, one could use [Wayback] Configure ESXi Hosts with Host Profiles, but a standalone ESXi box is not part of vSphere, so that won’t work.
ESXi 7 makes the above harder as for instance user root cannot change file rights any more, so eventually I might revert to a VM that auto-boots when ESXi comes up, then patches the right files in place over PowerCLI (read-only) or SSH.
Need to give this some thought later:
PowerCLI commands on the free version are limited to commands that are “read-only”, so you can only find out information rather than perform actions, if that makes sense.
So you can find out if a VM is turned on, find it’s uptime, but you can not turn it on or reboot it
This presumably is to prevent automation without a license…
Having a quick look at the VMware KB, it looks like PowerCLI was limited on the free version to “read-only” operations from 5.0 (I.e. when it went from ESX to ESXI) along with vCLI and vSphere-Perl, so for some time from the looks of it
–jeroen
Posted in *nix, *nix-tools, ash/dash, ash/dash development, Awk, BusyBox, Development, ESXi6, ESXi6.5, ESXi6.7, ESXi7, Power User, PowerCLI, Scripting, sed, sed script, Software Development, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2022/03/02
On my ESXi boxes, I have a directory with local scripts that in part depend on the machine.
So I contemplated patching the dending parts with patch.
Then I found out that the BusyBox that VMware built for ESXi does have diff, but not patch:
# $(readlink -f "`which diff`") BusyBox v1.29.3 (2021-01-17 01:25:00 PST) multi-call binary. BusyBox is copyrighted by many authors between 1998-2015. Licensed under GPLv2. See source distribution for detailed copyright notices. Usage: busybox [function [arguments]...] or: busybox --list or: function [arguments]... BusyBox is a multi-call binary that combines many common Unix utilities into a single executable. Most people will create a link to busybox for each function they wish to use and BusyBox will act like whatever it was invoked as. Currently defined functions: addgroup, adduser, arch, ash, awk, basename, bunzip2, bzcat, bzip2, cat, chgrp, chmod, chown, chvt, cksum, clear, cp, crond, cut, date, dd, delgroup, deluser, diff, dirname, dnsdomainname, du, echo, egrep, eject, env, expr, false, fdisk, fgrep, find, fstrim, getty, grep, groups, gunzip, gzip, halt, head, hexdump, hostname, inetd, init, kill, ln, logger, login, ls, lzop, lzopcat, md5sum, mkdir, mkfifo, mknod, mktemp, more, mv, nohup, nslookup, od, passwd, poweroff, printf, readlink, reboot, reset, resize, rm, rmdir, sed, seq, setsid, sh, sha1sum, sha256sum, sha3sum, sha512sum, sleep, sort, ssl_client, stat, stty, sum, sync, tail, tar, taskset, tee, test, time, timeout, touch, true, uname, uniq, unlink, unlzop, unzip, usleep, vi, watch, wc, wget, which, who, xargs, zcat
This list is much shorter than the applets that are supported in [Wayback] BusyBox – The Swiss Army Knife of Embedded Linux, so VMware did cut out quite a few.
The command-line trick above first expands diff using the output of which diff, then finds out where it links to through the readlink -f wrapper there the back-quotes “`” get this output:
# readlink -f "`which diff`" /usr/lib/vmware/busybox/bin/busybox
Finally the $(...) executes the output of readlink.
It is based on [Wayback] bash – How to resolve symbolic links in a shell script – Stack Overflow
readlink -f "$path"Editor’s note: The above works with GNU readlink and FreeBSD/PC-BSD/OpenBSD readlink, but not on OS X as of 10.11.GNU readlink offers additional, related options…
Given there is no patch, I need to think about a good way to apply patches, for instance to snip this into /etc/rc.local.d/local.sh in a reliable way:
## BEGIN-PATCH-PATH # local binaries are in /vmfs/volumes/NVMe980PRO_1TB/local-bin/ # link that directory from /opt/bin # then add /opt/bin to the PATH in /etc/profile so that on each logon it becomes available # this means you need to logon twice after reboot: # - first to patch /etc/profile # - second to have the correct PATH loaded from /etc/profile # direcory exist trick from https://stackoverflow.com/questions/59838/how-can-i-check-if-a-directory-exists-in-a-bash-shell-script patch_etc_profile_PATH() { if [ -d "$1" ]; then ln -s "$1" "/opt/bin" sed -i -e 's!PATH=/bin:/sbin!PATH=/bin:/sbin:/opt/bin/!' /etc/profile fi } patch_etc_profile_PATH /vmfs/volumes/NVMe980PRO_1TB/local-bin/ ## END-PATCH-PATH
–jeroen
Posted in *nix, *nix-tools, ash/dash, ash/dash development, BusyBox, Development, ESXi6, ESXi6.5, ESXi6.7, ESXi7, Power User, Scripting, Software Development, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2022/02/23
Earlier this month, I ended ESXi: editing /etc/vmware/hostd/vmInventory.xml to fix the datastore UUID for unavailable VMs part 2 with this:
A final note: I need to check out if
.vswpfiles need to be there at all, as my ESXi servers have plenty of physical memory in order not to swap out to disk. More on that in a future blog post.
Browsing back through my blog posts, I mentioned .vswp files before, but never really dug into them:
Posted in ArchiveTeamWarrior, ESXi6, ESXi6.5, ESXi6.7, ESXi7, Internet, InternetArchive, Power User, Virtualization, VMware, VMware ESXi, WayBack machine | Leave a Comment »
Posted by jpluimers on 2022/02/22
Note: the below holds for sure for ESXi 5.x and 6.5; as of ESXi 7.x, the VMKlinux stack is supposed to be gone for good. I still need to verify that as I’m still on ESXi 6.7.
I wrote about ESXi VMKlinux and native drivers before:
Back then, I knew that VMKlinux based drivers were being slowly phased out as of ESXi 5.5. But I didn’t really understand the actual difference.
VMKlinux is a bit like NDISwrapper – Wikipedia: it allows drivers basically written for a different platform to run on your platform. For NDISwrapper, it is about running Windows NDIS drivers on both i386 (née, x86-32, née IA-32) and x86-64 architectures. For VMKLinux, it allows drivers originally written for the Linux Kernel to be run on ESXi through an intermediate wrapper layer.
Usually having both native and wrapped code means that not all functionality is yet available natively. That was indeed the solution for my smartinfo trouble: the native drivers were having latency problems where the VMKlinux drivers were not.
Sometimes it means that hardware is only supported by the VMKlinux drivers, which (since native drives have a higher priority than VMKlinux drivers) means disabling the native driver.
This does not work in the early upgrade/install boot process: there the settings cannot be read from the configuration files yet. ESXi solves this by having a global boot option preferVmklinux=True that you can store in the boot configuration.
Most of the issues this solves are around USB boot sticks and USB disks, but not all of them, see the below links and summaries for more information.
I like the solution by temporarily using preferVmklinux=True, then just disabling the vmkusb best.
Upon rebooting the host, the host will need to use the legacy USB drivers to boot correctly. At the startup screen, you can press “e” to edit the boot parameters or later you can press “Shift + O” to edit the boot parameters.
Again add this to the boot parameters: preferVmklinux=TRUE
…
Once the system is booted and you can login to the ESXi shell you will need to enter the following commands:
esxcli system settings kernel set -s preferVmklinux -v FALSE esxcli system module set –enabled=false –m vmkusb rebootOnce the system reboots it will boot and discover the USB devices properly.
It should be noted that only a few systems have problems with the new USB driver. I had this trouble on an older system. An HP ML330 G6 gave me the trouble.
only one of the two Gigabit Ethernet interfaces will work out of the box. That’s why the interface did not get an IP address in the video above. Both interfaces were detected, but for some reason only the other one was detecting signal when I had an Ethernet cable plugged in.
…
using another computer make an SSH connection to the ESXi box, log in as root and execute the two following commands:
esxcli system settings kernel set -s preferVmklinux -v TRUE rebootAfter the reboot your both network interfaces should be working as expected.
After upgrading my ESXi host from 6.0 to 6.5, I am now unable to SSH into it or connect to it in any way. It appears to freeze half way through booting up (last message displayed : nfs41client loaded successfully) … Hardware: MacPro 6,1 Q: What are my options? TIA
If you prefer not to manually have to add the ESXi boot option by hand, you can create an ESXi bootable USB key and then simply edit both
boot.cfgandefi/boot/boot.cfgand append the option as shown below:kernelopt=runweasel preferVmklinux=True
The issue looks to be related to the new USB Native Driver (vmkusb) that was introduced in ESXi 6.5 where is it is unable to claim the specific USB device.
Although you can disable the USB Native Driver and fall back to the legacy driver as mentioned in this VMware KB 2147650, but because this is happening during the installation/upgrade process, it can get a bit tricky.
…
workaround
- Step 1 – Append preferVmklinux=TRUE to the ESXi’s boot.cfg file whether that is on a USB device which has your ESXi installer or on your PXE Server for ESXi Scripted Installations.Here is an example of what boot.cfg should look like:
kernelopt=runweasel preferVmklinux=TRUE</pre>- Step 2 – Boot up ESXi and you should now be able to see the USB device and continue with your upgrade.
- Step 3 – Once ESXi has been successfully upgraded, go ahead and run the following commands to re-enable the Native Drivers and disable the vmkusb driver (reboot required for changes to go into effect):
esxcli system settings kernel set -s preferVmklinux -v FALSEesxcli system module set –enabled false -m vmkusbreboot
Note: If you are doing an ESXi Scripted Installation, you can actually append just the first two commands (replace esxcli with localcli as hostd is not running) as part of the Kickstart
%postsection.
In ESXi 6.5, the legacy USB drivers, including
xhci,ehci-hcd,usb-uhci,usb,usb-storage, and so on, are replaced with a single USB driver namedvmkusb. The vmkusb driver is loaded by default and it is applied to all the USB Host Controllers (XHCI/EHCI/UHCI/OHCI), USB Keyboard, Mass Storage, and supported USB NIC devices connected to the host.…
You can disable the vmkusb driver by running
esxcli system module set -m=vmkusb -e=FALSE. The legacy USB drivers are loaded at the next reboot. To re-enable the vmkusb driver, runesxcli system module set -m=vmkusb -e=TRUE, and reboot the host.…
If the host will not boot completely to use the solution, please follow the below steps:
- Reboot the ESXi host.
- During the pre-boot splash screen, press SHIFT-O to modify the boot options.
- In the resulting screen, add the following to the end of the boot line:
jumpstart.disable=vmkusb
- Press the enter key to resume boot.
Note: When ESXi host comes up, vmkusb module will be disabled, and the solution can be followed to make the change permanent.
ESXi 6.5 contains many new native drivers that replace the earlier vmklinux drivers. Most of the new native drivers are enabled by default after installation or upgrade.
Some of the new native drivers are disabled by default, because they do not fully support the functions of the corresponding vmklinux drivers. For example:
- qflge is a native driver that replaces the vmklinux net-bnx2 driver, but does not support HW iSCSI.
- qfle3 is a native driver that replaces the vmklinux net-bnx2x driver, but does not support HW iSCSI and SW FCoE.
- ixgben is a native driver that replaces the vmklinux net-ixgbe driver, but does not support SW FCoE.
…
steps for enabling/disabling a native driver (which then overrules the VMKlinux driver)
Since the first days of ESX, we used the Linux derived driver modules to provide support for a large range of hardware devices. Doing so gave us a lot of hardware compatibility, but at the cost of introducing an additional layer of driver emulation. Because ESX is not Linux, we needed a translate layer that provides communication between the VMkernel and the Linux driver modules. This is the imperative layer that is VMKlinux. But since vSphere 5.5, we introduced the Native driver stack with the plan to move away from the VMKlinux driver stack. Please review the following blog posts for more in depth information about both driver stacks:
- ESXi 5.5 introduces a new Native Device Driver Architecture Part 1
- ESXi 5.5 introduces a new Native Device Driver Architecture Part 2
- Prepping an ESXi 6.7 host for Secure Boot
The vSphere 6.7 family will be the last vSphere versions that includes the VMKlinux driver stack. Future releases will only ship with the Native driver stack.
…
How to check impact on your cluster
If you run the following command, it will show you if the VMKlinux module is loaded on that specific ESXi host.
esxcli system module list | grep vmklinuxWhen it returns nothing, the system is already in full native mode and there are no VMKlinux dependencies. This however, is an ESXi host only approach. We came up with the following script to assist you in verifying an entire cluster.
With the help of William Lam, we created a script that identifies ESXi hosts with VMKlinux driver modules loaded. The usage of the script is pretty straightforward. Get, and contribute to, the script here: https://github.com/lamw/vghetto-scripts/blob/master/powershell/VMKLinuxDrivers.ps1.
–jeroen
Posted in ESXi6, ESXi6.5, ESXi6.7, ESXi7, Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »