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?

up vote 2 down vote accepted

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.

  • 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 Aug 1 '16 at 15:57
  • I don't have an opinion on that. – Nate Eldredge Aug 1 '16 at 16:02
  • @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 Aug 3 '16 at 6:08

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.