# Delete data folder

**URL:** <https://discuss.elastic.co/t/delete-data-folder/144307>\
**Category:** Elasticsearch\
**Created:** [August 14, 2018, 9:07am UTC](https://discuss.elastic.co/t/delete-data-folder/144307 "2018-08-14T09:07:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raghuveer\_SJ](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@Raghuveer\_SJ](https://discuss.elastic.co/u/Raghuveer_SJ)\
**Post date:** [August 14, 2018, 9:07am UTC](https://discuss.elastic.co/t/delete-data-folder/144307/1 "2018-08-14T09:07:55Z")

</div>

I am experimenting, I got some bad data loaded on to elasticsearch so thought to reload and deleted the `path.data` folder. The command `rm -rf *` removed many things but

```
ls: cannot access global-12.st: No such file or directory
ls: cannot access node-0.st: No such file or directory
total 0
?????????? ? ? ? ? ? global-12.st
?????????? ? ? ? ? ? node-0.st

```

I am unable to chown also. Please help me to delete these folders.

Also tried to restart elasticsearch thinking it could have a temporary status. But elasticsearch didn't start and threw following exception :

```
org.elasticsearch.bootstrap.StartupException: ElasticsearchException[java.io.IOException: failed to read [id:0, legacy:false, file:/home/elk/elasticsearch/data/nodes/0/_state/node-0.st]]; nested: IOException[failed to read [id:0, legacy:false, file:/home/elk/elasticsearch/data/nodes/0/_state/node-0.st]]; nested: NoSuchFileException[/home/elk/elasticsearch/data/nodes/0/_state/node-0.st];
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.3.2.jar:6.3.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.3.2.jar:6.3.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.3.2.jar:6.3.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.3.2.jar:6.3.2]
Caused by: org.elasticsearch.ElasticsearchException: java.io.IOException: failed to read [id:0, legacy:false, file:/home/elk/elasticsearch/data/nodes/0/_state/node-0.st]
```

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [August 14, 2018, 10:29am UTC](https://discuss.elastic.co/t/delete-data-folder/144307/2 "2018-08-14T10:29:20Z")

</div>

> [@Raghuveer\_SJ](#):
>
> got some bad data loaded on to elasticsearch so thought to reload and deleted the `path.data` folder.

You should never delete the **path.data** directory from an active Elasticsearch installation, that will likely cause data loss. The only time I've done so is when I've stopped all nodes to install a new cluster and don't want any old data to remain. The **path.data** directory is both where your data resides but also the cluster state.

If you want to erase "bad data" you should instead do a [Delete Index](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html) on the "bad" index. That way you leave the data directory, with its system indices and cluster information, safe and untouched.

I'm not sure what happened in your situation but I would probably start from scratch and install a new copy of Elasticsearch, erasing all traces of the old, broken one.

---

<div class="post-metadata">

**Author:** ![Raghuveer\_SJ](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@Raghuveer\_SJ](https://discuss.elastic.co/u/Raghuveer_SJ)\
**Post date:** [August 14, 2018, 10:31am UTC](https://discuss.elastic.co/t/delete-data-folder/144307/3 "2018-08-14T10:31:15Z")

</div>

What I did was use a different path for the data. But just wondering if we can delete it as production should not have junk in it.

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [August 14, 2018, 10:40am UTC](https://discuss.elastic.co/t/delete-data-folder/144307/4 "2018-08-14T10:40:44Z")

</div>

Oh, I see. Well, if you've changed the value of **path.data** and restarted the node so that it uses the new path, the old data directory is just like any other directory and can be deleted.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 11, 2018, 10:40am UTC](https://discuss.elastic.co/t/delete-data-folder/144307/5 "2018-09-11T10:40:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
