Kill unresponsive VM from ESXi cli

Sometimes a VM can go in an unresponsive mode and you cannot shut it down or reboot it from the vSphere client. When this happens we need to be more persuasive in telling the VM to shut down. Log in to the ESXi server with SSH, find the World ID for the unresponsive VM and kill the process, this is done like this:

esxcli vm process list

This will list all the running VMs on the server, use grep -A2 to filter the VM name and the world ID, like this:

esxcli vm process list |  grep -A2 “VM Name”

Kill the process with this command:

esxcli vm process kill -t=soft -w=”WORLD_ID”

This will kill the process in a “soft” way, use -t=hard to be even more persuasive and as a last resort attempt you can use -t=force. If none of the three shuts down the VM, a reboot of the host is required.
To automate things a bit i assembled this one-liner for easy use:

esxcli vm process kill -t=soft -w=`esxcli vm process list | grep -A2 “VM Name” | grep World | awk ‘{print $3}’`

This will softly shut down the VM with “VM Name”

Add new virtualportgroup to vSwitch on multiple VMHosts with Powercli

If you dont have dvSwitches (Distributed vSwitches) in your vSphere cluster, or dont even have a cluster, you may have to add new portgroups manually, depending on the number of VMHosts this can a pretty cumbersome task.

Luckily, we can use powercli to automate the task. In the following example i will use the -location parameter to get the VMHosts in target, this could be accomplished in other ways.

Fist, lets get the VMhosts in taget:

$hosts=get-vmhost -location “location”

Then, we create the new portgroup for every VMhost in the location:

foreach ($vmhost in $hosts) {Get-VMHost $vmhost | Get-VirtualSwitch -name “vSwitch0” | New-VirtualPortGroup -VLanId “10” -Name “Name”}

This will create a new VirtualPortGroup with VLAN ID 10 named “Name” on vSwitch0 on all the VMHosts in the specified location.

Remove the port again by doing this:

foreach ($vmhost in $hosts) {Get-VMHost $vmhost | Get-VirtualSwitch -name “vSwitch0” | Get-VirtualPortGroup -Name “Name” | Remove-VirtualPortGroup -Confirm:$false}

Remember that -Confirm:$false will remove the port without confirmation! Make sure you have the right targets in the $hosts variable!!!

Saving and restoring ESXi configuration, and fixing VMKCore coredump partition dump issues

Hi all.
Today i had to reinstall some ESXi 5.5 hosts as we were upgrading to SSD disks, in order to have more performance on the Citrix environment we are hosting.

Before i powered off the server, i saved the configuration to use for easy reconfiguration with the following command from powercli:

Get-VMHostFirmware -VMHost xxx-hostname-xxx -BackupConfiguration -DestinationPath C:\HostBackups\

Now i got a xxx.tgz file containing the full configuration of the original ESXi host, ready for importing back when the reinstall is done.

When the server was installed on the new disks, i connected directly to the reinstalled server by its IP address,  put the server in maintenance mode and imported the configuration backup with these commands from powercli:

Set-VMHost -State Maintenance

 

Set-VMHostFirmware -VMHost xxx-hostname-xxx -Restore -SourcePath c:\HostBackups\xxx.tgz -HostUser user -HostPassword password

Because of the new disks i got an error regarding my vmkcore vmkdumpfile that was missing. I was able to list the partition table, which showed that i had two different dump partitions, but none of them were configured for use.
To get it fixed i had to unconfigure the existing coredump partition with this command from the ESXi shell:

esxcli system coredump partition set -u

And then reconfigure the partition with this command, also from the ESXi shell:

esxcli system coredump partition set –enable true –smart

This command will let the system choose which partition to use for the coredumps. The system will now use the choosen partition, no reboot needed.

Re-Volt, Wine, Multiplayer

My kids are beginning to play on their computers, and when one of them where invited to a socalled LAN-Party it woke up memories in my mind. I remembered how I used to play at LAN parties my self, and I remembered how simple it was to set up a game and play against each others. Todays gaming is all about joining public servers, creating accounts, and answering questions about this and that.

That made me think back on one of my favourite games from around 2000, Re-Volt. I searched the web and found that Re-Volt isn’t dead at all, fan communities are still alive, and theres even a small patch for the latest version that will support modern wide screens, easier multiplayer, etc. Check it out here: http://www.revoltrace.net/ where you will also be able to download the latest version and patch.

The kids are running Windows 7 and Windows 10 and we had no issues installing it, the installer will ask for the directplay module and download it when needed. In order to play multiplayer we had to allow some firewall ports to be used even though the firewall is disabled on the local network. When hosting a game I noticed that it’s using my public IP and not my private, thats probably why I had to allow additional ports to be used – 🙁

Now, lets get back to the actual point for my post. I am running Ubuntu Linux 14.04 on my laptop, and I thought I would be able to play Re-Volt using Wine. No problem at all, it installed just fine and worked like a charm, until I wanted to play multiplayer over the LAN. I got different erros depending if I wanted to host or join a game, but quickly I found out that on Linux I also needed the so-called directplay module, which is easily installed with winetricks that comes with the Wine installation on my system. After some googling I found out that all I needed to do was:

winetricks directplay

This command will install the directplay module and now the game is running smoothly with or without multiplayer. Wine documentation states to run “sh winetricks directplay” which will not work for the package-manager installed version.

Using Vim as editor in PowerShell

If you are used to using Vim or Vi as your editor, you might miss it when using powershell. Good news is, theres a way to get it. Download and install Vim for windows, create a profile.ps1 file in this path: (for me at least) c:\users\%username%\documents\WindowsPowerShell\ and type in the following:

$VIMPATH    = “C:\Program Files (x86)\Vim\vim74\vim.exe”

Set-Alias vi   $VIMPATH
Set-Alias vim  $VIMPATH

# for editing your PowerShell profile
Function Edit-Profile
{
vim $profile
}

# for editing your Vim settings
Function Edit-Vimrc
{
vim $home\_vimrc
}

Remember to change the $VIMPATH to your installation.

Now you have a fully functional vim from powershell.

/Kasper

Steam (and possible other) in 64 bit systems

Hi all.

I just tried to install Team Fortress 2 in Steam on my Ubuntu 15.04 64bit system, and I got this error message:

You are missing the following 32-bit libraries, and Steam may not run: libc.so.6

I asked google, and I found an article suggesting to do this: apt-get install lib6* – this will install a hell of a lot of software that you probably don’t need.

So instead of just following the suggestion I did an apt-search libc6, and found this package: libc6-i386, I installed it, and now I was able to install Team Fortress 2 in steam.

/Kasper

Forbinde til en VM i KVM med virsh console

En nem måde at forbinde til en KVM VM er ved brug af kommandoen virsh console ‘vm-name’. Man forbinder direkte til konsollen, og på den måde er man uafhængig af netværk. Mon ikke de fleste har prøvet at rive sig selv i håret, når man opdager at man har lukket sig selv ude fra SSH.

Når man først er inde skal man jo også ud igen, hvis man er vant til at arbejde med SSH skriver man naturligt exit når man vil ud, men så ender man bare i login prompten, stadig på den samme maskine. Når man logger ind kommer et fint lille hint der fortæller at “Escape character is ^]”, og hvad betyder så det? Jo, det må være noget med “Ctrl+AltGr+9”, jeg kan afsløre med det samme at det virker ikke. På min maskine med dansk tastatur layout er det “Ctrl+5”, det er jo dejligt nemt, når man først har brugt ½-1 time på at finde ud af det 🙂

Alt i alt en nem og hurtig måde at logge ind på de enkelte virtuelle maskine og måske endnu vigtigere en god backup, hvis man har dummet sig med netværket.

Cyanogenmod MMS, data og telenor

Jeg har nu efterhånden, ad flere omgange kørt med Cyanogenmods ROM på min telefon i ret lang tid. Et af de problemer, jeg oftest er støt på ved skiftet, er understøttelsen af MMS, det har altid drillet.

Der findes en funktion der kan nulstille APN’erne, den søger på netværket og finder ud af hvad man skal bruge, problemet er bare at de ikke virker. På min telefon ender jeg op med APN’er til Belmore og Bibob begge med internet og MMS. Løsningen har for mig tidligere været at fjerne Bibob APN’erne og så har det virket.

Nu begyndte den så at drille igen forleden, fejlen viste sig ved at jeg igen ikke kunne sende MMS’er. Jeg tjekkede hurtigt APN’erne, men det var kun Telenors der var tilstede. Jeg brugte nulstillingsfunktionen og nu havde jeg igen både bibog og Telenor APN’er, jeg slettede dem til Bibob, men nu virkede hverken MMS’er eller dataforbindelse (3G) 🙁

Efter at have opgivet i den tro at det var 3G dækningen der var for dårlig i det sommerhusområde jeg befandt mig, kunne jeg konstatere ved hjemkomst at jeg stadig havde problemer.

Jeg tjekkede Telenors hjemmeside for at finde de korrekte oplysninger, og jeg fandt en guide der beskrev de oplysninger der skal til. Jeg tjekkede i forhold til de oplysninger den henter fra netværket og bemærkede at der på min telefon er en såkaldt MVNO-type og en MVNO-værdi hvor der i begge stod TELMORE både under internet og MMS’s opsætningen. Jeg prøvede lykken og slettede TELMORE alle 4 steder, og indenfor 1 sekund var jeg tilbage på 3G nettet og MMS’erne tikkede ind.

APN ConfigurationAPN Overview