For my link archive: [Wayback] VMware ESXi: How to Kill an Unresponsive (Stuck) Virtual Machine | Windows OS Hub
Commands covered:
esxcli vm process list
esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber
esxtop
ps
kill
–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 list
esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber
esxtop
ps
kill
–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/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/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.sh
file 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 +t
run backup manually before the first reboot:
/sbin/auto-backup.sh
because 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
.vswp
files 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 »