Nutanix Emergency VM Rescue Bash Toolkit

Introduction

Every environment faces moments of failure. Whether from guest corruption, misconfigurations, or broken updates, virtual machines sometimes need urgent rescue. This guide offers a pre-built Bash-based emergency toolkit using acli to snapshot VMs, reassign NICs, attach recovery ISOs, and power cycle problematic VMs.


My Personal Repository on GitHub

Nutanix Repository on GitHub


Diagram: Rescue Toolkit Flow

Diagram of Rescue Toolkit Flow.

Rescue Toolkit Functions

  1. Snapshot current VM state
  2. Detach all NICs (useful for network isolation)
  3. Attach ISO for repair
  4. Power off/on cycle

Bash Script: nutanix_vm_rescue.sh

#!/usr/bin/env bash
set -euo pipefail

vm="$1"
iso_image="CentOS-Rescue.iso"
log="/var/log/nutanix_rescue.log"

echo "[$(date)] Starting rescue for $vm" | tee -a "$log"

# Step 1: Snapshot
snap_name="${vm}_rescue_$(date +%Y%m%d%H%M)"
acli vm.snapshot_create "$vm" snapshot_name="$snap_name"
echo "Snapshot created: $snap_name" | tee -a "$log"

# Step 2: Power off
acli vm.off "$vm"
echo "VM powered off" | tee -a "$log"

# Step 3: Detach NICs
acli vm.nic.delete_all "$vm"
echo "All NICs detached" | tee -a "$log"

# Step 4: Attach ISO
acli vm.cdrom_update "$vm" clone_from_image="$iso_image"
echo "Attached ISO: $iso_image" | tee -a "$log"

# Step 5: Power on VM
acli vm.on "$vm"
echo "Rescue boot initiated" | tee -a "$log"

Usage Example

./nutanix_vm_rescue.sh app01

Tips for Rescue Operations

  • Preload known-good ISO images in the image service
  • Always create a snapshot before any destructive action
  • Detach NICs to prevent boot loop or DHCP issues
  • Reattach network or restore from snapshot after inspection

Optional Enhancement: Slack or Email Alert

echo "Rescue started for $vm" | mailx -s "Nutanix VM Rescue Triggered" ops@example.com

Summary

The Nutanix Emergency VM Rescue Toolkit helps you act fast when systems go sideways. Whether it’s attaching an ISO, detaching NICs, or just grabbing a safe snapshot, this script builds a first-response automation layer for unstable VMs.

External Documentation:

Keep exploring

Choose your next step

Continue with the path that best matches the architecture or operating challenge in front of you.

Leave a Reply

Discover more from Digital Thought Disruption

Subscribe now to keep reading and get access to the full archive.

Continue reading