A. You need to move the elasticsearch folder, i.e. that’s the folder which bears the same name as your cluster.name configured in the elasticsearch.yml file.
B. You need to modify the path.data setting in the elasticsearch.yml file to the new folder you’ve moved the data to.
So, say you are currently using /var/lib/elasticsearch and you want to move the data folder to /foo/bar, here is what you need to do:
> mv /var/lib/elasticsearch /foo/bar
Then in elasticsearch.yml modify path.data to:
path.data: /foo/bar
You’ll end up with your data being stored in /foo/bar/elasticsearch instead of /var/lib/elasticsearch. Make sure that the elasticsearch process can access your new folder.