> ## Documentation Index
> Fetch the complete documentation index at: https://docs.macstadium.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prepare a VM before you push it to an image

> Restart after NVRAM changes, let work in the guest finish, remove secrets, and test the result before you push an Orka VM to an image for CI.

The image you push is the starting point for every VM deployed from it, so anything left in the VM, or missing from it, shows up in every job. Run through these steps before `orka vm push`.

## Restart after NVRAM changes

Settings stored in the VM's NVRAM, such as `boot-args` or other variables you set with `sudo nvram`, reach the VM's files on the node only when macOS restarts. If you push right after changing them, VMs deployed from the image come up without the change.

Restart from inside the guest, then confirm the value survived before you push:

```bash theme={null}
sudo nvram boot-args="<BOOT_ARGS>"
sudo shutdown -r now
```

When the VM is reachable again:

```bash theme={null}
nvram boot-args
```

Then push:

```bash theme={null}
orka vm push <VM_NAME> <SERVER_ADDRESS>/<IMAGE>:<TAG>
```

Restart from inside macOS. Deleting the VM discards it, and Orka 4.0 has no command to stop and start a VM.

## Let work inside the VM finish

Orka copies the VM's disk while the VM keeps running. Let installs, builds, and downloads finish, and quit apps that are writing to disk, so the image doesn't capture a half-written state.

## Remove secrets

Every VM deployed from the image gets a copy of everything on its disk. Before you push, remove anything you used during setup that shouldn't be in every VM:

* Git credentials, `.netrc` files, SSH private keys, registry logins, and CI agent tokens.
* Tokens embedded in the remote URLs of repositories you cloned into the image. Check with `git remote -v`.
* The User Data log, if the VM ran a User Data script that printed anything sensitive. Its output is in `/var/log/orka/userdata.log` and travels with the image. See [Bootstrap VMs with User Data](https://docs.macstadium.com/orka/orka-resources/userdata.md#keep-credentials-safe).
* Shell history, which can hold secrets you typed. Clear it as the last step:

  ```bash theme={null}
  unset HISTFILE
  rm -f ~/.zsh_history ~/.bash_history
  ```

Have your CI system provide secrets to each job when it runs instead.

Also change the VM's default `admin` password before you push, so VMs from the image don't inherit it. See [Understanding Orka credentials](https://docs.macstadium.com/orka/orka-cluster-access/understanding-orka-credentials.md).

## Push to a new tag, then test it

Push to a new versioned tag rather than overwriting one you already use. Then deploy a VM from the new tag and run a real job on it before you point your pipelines at it.

## Related pages

* [How Orka manages VMs](https://docs.macstadium.com/orka/orka-overview/how-orka-manages-vms.md#how-do-you-keep-changes-you-make-inside-a-vm)
* [Save Orka VM changes to a local or OCI image](https://docs.macstadium.com/orka/oci-images/oci-images-preserve-changes.md)
* [Building a hardened custom image](https://docs.macstadium.com/orka/oci-images/building-a-hardened-custom-image.md)


## Related topics

- [Save Orka VM changes to a local or OCI image](https://docs.macstadium.com/orka/oci-images/oci-images-preserve-changes.md)
- [How Orka manages VMs](https://docs.macstadium.com/orka/orka-overview/how-orka-manages-vms.md)
- [Building a hardened custom image](https://docs.macstadium.com/orka/oci-images/building-a-hardened-custom-image.md)
- [Bazel remote build execution for iOS and macOS with Orka](https://docs.macstadium.com/orka/orka-devops-integrations/bazel-rbe.md)
- [Save, commit, and push Orka VM images with the CLI](https://docs.macstadium.com/orka/orka-cli-reference/vm-lifecycle-management.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.