Author Topic: *Dramatically* increase blockchain sync speed (Linux, Windows too in theory)  (Read 1827 times)

Offline maplesyrupghost

Okay I saw this on Reddit, seems like a sure-fire way to increase the sync speed of the blockchain.  It can work in Windows, too, because Windows supports ramdisks, but this here is a Linux trick. 

Not sure if it's common knowledge, but you can *dramatically* increase blockchain sync speed (at least on Linux) by putting blkindex.dat in a ramdisk.

Here's a script I wrote that I use when there's more than a few days worth of blocks to sync. I run it, wait for it to sync, then I close bitcoin-qt and start it again normally. The script is very simple and stupid, so please don't use it unless you understand what it does. Also make sure you have at least 1.5 GB of free memory.

Code: [Select]
#!/bin/bash

#console version:
#sudoapp=sudo
#moveapp=mv

#KDE version:
sudoapp="/usr/bin/kdesudo"
moveapp="/usr/bin/kioclient move"

cd ~/.bitcoin
indexsize=$(stat -c%s blkindex.dat)
indexsize=$(expr $indexsize + 1024 \* 1024 \* 200)

$sudoapp sh -c "mkdir -p /mnt/btctmp && chmod 777 /mnt/btctmp && mount -t tmpfs -o size=$indexsize btctmp /mnt/btctmp"
$moveapp blkindex.dat /mnt/btctmp/
ln -s /mnt/btctmp/blkindex.dat ./

bitcoin-qt

if ! [ -h blkindex.dat ]
    then
    echo "Something's wrong, bailing out."
    exit
fi

rm blkindex.dat
$moveapp /mnt/btctmp/blkindex.dat ./

if ! [ -f blkindex.dat ]
    then
    echo "Something's wrong, bailing out."
    exit
fi

$sudoapp umount btctmp
BitcoinTrading.com founder