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
root@MNG-BC ➜ .bitcoin bitcoind --version
Bitcoin 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
# [core]
# Specify the location of the configuration file. To use non-default location, create a default location config file containing this setting.
conf=/root/.bitcoin/bitcoin.conf
# [debug]
# Enable debug logging for all categories.
#debug=1
# Log IP Addresses in debug output.
#logips=1
# Run this node on the Bitcoin Test Network.
#testnet=1
# [rpc]
# Accept command line and JSON-RPC commands.
server=1
# Accept public REST requests.
rest=1
# RPC user
rpcuser=rpcuser
# RPC password
rpcpassword=rpcpass
# RPC allow ip (allow all)
rpcallowip=0.0.0.0/0
# RPC bind
#rpcbind=127.0.0.1
# get all transaction
txindex=1
# [Sections]
# Most options automatically apply to mainnet, testnet, and regtest networks.
# If you want to confine an option to just one network, you should add it in the relevant section.
# EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
# only apply to mainnet unless they appear in the appropriate section below.
# Options only for mainnet
[main]
# datadir
datadir=/mnt/data/bitcoin/mainnet
# Listen for incoming connections on non-default port.(default: 8333 or testnet: 18333)
port=8333
# RPC port(default:8332 or testnet:18332)
rpcport=8332
# Options only for testnet
[test]
# datadir
datadir=/mnt/data/bitcoin
# Listen for incoming connections on non-default port.(default: 8333 or testnet: 18333)
port=18333
# RPC port(default:8332 or testnet:18332)
rpcport=18332
# Options only for regtest
[regtest]
step2 : run bitcoind
run bitcoind with below command
bitcoind -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/
drwx------ 2 root root 4096 Apr 4 16:51 blocks
drwx------ 3 root root 4096 Apr 4 16:51 testnet3
more info about the contents in /root/.bitcoin
root@MNG-BC ➜ .bitcoin du --max-depth=1 -h
1.1G ./testnet3
4.0K ./blocks
1.1G .
root@MNG-BC ➜ .bitcoin cd testnet3
root@MNG-BC ➜ testnet3 ls
blocks
root@MNG-BC ➜ testnet3 cd blocks
root@MNG-BC ➜ blocks ls
blk00000.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?