23

I am trying to do a fast sync using geth --fast but I am getting this message:

blockchain not empty, fast sync disabled

How can I empty the blockchain to allow for fast sync?

eth
  • 85,679
  • 53
  • 285
  • 406
Randomblue
  • 2,610
  • 2
  • 17
  • 38

4 Answers4

16

To remove your blockchain with geth, run: geth removedb
Then:

Use --fast but you probably also need --cache=1024 (and --jitvm may also help). Without it, you are running with the default which is --cache=16.

A 50% speed increase is possible just by increasing the cache.

If you are starting from the beginning, use: geth --fast --cache=1024 --jitvm

Depending on your RAM, you can also try with higher values, like --cache=2048.

NOTE: The number after --cache= is the amount of memory allocated to the task of downloading the blockchain!!

Source

Ismael
  • 30,570
  • 21
  • 53
  • 96
Astad
  • 478
  • 3
  • 9
  • 3
    Note this should now be geth removedb (no dash) – Derek May 31 '17 at 13:31
  • Is there a way to do this while geth --fast is already running? I want to leave it running long-term to answer RPC requests but don't want it to eat up my disk. – sudo Apr 07 '18 at 20:45
  • I mean a safe way. You can run geth removedb in a separate shell while geth --fast is running. I didn't have any problems doing this then sending a few xacts after, but I don't know if it's safe. Docs say nothing. – sudo Apr 07 '18 at 20:56
9

The default datadir is:

Mac: ~/Library/Ethereum
Linux: ~/.ethereum
Windows: %APPDATA%/Ethereum

Delete the chaindata subdirectory that you find.

Run geth --fast --cache=1024 for a recommended way to sync the chain quickly (don't forget to use a bigger --cache with a value like 1024, otherwise the default is 16, and it won't sync as quickly).

EDIT: Running geth removedb is the simplest way to delete the blockchain in Geth.

eth
  • 85,679
  • 53
  • 285
  • 406
6

If you have your blockchain partially or fully imported while starting geth, then using the --fast flag is ignored (the flag is disabled). To use the --fast flag you have to remove all of the data from your chaindata folder.

romanoza
  • 893
  • 1
  • 8
  • 17
  • 1
    Will starting fresh with --fast take less time than updating from the stored data? At what point would you say it's worth it? – TinyTimZamboni Jul 18 '17 at 02:58
1

use

geth --fast --cache=2048

it seems at least Mac does not provide the other options under go1.9.2:

flag provided but not defined: -jitvm
Dennis Ng
  • 111
  • 2
  • 1
    This is an old question (March 2016), early iterations of the --fast flag didn't allow restarting geth until it finished syncing, if you did restart it will switch to full mode. – Ismael Jan 12 '18 at 03:16