I was able to migrate my data without any apparent issues. Instead of copying, I used rsync, which is a safer alternative.
Here's what I did:
Step 1: Create a new directory on the new drive to store your indices:
Step 2: Disable shard allocation.
When you shut down a node, the allocation process waits for index.unassigned.node_left.delayed_timeout (by default, one minute) before starting to replicate the shards on that node to other nodes in the cluster, which can involve a lot of I/O. Since the node is shortly going to be restarted, this I/O is unnecessary. You can avoid racing the clock by disabling allocation before shutting down the node:
Step 3: Stop indexing and perform a synced flush.
Performing a synced-flush speeds up shard recovery.
You will likely need to stop Logstash or Winlogbeat from sending events to Elasticsearch to stop the failed status codes:
systemctl stop logstash.
When you perform a synced flush, check the response to make sure there are no failures. Synced flush operations that fail due to pending indexing operations are listed in the response body, although the request itself still returns a 200 OK status. If there are failures, reissue the request.
Step 4: Stop Elasticsearch:
systemctl stop elasticsearch
Step 5: Copy your indices to the new location:
rsync --info=progress2 -auvrz /var/lib/elasticsearch /apps/elasticsearch
or using copy (not recommended)
cp -RP * /apps/elasticsearch
Step 6: Change the ownership on copied files and directorys to
chown -R elasticsearch:elasticsearch /apps/elasticsearch
This step is only necessary when using the copy command.
Step 7: Change the
path.data location in
elasticsearch.yml using your favorite editor:
If you have multiple locations where you're storing indices, you can use the following syntax:
Step 9: Start Elasticsearch:
systemctl start elasticsearch
Step 10: Reenable allocation.
When all nodes have joined the cluster and recovered their primary shards, reenable allocation by restoring cluster.routing.allocation.enable to its default:
Once allocation is reenabled, the cluster starts allocating replica shards to the data nodes. At this point it is safe to resume indexing and searching, but your cluster will recover more quickly if you can wait until all primary and replica shards have been successfully allocated and the status of all nodes is green.
It will take several minutes (or longer) depending on how many documents you have stored in your indices.
More information on this can be found on the following documentation pages: