GETH — ‘Pruning’ your database

Lex Luther
3 min readApr 26, 2021

--

‘Snapshot Offline Pruning’ to reclaim diskspace on a StrongBlock ETH Node

A fresh installation of GETH currently takes about 350GB of space using a fast/snap sync, and then it continues to grow by roughly an additional 10GB per week. Since most BYoN node operators are using the Contabo L package, many nodes are quickly approaching their full disk capacity.

This tutorial will walk you through the steps to ‘prune’ and compact your chaindata database. By doing so, you should be able to effectively get back to a disk size of roughly 350GB.

While these instructions have been specifically written for those who have used the StrongBlock GETH installation instructions, I have included notes for those who may have used alternative means to install their GETH node.

Prerequisites

The following assumes that you are using either Ubuntu 18.04 or 20.04

Free diskspace of 50GB

GETH 1.10.x installed and fully synced

GETH has completed a snapshot

Instructions (type the BOLD commands)

  1. Log into your VPS unit using your user (not root)
  2. sudo apt update && sudo apt upgrade -y (Let’s get your stuff up to date)

3. df -h (Let’s ensure you have at least 50GB of free diskspace left)

4. sudo systemctl stop geth (Takes a minute. GETH is stopped to prune.)

5. sudo apt install tmux -y (Installs TMUX, the terminal emulator)

6. tmux new -s prune (Opens a new session named ‘prune’ )

The pruning process needs to run, without interruption, or risk of being stopped if PUTTY is closed or the connection lost. To achieve this, we will use TMUX which will allow the process to run in the background.

To keep TMUX running in the background, but return to the standard VPS command line, press ‘ctrl-b then d’ (think of ‘d’ for detach)

To return to your TMUX session, type ‘tmux attach

7. sudo -u $USER geth snapshot prune-state

If you are preforming this process on a installation other than for a StrongBlock node, you may need to alter step #7.

First, ensure that the user you are currently logged in as is the user that installed and initiated GETH, or replace ‘$USER’ with that username.

Second, add the chain directory information to the end of the above command…

--sudo -u $USER geth snapshot prune-state --datadir /my/data/dir

Pruning and compacting the database will take several hours to complete, and occurs in multiple stages. During the ‘compacting database’ phase your system may appear to get ‘stuck’ for over an hour after a few entries. This is typical, allow time for it to complete.

If you like, you may “detach’ from this TMUX session, and return later to check on its progress. This will allow you to close PUTTY, and still not interrupt the pruning process. To detach, simply press ‘ctrl-b, then d

Once you have received confirmation the process is complete, then we must close out of TMUX, and restart GETH. GETH will then need to catch up and sync…

8. exit (while in TMUX. This will close the current session)

9. df -h (This will show you how much space is used/free on your VPS now)

10. sudo systemctl start geth (Back at PUTTY command line, starts GETH)

11. Congrats! You have now pruned your database…. You are finished.

If you find you need to upgrade to a larger package, use the link below to visit the Contabo website for current deals.

Visit the site to see what current deals are running

--

--

No responses yet