The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,949 other followers

Archive for the ‘PowerCLI’ Category

Some notes on replacing parts of a text file with template text using sed on a Busybox system

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:

The kind of modifications I am after

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 and up

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:

–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 »

VFrontDe/ESXi-Customizer-PS: PowerCLI script that greatly simplifies and automates the process of creating fully patched and customized VMware ESXi installation images

Posted by jpluimers on 2021/11/30

On my list of things to try, as it allows me to have an ISO at hand in case I ever need to quickly re-install a machine to the current patch level (for instance when the USB boot stick breaks down: these things happen in reality): [Wayback] VFrontDe/ESXi-Customizer-PS: PowerCLI script that greatly simplifies and automates the process of creating fully patched and customized VMware ESXi installation images

ESXi-Customizer-PS is a Powershell script that greatly simplifies and automates the process of creating fully patched and customized ESXi 5.x and 6.x installation ISOs using the VMware PowerCLI ImageBuilder module/snapin.

Requirements

  • A Windows computer (XP or newer) with Powershell 2.0 or newer
  • VMware PowerCLI version 5.1 or newer

You can get the code from [Wayback] ESXi-Customizer-PS/ESXi-Customizer-PS.ps1 at master · VFrontDe/ESXi-Customizer-PS.

The old site (which still has most of the documentation) can be reached at two places:

A video showing how to use it is below the signature.

The above links via [Wayback] Custom ESXi ISO with ne1000 driver for install on Intel NUC Frost Canyon – seanwalsh.dev.

 

Oh: you can check if you have a PXE, USB or HDD installation of ESXi via the steps here: Determining the ESXi installation type (2014558) | VMware KB.

More on a failing USB stick later…

 

–jeroen


Read the rest of this entry »

Posted in CommandLine, Development, ESXi6, ESXi6.5, ESXi6.7, ESXi7, Power User, PowerCLI, PowerShell, PowerShell, Software Development, Virtualization, VMware, VMware ESXi | Leave a Comment »

ESXi: finding unmounted VMFS volumes

Posted by jpluimers on 2021/08/26

Sometimes, especially when ESXi thinks a volume is bad, but the ESXi S.M.A.R.T. logging does not indicate so, it boots without mounting some of the VMFS volumes as datastores.

It took me a while to find the right command to list those, but I’m glad I found it:

Read the rest of this entry »

Posted in ESXi6, ESXi6.5, ESXi6.7, Power User, PowerCLI, Virtualization, VMware, VMware ESXi | Leave a Comment »

NVMe and SATA health data on ESXi: some links to investigate

Posted by jpluimers on 2021/08/25

(Edit 20221202: added one more link on “REALLOCATED SECTOR CT below threshold”)

Somehow, health data of my NVMe and SATA drives do not show up as health information on the web-ui of my ESXi playground rig.

So far, I noticed that ESXi runs a smartd, but does not ship with a smartctl, nor health data ends up in the web user interface. So you cannot see the state of NVMe and SATA devices easily.

Still these devices deteriorate over time and afterwards die, so below are some links to investigate later.

Goal is to use my own thresholds to set warning and error levels.

Some log entries:

Read the rest of this entry »

Posted in *nix, *nix-tools, ESXi6, ESXi6.5, Power User, PowerCLI, smartmontools/smartctl/smartd, Virtualization, VMware, VMware ESXi | Leave a Comment »

The tale of [SSH into ESXi 6.7 box resulting in “debug1: expecting SSH2_MSG_KEXDH_REPLY”, delay and after entering password “Permission denied, please try again.”]

Posted by jpluimers on 2021/04/02

A similar ESXi 6.5 box worked well to ssh into, but on ESXi 6.7 it failed:

SSH into ESXi 6.7 box resulting in “debug1: expecting SSH2_MSG_KEXDH_REPLY“, delay and after entering password “Permission denied, please try again.

I had a hard time figuring out why: Login with the same user+password on the web user interface, DCUI and console shell work fine (see [WayBack] Enable SSH on VMware ESXi 6.x – VirtuBytes).

Searches that led me to EBCAK:

Read the rest of this entry »

Posted in ESXi6.5, ESXi6.7, Hardware, IPMI, Mainboards, Power User, PowerCLI, SuperMicro, Virtualization, VMware, VMware ESXi | Leave a Comment »

 
%d bloggers like this: