Bitzuma

Moving the Bitcoin Core Data Directory

By Rich Apodaca | Updated

Bitcoin Core runs as a full network node and maintains a local copy of the block chain. This data independence improves wallet privacy and security. Unlike some SPV wallets that leak addresses to peers, Bitcoin Core stores all transactions locally. With local access to the complete set of headers and transactions, Bitcoin Core can use full verification to tell when peers lie about payments.

However, dealing with the block chain comes at a price. An ever-growing data set causes smaller hard drives to fill up quickly. Furthermore, a new wallet can’t be used until the full block chain is downloaded and processed, which can take several hours on mid-range equipment.

These problems can be solved by moving and copying Bitcoin Core’s data directory. This article describes two approaches that can be used with either a new or existing Bitcoin Core 0.10.0 installation.

Wallet Back Up

Although the procedures described here have been tested several times, Murphy’s law can strike at any time. To protect yourself from loss of funds, make a backup of your wallet now. Start Bitcoin Core and select the File -> Backup Wallet… option. After the backup has been saved, exit Bitcoin Core.

Find the Default Data Directory

If your data directory already contains a complete block chain and or/wallet, you may want to move it rather than start from scratch. The first step is finding the default data directory. Mac, Windows, and Linux version of Bitcoin Core each store data in a different location. The procedure described here will use a graphical file browser to find it.

On Windows 7, begin by clicking on the Windows menu. Then click your username from the right-hand menu. Windows Explorer should show a folder containing other folders such as Contacts and Desktop. Another folder, AppData is hidden by default. It can be shown by selecting the Organize -> Folder and Search options menu. From the View tab, click the “Show hidden files, folder, and drives” option, then click “OK”.

Windows Show Hidden Files

Windows Explorer should now display an AppData folder. Double click it. Then enter the Roaming folder, where the Bitcoin folder is contained.

Windows Explorer Data Directory

On OS X, open a file browser by selecting the File -> New Finder Window menu option while running Finder. Next, select the Go -> Go to Folder… menu option. Enter ~/Library into the box and press enter. Double click on the Application Support folder. If you’ve already run Bitcoin Core, you will see a folder called Bitcoin.

Finder Data Directory

On Ubuntu, open a file browser by clicking on the folder icon in the launcher. The data directory, .bitcoin, is hidden by default. To show it, select the View -> Show Hidden Files menu option.

Nautilus Data Directory

Copy the Data Directory

Having found the default data directory, we can now copy it. Be sure that Bitcoin Core has been shut down and is no longer running. The software occasionally takes a minute or two to completely exit.

Begin by renaming the Bitcoin Core data directory. Use the name bitcoin-backup. Don’t move the renamed folder. This allows recovery of the original data directory in case something goes wrong. To recover the original, reinstate the original name of the bitcoin-backup folder (either Bitcoin or .bitcoin).

If you’d rather not change the default data directory, you may be able to use the alternative approach described below.

Next copy the renamed bitcoin data directory to a destination of your choice. This can be the same hard drive, an external hard drive, or a removable medium such as USB drive or SD card. Copying data may require only a few minutes or a couple of hours, depending on how up-to-date your copy of the block chain is and the speed of your hardware.

You can now rename the copied folder. For example, it might be convenient to use the name Bitcoin.

Restart Bitcoin Core

If you plan to run Armory on Mac, skip this step.

With no default data directory, Bitcoin Core assumes that this is its first session. Launching Bitcoin Core should yield a welcome screen. This screen gives you to option to store data in the default location or a custom location. Select the second option. Then Click the “…” button to point to the new location of the Bitcoin Core data directory.

Choose Data Directory

Bitcoin Core should continue starting up. When the process completes, the software should work exactly as it did before. When ready to proceed to the next step, close the application.

Delete the Original Data Directory

At this point your system contains two more or less identical copies of the data directory. Assuming there were no issues with the move, the original can now be deleted. Browse to the location of the bitcoin-backup directory and delete it.

Mac and Armory

Users of Armory on Mac face a tricky problem when trying to move the Bitcoin Core data directory. Armory only recognizes the default data directory on OS X. Moving it means that Armory will no longer function.

Fortunately, the solution is relatively simple. Create a symbolic link from the new data directory to the old default directory. Creating this link allows the new data directory to be used as if it still resided at the old location. Although creating a shortcut through the Finder seems like it should work, it doesn’t.

Begin by launching the Terminal application. This is most conveniently done by pressing ⌘-space, then typing the word “terminal” into the search box. Enter the following command at the prompt to create the symbolic link, where {newpath} is the path to the new data directory. For example, if you moved the data directory to a folder called Bitcoin on the external drive called “Bigdata”, then replace {newpath} with /Volumes/Bigdata/Bitcoin.

$ ln -s {newpath} ~/Library/Application\ Support/Bitcoin
$ foo bar

The backslash after “Application” is required.

Another Option: Command Line Parameter

Instead of pulling the data directory out from under Bitcoin Core and then supplying a new path after startup, the data directory can be passed as the command line parameter datadir. This approach keeps the existing default data directory intact. It also allows multiple data directories to be used side-by-side. The disadvantages are that this method requires some extra configuration, and it won’t work easily on OS X.

Windows users can create a shortcut that uses the command line option datadir. Doing so directs Bitcoin Core to use, not the default data directory, but the one given as a parameter.

Begin by right-clicking on the desktop and selecting New -> Shortcut. Browse to the location of the Bitcoin Core executable (C:\Program Files\Bitcoin\bitcoin-qt.exe) and click the OK button. Next, add the command line option datadir, using the path to your data directory.

Windows Shortcut

Double clicking the newly-created shortcut will direct Bitcoin Core to use the new data directory.

Ubuntu users can create a desktop shortcut by first browsing to the /usr/share/applications directory. Right-click on the Bitcoin file, then select the “Copy” option. Right click on the desktop and select “Paste”. This places a shortcut on the desktop. To direct this shortcut use the datadir option, right click, select “Properties”, then replace the command field with bitcoin-qt -datadir={path}, where {path} is the fully qualified path to the new data directory. Double clicking the resulting shortcut starts Bitcoin Core with the custom data directory.

Ubuntu Shortcut

Although a similar shortcut-based approach will work on OS X, creating a clickable icon is much more difficult.

Conclusions

Moving the Bitcoin Core data directory can be helpful in two situations:

  1. freeing up disk space on a cramped hard drive
  2. rapidly bringing up a new node by copying an existing data directory

The procedures outlined here can be used in either case.