ethereum, split the data directory

Viewed 962

I am currently running geth mist on Linux with an SSD and would like to move some (or all) of the chain data to an external drive to conserve space.

I understand there is a command line option to move the data directory:

geth --datadir <path to data directory>

My concerns are

  1. Will implementing this now slow syncing due to the external drive being much slower than my internal SSD?
  2. Will it cause a re-sync of the entire blockchain?

Currently, I run the following script on my bitcoin blocks directory and it avoids both of those issues by keeping high throughput data on the SSD and moving large, but less frequently accessed data, to the external drive.

#!/bin/bash
set -e
BLK_TARGET=/mnt/ssd/core/blocks #Replace with your destination, no trailing slash

find . -name '*.dat' -type f -printf '%f\n' > tomove
while read line; do
    echo $line
    mv "$line" "$BLK_TARGET/$line"
    ln -s "$BLK_TARGET/$line" "$line"
done <tomove
rm tomove
echo Done

When I tried similar on the Ethereum Network it triggered a re-sync of the entire chain.

Can anyone recommend a similar process for Ethereum's geth client or appease my two concerns?

Current directory sizes on my SSD are:

:~$ du -sh .ethereum/*
37G .ethereum/geth
0   .ethereum/geth.ipc
12K .ethereum/history
28K .ethereum/keystore
2 Answers

External SSDs tend to be significantly slower than internal. (Internal SSDs come in two main categories, SATA and NVMe, and while NVMe is significantly faster than SATA, SATA is still significantly faster than external.) As of mid-2019 I had difficulty syncing the chain with an external drive that could manage 150 MB read/write, though there are much faster external drives.

(If you'd like a guide to speed checking your external drive, this article goes through how to in section 7 ('Disk Performance Checkpoint').)

Assuming that you do still want to set up Geth to write to the external drive, if you run geth --datadir /path/to/external/drive, and the chaindata folder in the new location is empty, then Geth will begin syncing from the beginning of the chain. There's a simple way to avoid this problem, though: you can simply copy the chaindata from the internal drive onto the external drive. (This will take some time, but far, far less than syncing the chain.) I would recommend copying, and only deleting the old chaindata after you see that Geth is cooperating with the new location; you wouldn't want to discover that your new chaindata has issues without having a backup.

Related