Limit the disk space consumed by Bitcoin Core nodes on Linux

Profile image of Mattias Geniar

Mattias Geniar, February 25, 2019

Follow me on Twitter as @mattiasgeniar

If you run a Bitcoin Core node, by default it will download the entire blockchain on startup and keep a list of every block & transaction. If you’re limited in diskspace, you can instruct the Bitcoin Code daemon to limit the amount of storage the blockchain will take up.

I’ll assume the Bitcoin Core blockchain is being kept at /home/bitcoin/.bitcoin/. If you run your node as a different user, look for the .bitcoin hidden directory in your home directory.

In there, either a bitcoin.conf file already exists, or you can create one.

To limit the amount of diskspace being consumed, set the prune directive.

$ cat /home/bitcoin/.bitcoin/bitcoin.conf

The prune= accepts as a parameter the size in MB’s that you want to keep. This example above limits the blockchain to 1GB (= 1000MB).

There’s a caveat to limiting the diskspace those, as explained by the manual;

-prune=n: This mode is incompatible with -txindex and -rescan. Warning: Reverting this
setting requires re-downloading the entire blockchain. (default: 0 = disable pruning blocks,
1 = allow manual pruning via RPC, >550 = automatically prune block files to stay under the
specified target size in MiB)

It makes sense, too: if the entire blockchain isn’t present on the local disk, you also can’t use all the tools that require the local blockchain to be complete.

Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.