How to calculate the size of the blockchain?

0

I want to find the size of the blockchain data. I've been using this Linux command:

du --exclude=index /home/me/.bitcoin/blocks/

Is this the most accurate way to do it? And does dividing the result by 1024/1024 give the size of the blockchain in GBs?

Note: The --exclude=index part excludes the blocks/index/ subfolder, which I've heard is extra metadata used for levelDB to make it faster to search through the blockchain. I just want to know the size of the blockchain data only, so does it make sense to omit this?

inersha

Posted 2016-08-01T15:22:11.950

Reputation: 2 236

Answers

2

du rounds up file sizes to the next multiple of your filesystem's block size. It also includes the sizes of directories. So this will give you a (slight) overestimate.

You really just want to add up the total sizes of all the blk*.dat files. You can get that with

du -c --apparent-size /home/me/.bitcoin/blocks/blk*.dat

You can divide this number by 1000000000 to get GB, or by 1024*1024*1024 to get GiB (note the distinction).

Note that this will still include "orphan" blocks that you downloaded and stored, but that are not part of the main block chain. There isn't any easy way to exclude those, as far as I know.

Nate Eldredge

Posted 2016-08-01T15:22:11.950

Reputation: 21 420

Thanks Nate. I'm going to display the size of the blockchain on a website. In your opinion, would it make more sense to use GB or GiB?inersha 2016-08-01T15:57:19.763

I don't have an opinion on that.Nate Eldredge 2016-08-01T16:02:15.850

@inersha: GiB is less ambiguous. When you write GB, especially in the context of storage capacity some might understand it as 10^9 bytes while others think you mean 2^30.Murch 2016-08-03T06:08:46.267