issue sumary
I specificed datadir
in conf file and run bitcoind with -conf
option, but data is writing to default ~/.bitcoin
dir , not the dir I want
steps to reproduce
bitcoind version 0.17.1
0root@MNG-BC ➜ .bitcoin bitcoind --version
1Bitcoin Core Daemon version v0.17.1.0-gef70f9b52b851c7997a9f1a0834714e3eebc1fd8
step1: configrations
bitcoind conf file path /root/.bitcoin/bitcoin.conf
datadir for testnet : datadir=/mnt/data/bitcoin
0# [core]
1# Specify the location of the configuration file. To use non-default location, create a default location config file containing this setting.
2conf=/root/.bitcoin/bitcoin.conf
3
4# [debug]
5# Enable debug logging for all categories.
6#debug=1
7# Log IP Addresses in debug output.
8#logips=1
9# Run this node on the Bitcoin Test Network.
10#testnet=1
11
12# [rpc]
13# Accept command line and JSON-RPC commands.
14server=1
15# Accept public REST requests.
16rest=1
17# RPC user
18rpcuser=rpcuser
19# RPC password
20rpcpassword=rpcpass
21# RPC allow ip (allow all)
22rpcallowip=0.0.0.0/0
23# RPC bind
24#rpcbind=127.0.0.1
25# get all transaction
26txindex=1
27
28
29# [Sections]
30# Most options automatically apply to mainnet, testnet, and regtest networks.
31# If you want to confine an option to just one network, you should add it in the relevant section.
32# EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
33# only apply to mainnet unless they appear in the appropriate section below.
34
35# Options only for mainnet
36[main]
37# datadir
38datadir=/mnt/data/bitcoin/mainnet
39# Listen for incoming connections on non-default port.(default: 8333 or testnet: 18333)
40port=8333
41# RPC port(default:8332 or testnet:18332)
42rpcport=8332
43
44# Options only for testnet
45[test]
46# datadir
47datadir=/mnt/data/bitcoin
48# Listen for incoming connections on non-default port.(default: 8333 or testnet: 18333)
49port=18333
50# RPC port(default:8332 or testnet:18332)
51rpcport=18332
52
53# Options only for regtest
54[regtest]
step2 : run bitcoind
run bitcoind with below command
0bitcoind -conf=/root/.bitcoin/bitcoin.conf -testnet=1
step3 : check the data
expected all the data write to /mnt/data/bitcoin/testnet3
but actually block data is been wroted to /root/.bitcoin/
0drwx------ 2 root root 4096 Apr 4 16:51 blocks
1drwx------ 3 root root 4096 Apr 4 16:51 testnet3
more info about the contents in /root/.bitcoin
0root@MNG-BC ➜ .bitcoin du --max-depth=1 -h
11.1G ./testnet3
24.0K ./blocks
31.1G .
4root@MNG-BC ➜ .bitcoin cd testnet3
5root@MNG-BC ➜ testnet3 ls
6blocks
7root@MNG-BC ➜ testnet3 cd blocks
8root@MNG-BC ➜ blocks ls
9blk00000.dat blk00001.dat blk00002.dat blk00003.dat blk00004.dat blk00005.dat blk00006.dat blk00007.dat index rev00000.dat rev00001.dat rev00002.dat rev00003.dat rev00004.dat rev00005.dat rev00006.dat rev00007.dat
question
Why datadir is not taken effect in conf? Is it a bug or my conf is wrong? Should I specific -datadir
option in the command line?