# Uninstalling Datafy

Uninstalling Datafy is just as simple as the initial installation. Except for the [preparation](#prepare-for-uninstall), the following steps are the same for uninstalling Sensor or AutoScaler.

## Prepare for Uninstall

If you have **AutoScaler** installed, before you can uninstall, you must turn off autoscaling for all volumes managed by Datafy. Turning off autoscaling returns your volumes to their original provisioned size and removes the virtualization layer managed by Datafy. This is critical for ensuring access to your data after Autoscaler is uninstalled.

{% hint style="info" %}
If you only have Sensor installed, you can skip this step
{% endhint %}

{% stepper %}
{% step %}
**Turn Off Autoscaling Rules**

If you have autoscaling rules active in your account, turn off any rules relevant to the instances you wish to uninstall from, in the [Autoscale Rules table](https://app.datafy.io/fleet-manager/autoscale-rules) in the Datafy app.

This ensures that autoscaling isn't activated for any new volumes while you are preparing for uninstalling.

<figure><img src="/files/8L8FfX9Aiu6elpKvQ1BW" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Identify Managed Volumes**

In the [All Volume table](https://app.datafy.io/fleet-manager/all-volumes) in the Datafy app, find all of the relevant volumes by filtering the status "Autoscaling active" in the dashboard

<div data-full-width="false"><figure><img src="/files/UXOnfDwTYaZfGewOrfgm" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**Turn off Autoscaling**

Turn off the toggle in the "AutoScale" column for all of the relevant volumes.

<figure><img src="/files/ITexFuzw17SSXsnLFivk" alt=""><figcaption></figcaption></figure>

Similarly to the initial migration process when autoscaling was turned on, this stage can take time, dependent on the size of the volume. You track the progress in the All Volumes table, or in the Optimization Actions log in the [Reports](https://app.datafy.io/reports) tab.

<figure><img src="/files/kcKQg47H0DEbTEh23VkM" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

## Uninstall Datafy

{% hint style="warning" %}
Uninstalling AutoScaler when there are managed volumes can lead to loss of access to the data stored on those volumes. Always [turn off autoscaling](#prepare-for-uninstall) before uninstalling Autoscaler.
{% endhint %}

Datafy can be uninstalled in the same ways it was installed, by substituting `install` from the [original install command](/set-up-and-installation/datafy-installation/installation.md) with `uninstall`. The version supplied should match the version installed.

### EC2 Instance

```sh
curl -sSfL https://agent.datafy.io/uninstall\?version=$VERSION | sh
```

{% hint style="info" %}
You can check which version is installed on your instance with the command:

```bash
 /usr/local/datafy-agent/bin/datafy-agent --version
```

{% endhint %}

### Kubernetes Cluster

You should use the same method to uninstall as you did to install

{% tabs %}
{% tab title="One-line installation" %}

```sh
curl -sSfL https://agent.datafy.io/uninstall-k8s\?version=$VERSION | sh
```

{% hint style="info" %}
You can check which version is installed on your cluster by checking the image tag of the `datafy-installer` DaemonSet
{% endhint %}
{% endtab %}

{% tab title="Helm chart installation" %}

```shellscript
helm uninstall datafy-agent --namespace datafy-agent
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Some Datafy components may remain in your cluster as long as volumes that were previously autoscaling exist in the cluster. The components will remove themselves once all previously autoscaling volumes are deleted from the cluster. For details, see [AutoScaler on Kubernetes — Uninstalling](/how-it-works/autoscaler-on-kubernetes.md#uninstalling).
{% endhint %}

## Remove IAM Role

After uninstallation, the IAM role configured during the [initial setup](/set-up-and-installation/datafy-installation/permissions-configuration.md) should be removed. This can be done in one of the following ways:

1. Remove the ARN from the Permission section of the [account settings](https://app.datafy.io/settings).
2. Delete the role from your AWS account, by deleting the CloudFormation stack or Terraform module.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datafy.io/set-up-and-installation/uninstalling-datafy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
