I am going to run a bitcoin core on a Linux server (Ubuntu 20.04). I don't have enough storage to store blockchain data. Therefore, I want to save the data over an NFS server (CentOS release 6.10). However, I get an error when I set the -datadir to the shared folder.

The content of /etc/exports file in the NFS server (I've seen the configuration from here):

/home/storage/  BITCOIN.CORE_IP(rw,sync,no_root_squash,no_subtree_check)

I mounted the remote shared directory in the Ubuntu 20.04 Linux server using the following command:

mount NFS_SERVER_IP:/home/storage/ /root/blockchain/

everything works fine, and the file system disk space usage report is: (df -h)

Filesystem                   Size  Used Avail Use% Mounted on
NFS_SERVER_IP:/home/storage/  1.0T  682M  1.0T   1% /root/blockchain

After running the following command to change the data directory to the shared directory:

./bitcoin-0.20.0/bin/bitcoind -datadir=/root/blockchain

I get the following error:

Error: Cannot obtain a lock on data directory /root/blockchain. Bitcoin Core is probably already running.

I should note that the shared directory is empty before running the bitcoind, then after that, it contains an empty file, which name is .lock. Moreover, If I set the -datadir to any local folder, it will not return any error!


  • Are you running bitcoind under a user with permission to write to that directory? Jul 27, 2020 at 2:23
  • @RaghavSood I run the following command to see what user bitcoind is running as: ` ps -eo user,group,comm |egrep 'bitcoind' |awk '{print "Bitcoin user: " $1}' ` the result is: ` Bitcoin user: root `. I can mkdir and touch under the root user.
    – Taghi
    Jul 27, 2020 at 5:23
  • You might have another bitcoin instance running on the same machine, or on another machine connected to the same shared drive - try stopping all Bitcoin instance, deleting the .lock file (if it still exists), and then starting it again Jul 27, 2020 at 5:31
  • @RaghavSood I have tried this multiple times, but nothing changes :((
    – Taghi
    Jul 27, 2020 at 5:42
  • 1
    Network file systems often don't support the same locking primitives that are expected from local filesystems. Jul 27, 2020 at 21:12

1 Answer 1


In my view, we cannot move LevelDB index files such as chainstate, etc. to an external slow storage.

According to this link, we should only move the blkxxxxx.dat and revxxxxx.dat files to an external storage. These files are inside ${datadir}/blocks/ by default. Since the index directory (${datadir}/blocks/index) contains high i/o-frequency LevelDB index files, moving it to an external storage will increase the initial blockchain synchronization time.

So take the following steps (I followed the instructions of the link):

  1. run bitcoind.

Let it run for a few minutes, or long enough that it has started synchronizing [ref]

  1. Then kill the bitcoind.

  2. Next, Move the "index" folder up one level (so that it may remain on the local storage):

mv -f ~/.bitcoin/blocks/index ~/.bitcoin/
  1. Move the blocks folder to the shared directory:
mv -f ~/.bitcoin/blocks ~/blockchain/
  1. Create a symbolic (soft) link to the local index directory at blocks directory in the shared storage (use absolute path):
ln -s /root/.bitcoin/index /root/blockchain/blocks/index
  1. Now, create a symbolic (soft) link to the blocks directory at .bitcoin in the local storage (again use absolute path)::
ln -s /root/blockchain/blocks/ /root/.bitcoin/blocks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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