LINUX VM MIGRATION PREP — README
═════════════════════════════════

There are two ways to run the migration prep on a Linux VM:

  METHOD 1 — Via Move Appliance (network)   → see section: "METHOD 1: RUN VIA MOVE APPLIANCE"
             Requires the VM to have network access to the Move appliance.
             One-liner — no files need to be copied to the VM.

  METHOD 2 — Local (offline)                → see section: "METHOD 2: RUN LOCALLY (OFFLINE)"
             Use this when the VM cannot reach the Move appliance directly.
             Requires copying the script files to the VM first.


DIRECTORY STRUCTURE
────────────────────
There are TWO directories involved — one you create (the staging bundle), one the script creates automatically.

STAGING DIRECTORY — you create this and copy files into it:

/opt/movebundle/                       ← copy all migration files here before running
├── esx_setup_uvm.sh                   ← main prep script
├── validate_prep_state.sh
├── scripts/
│   ├── nutanix_move.sh
│   ├── retainIP.sh
│   ├── uninstallVMwareTools.sh
│   ├── install_ngt.sh
│   ├── reconfig_fstab.sh
│   └── configureTempDisk.sh
├── uninstall_scripts/
│   └── cleanup_installation.sh
└── virtio_scripts/
    ├── installAMD.sh
    └── isAMDInstalled.sh


WORKING DIRECTORY — created automatically by the script when it runs:

/opt/Nutanix/                          ← NXBASE_DIR (script output, do NOT create manually)
├── log/
│   └── uvm_script.log
├── prep_state                         ← state tracking file
├── validate_prep_state.sh
└── Move/
    └── download/
        ├── scripts/
        └── virtio/
            └── scripts/
└── Uninstall/
    └── scripts/
        └── cleanup_installation.sh


There's ONE key variable at esx_setup_uvm.sh that controls where the working directory is created:
NXBASE_DIR="/opt/Nutanix"    ← THIS IS THE ONLY DIR TO CHANGE (if needed)


PREREQUISITES
─────────────
- Must be run as root (sudo or root session)
- Supported: RHEL/CentOS/OEL 6.x–8.x, SLES 12/15, Ubuntu 16.04+


METHOD 1: RUN VIA MOVE APPLIANCE
─────────────────────────────────
If the VM has network access to the Move appliance, no files need to be copied.
Run the following single command on the VM, replacing <Move_IP> with the actual Move appliance IP:

    curl -sSk https://<Move_IP>/resources/uvm/linux/esx_setup_uvm.sh | sudo sh /dev/stdin --move-address '<Move_IP>' --retain-ip --install-amd --reconfig-lvm --uninstall-vmware-tools

NOTE: --move-address is required when running via this method so the script knows
      where to download migration artifacts from.



METHOD 2: RUN LOCALLY (OFFLINE)
────────────────────────────────
1. Create a staging directory on the VM to copy the script files into.
   This is a temporary working location — it can be anywhere writable.
   /opt/Nutanix/ is NOT this directory — that is created automatically by the script when it runs.

       mkdir -p /opt/movebundle
       cd /opt/movebundle

2. Copy all the following files/folders into that directory:
       esx_setup_uvm.sh
       validate_prep_state.sh
       scripts/
       uninstall_scripts/
       virtio_scripts/

3. Make the script executable:
       chmod +x esx_setup_uvm.sh

4. Run with the appropriate flags:
       sudo ./esx_setup_uvm.sh [flags]

   Standard full migration example:
       sudo ./esx_setup_uvm.sh --retain-ip --install-amd --reconfig-lvm --uninstall-vmware-tools


FLAGS
─────
Flag	                            Short	                What it does
--retain-ip	                        -r	                    Keeps the VM's IP after migration
--install-amd	                    -d	                    Installs VirtIO drivers (recommended for all migrations)
--reconfig-lvm	                    -l	                    Reconfigures LVM (use if VM has LVM disk layout)
--uninstall-vmware-tools	        -u	                    Schedules VMware Tools removal at cutover (not executed immediately)
--reconfig-fstab	                -s	                    Reconfigures fstab — only needed for non-standard disk layouts; Move handles this automatically in most cases
--install-ngt	                    -n	                    Installs Nutanix Guest Tools post-migration


WHAT THE SCRIPT DOES (in order)
────────────────────────────────
1. Verifies /opt/movebundle exists and is accessible
2. Runs cleanup of any previous prep
3. Creates the /opt/Nutanix directory structure
4. Copies migration artifacts from /opt/movebundle into /opt/Nutanix
5. Schedules the Move service to run at cutover


LOGS & TROUBLESHOOTING
───────────────────────
Log file:   /opt/Nutanix/log/uvm_script.log
State file: /opt/Nutanix/prep_state  ← tracks what has already run

If the script needs to be re-run, execute the cleanup first:
    sudo bash /opt/Nutanix/Uninstall/scripts/cleanup_installation.sh