Limit the disk space consumed by Bitcoin Core nodes on Linux

Oh Dear! monitors your entire site, not just the homepage. We crawl and search for broken pages and mixed content, send alerts when your site is down and notify you on expiring SSL certificates.

Start your free 10 day trial! »

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.

Will you help me share this post?

It would mean a lot to me if you could help share this post on social media. 🤗