user120: Since I have been tearing down and setting up bitcoin clients a lot for some experiments lately, I was wondering whether there is a simple way to speed up the synchronization with the network. One method that comes to mind is the bootstrap.dat file distributed by some people. The problem is that the last 40'000 blocks, which are the most expensive to get and verify, are not included.
Now I was wondering how to create such a bootstrap.dat myself, from a good copy I have on another machine. Any idea?

user14381: Making your own bootstrap.dat is fairly simple. In windows, drop to your command prompt and use the following command. 
Copy /b blk00000.dat+blk00001.dat+blk00002.dat bootstrap.dat

You'll want to keep going with the + blk*.dat files until you reach the last one. To make things easier for you, just run a batch file which can take care of adding them all without having to input each blk*.dat file. Simply copy and paste the code below into a text file and name it something like Create_Bootstrap.cmd and run it from your /blocks folder.
@echo off 
setlocal enableDelayedExpansion 

set BITCOINDIR=%APPDATA%\bitcoin\blocks
for /F %%x in ('dir /B/D/ON %BITCOINDIR%\blk*.*') do (
  IF NOT [!B!] == [] set B=!B!+
  set FILENAME=%BITCOINDIR%\%%x
  set B=!B!"!FILENAME!"
)
copy /b %B% bootstrap.dat

or just use "copy /b blk*.dat bootstrap.dat" 

user18471:  From Mac

Open terminal
Go to the folder where the blocks are. In this
case Bitcoin's folder (it's the same for other bitcoin forks)
cd "Library/Application Support/Bitcoin/blocks/"

Run this code that will concatenate all the blk files. Make sure to include all the numbered
blocks you find on your Bitcoin's folder. In this case there are 4
cat blk000*.dat > bootstrap.dat

Done.


user4358: The block files are in the same format as the bootstrap file. Their format is really simple: just concatenate all blocks after prefixing them by the network number (to avoid mixing the testnets) and the block length.
[network number] [length] [block header] [block transactions]
[network number] [length] [block header] [block transactions]
[network number] [length] [block header] [block transactions]
... repeat for all blocks

To create a bootstrap file, all you need to do is to just grab the data from blk00001.dat up to your last block file (here that's blk000054.dat) and put all of it in the bootstrap.dat file, preferably sorted so that it can just import them all in one go without having to swap blocks.
I think you might even be able to just concatenate the block files themselves, as they are already in the right format, and the format supports concatenation.

user33042: Bitcoin Core contains a tool to do this properly (filtering out any orphan blocks, putting everything in the correct order — which will work a lot better than just concatenating the block files. It's documented in its own README, here: https://github.com/bitcoin/bitcoin/tree/master/contrib/linearize
In short:

Launch Bitcoin with an rpcuser and rpcpassword set in your config file, with the correct location as per https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File
Checkout the Bitcoin source from Github and cd to contrib/linearize.
Copy example-linearize.cfg to linearize.cfg and update it with your rpcuser/rpcpassword values, along with the maximum block height you want to output (max_height), and the path to your data directory (input), as well as the path to your desired output file (output_file).
Run ./linearize-hashes.py linearize.cfg > hashlist.txt followed by ./linearize-data.py linearize.cfg.


120: <p>Since I have been tearing down and setting up bitcoin clients a lot for some experiments lately, I was wondering whether there is a simple way to speed up the synchronization with the network. One method that comes to mind is the <code>bootstrap.dat</code> file distributed by some people. The problem is that the last 40'000 blocks, which are the most expensive to get and verify, are not included.</p>

<p>Now I was wondering how to create such a <code>bootstrap.dat</code> myself, from a good copy I have on another machine. Any idea?</p>
 14381: <p>Making your own bootstrap.dat is fairly simple. In windows, drop to your command prompt and use the following command. </p>

<pre><code>Copy /b blk00000.dat+blk00001.dat+blk00002.dat bootstrap.dat
</code></pre>

<p>You'll want to keep going with the + blk*.dat files until you reach the last one. To make things easier for you, just run a batch file which can take care of adding them all without having to input each blk*.dat file. Simply copy and paste the code below into a text file and name it something like Create_Bootstrap.cmd and run it from your /blocks folder.</p>

<pre><code>@echo off 
setlocal enableDelayedExpansion 

set BITCOINDIR=%APPDATA%\bitcoin\blocks
for /F %%x in ('dir /B/D/ON %BITCOINDIR%\blk*.*') do (
  IF NOT [!B!] == [] set B=!B!+
  set FILENAME=%BITCOINDIR%\%%x
  set B=!B!"!FILENAME!"
)
copy /b %B% bootstrap.dat
</code></pre>

<p>or just use "copy /b blk*.dat bootstrap.dat" </p>
 18471: <p> From Mac</p>

<ol>
<li>Open terminal</li>
<li><p>Go to the folder where the blocks are. In this
case Bitcoin's folder (it's the same for other bitcoin forks)</p>

<pre><code>cd "Library/Application Support/Bitcoin/blocks/"
</code></pre></li>
<li><p>Run this code that will concatenate all the blk files. Make sure to include all the numbered
blocks you find on your Bitcoin's folder. In this case there are 4</p>

<pre><code>cat blk000*.dat &gt; bootstrap.dat
</code></pre></li>
<li><p>Done.</p></li>
</ol>
 4358: <p>The block files are in the same format as the bootstrap file. Their format is really simple: just concatenate all blocks after prefixing them by the network number (to avoid mixing the testnets) and the block length.</p>

<pre><code>[network number] [length] [block header] [block transactions]
[network number] [length] [block header] [block transactions]
[network number] [length] [block header] [block transactions]
... repeat for all blocks
</code></pre>

<p>To create a bootstrap file, all you need to do is to just grab the data from <code>blk00001.dat</code> up to your last block file (here that's <code>blk000054.dat</code>) and put all of it in the <code>bootstrap.dat</code> file, preferably sorted so that it can just import them all in one go without having to swap blocks.</p>

<p>I <em>think</em> you might even be able to just concatenate the block files themselves, as they are already in the right format, and the format supports concatenation.</p>
 33042: <p>Bitcoin Core contains a tool to do this properly (filtering out any orphan blocks, putting everything in the correct order — which will work a lot better than just concatenating the block files. It's documented in its own README, here: <a href="https://github.com/bitcoin/bitcoin/tree/master/contrib/linearize" rel="noreferrer">https://github.com/bitcoin/bitcoin/tree/master/contrib/linearize</a></p>

<p>In short:</p>

<ol>
<li>Launch Bitcoin with an <code>rpcuser</code> and <code>rpcpassword</code> set in your config file, with the correct location as per <a href="https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File" rel="noreferrer">https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File</a></li>
<li>Checkout the Bitcoin source from Github and <code>cd</code> to <code>contrib/linearize</code>.</li>
<li>Copy <code>example-linearize.cfg</code> to <code>linearize.cfg</code> and update it with your <code>rpcuser</code>/<code>rpcpassword</code> values, along with the maximum block height you want to output (<code>max_height</code>), and the path to your data directory (<code>input</code>), as well as the path to your desired output file (<code>output_file</code>).</li>
<li>Run <code>./linearize-hashes.py linearize.cfg &gt; hashlist.txt</code> followed by <code>./linearize-data.py linearize.cfg</code>.</li>
</ol>
