Limit the disk space consumed by Bitcoin Core nodes on Linux

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

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
prune=1000

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.