So, I have an ETH2 validator node which uses a Hetzner AX41 dedicated server and has been running since genesis. The set-up includes a GETH ETH1 node, beacon chain and the ETH2 Validator (Prysm) and is slowly using the allocated 1TB NVMe disk space (2 x 512GB using RAID 0). I contacted the Prysm Discord channel to seek advice on what best to do. An amiable chap replied, and I thought it helpful to share in case anyone else has the same challenge.
I came across a Reddit post that used the first method suggested by Discord, although using a Geth Service method. This is the approach I followed, and it was very simple to implement. Notes below...
A simple way to prune GETH disk space
Beacon-node set-up #Set-up Beacon-chain failover for infura.iofree oralchemy.io free.#Prylabs fallback eth1 nodes documentation.http-web3provider: http://localhost:8545fallback-web3provider:- https://mainnet.infura.io/v3/YOUR-PROJECT-ID- https://eth-mainnet.alchemyapi.io/v2/YOUR-PROJECT-ID #Restart Beacon-nodesudo service beacon-node restart #Check Beacon-node service statussudo service beacon-node status #Check Beacon-node service logs for activitysudo journalctl -fu beacon-node
Geth node pruning #Check location of Geth working directorycat /etc/systemd/system/geth.service #Get current size of GETH data locationdu -sh <WorkingDirectory> #Stop Gethsudo service geth stop #Change Service to Prunevi /etc/systemd/system/geth.service[Comment out existing ExecStart using a #]#ExecStart=/usr/bin/geth blah blah blah[Add new ExecStart to prune]ExecStart=/usr/bin/geth snapshot prune-state #Reload Service configsudo systemctl daemon-reload #Start Geth Pruningsudo service geth start #Check Geth service statussudo service geth status #Check Geth service logs for pruning activitysudo journalctl -fu gethLogs should look something like this and can take up to 4 hours to complete…
Once pruning and dB compacting have finished... #Stop Geth in Pruning modesudo service geth stop
#Change Service back to normal (comment out the Prune exec line) vi /etc/systemd/system/geth.service[Uncomment the normal ExecStart removing the #]ExecStart=/usr/bin/geth blah blah blah[Comment out the ExecStart to prune with an #]#ExecStart=/usr/bin/geth snapshot prune-state #Reload Service configsudo systemctl daemon-reload #Start Geth in normal modesudo service geth start #Check Geth service statussudo service geth status #Check Geth service logs for normal activitysudo journalctl -fu geth #Check the current size of GETH data locationdu -sh <WorkingDirectory>
Boom!
Useful commands
If you encounter any errors during the pruning, then you may wish to consider starting a fresh and removing the Geth chain data. There is a formal and easy way to remove the data and start again, but sometimes Geth can get mixed up if a previous Geth has been running and created multiple chain data folders. In this scenario, you can manually remove the folder and Geth will sync from day one.
NB: Geth working directory when running within a service is typically "/home/geth/"
The formal removal of Geth Chaindata
#Stop Geth in normal modesudo service geth stop #Remove Geth database (chaindata) NB: Ensure that the prompted Geth working directory is what you expect it to be. If its not, then you may consider the informal method for removing the Geth chaindata.geth removedb #Start Geth in normal modesudo service geth start #Check Geth service logs for normal activitysudo journalctl -fu geth #Check current size of GETH data locationdu -sh <WorkingDirectory>
Boom!
Informal removal of Geth Chaindata
#Stop Geth in normal modesudo service geth stop #manually remove Geth database (chaindata) NB: Ensure the correct path is used for the Geth working directory (/home/geth/ used in this examplesudo rm -rf /home/geth/.ethereum/geth/chaindata/ #Start Geth in normal modesudo service geth start #Check Geth service logs for normal activitysudo journalctl -fu geth #Check current size of GETH data locationdu -sh <WorkingDirectory>