changing the path of the .bitcoin folder #27024
issue david739 openend this issue on February 2, 2023-
david739 commented at 8:17 am on February 2, 2023: nonehi, could someone please advise me how to change the path to the .bitcoin folder or what command to enter when running ./bitcoind to create a name other than .bitcoin
-
maflcko commented at 8:21 am on February 2, 2023: memberYou can use
./bitcoind -help
and look for the-datadir
setting. -
maflcko commented at 8:22 am on February 2, 2023: member
I see it doesn’t show the default in the
-help
.This is documented here: https://github.com/bitcoin/bitcoin/blob/master/doc/files.md#data-directory-location
-
maflcko added the label Questions and Help on Feb 2, 2023
-
david739 commented at 8:42 am on February 2, 2023: nonehi i entered this command and it doesn’t work i’m wrong
./bitcoind -datadir=<btc>
bash: syntax error near unexpected token `newline’ ./bitcoind -datadir=btc Error: Specified data directory “btc” does not exist. -
maflcko commented at 8:45 am on February 2, 2023: member
Ok, this is also not mentioned in the help, but my recommendation would be to use absolute paths.
Also, not mentioned in the doc, but the datadir may need to exist if the returned error is that it does not exist.
-
maflcko added the label Docs on Feb 2, 2023
-
david739 commented at 8:47 am on February 2, 2023: noneok, what should I enter for the command, please, the file exists, I rewrote .bitcoin to btc
-
willcl-ark commented at 8:57 am on February 2, 2023: contributor
Use the full path to the directory. If you renamed
bitcoin
tobtc
in its original location then this would mean (from the link Marco sent) on Linux using:bitcoind -datadir=$HOME/btc
Adapt to fit if you changed the default path, or are on Windows or MacOS.
-
david739 commented at 8:59 am on February 2, 2023: nonehi thank you it works
-
willcl-ark commented at 9:00 am on February 2, 2023: contributor
Ok, this is also not mentioned in the help, but my recommendation would be to use absolute paths. @MarcoFalke It’s not mentioned directly in the help, but it does have a flag in the log:
2023-02-02T08:58:00.640325Z Warning: relative datadir option '.bitcoin' specified, which will be interpreted relative to the current working directory '/home/will'. This is fragile, because if bitcoin is started in the future from a different location, it will be unable to locate the current data files. There could also be data loss if bitcoin is started while in a temporary directory.
Do you think it’s worth adding a note to the help too, or is this enough?
-
willcl-ark commented at 9:00 am on February 2, 2023: contributorGreat @david739 . Please feel free to close the issue if you’re happy with it.
-
kristapsk commented at 9:01 am on February 2, 2023: contributor
Ok, this is also not mentioned in the help, but my recommendation would be to use absolute paths.
Also, not mentioned in the doc, but the datadir may need to exist if the returned error is that it does not exist.
Should we improve docs / help?
-
david739 commented at 9:04 am on February 2, 2023: none1 more thanks guys I’ve been struggling with this quite a bit
-
david739 closed this on Feb 2, 2023
-
maflcko commented at 9:08 am on February 2, 2023: member
flag in the log: 2023-02-02T08:58:00.640325Z Warning:
Shouldn’t this at least be an InitWarning? I mean, who reads the log, especially gui users?
-
willcl-ark commented at 9:48 am on February 2, 2023: contributor
@MarcoFalke yep that’s definitely nicer on the QT side! For bitcoind it also prints a nice warning, unless you also add the
-daemon
option, in which case all is supressed to the log file again…Do you think it would it be acceptable to move the warning into appinit parameter interaction like so to have the warning surface before daemonisation?:
0diff --git a/src/init.cpp b/src/init.cpp 1index 5b486854e..87b46b00f 100644 2--- a/src/init.cpp 3+++ b/src/init.cpp 4@@ -436,7 +436,7 @@ void SetupServerArgs(ArgsManager& argsman) 5 argsman.AddArg("-blocksonly", strprintf("Whether to reject transactions from network peers. Automatic broadcast and rebroadcast of any transactions from inbound peers is disabled, unless the peer has the 'forcerelay' permission. RPC transactions are not affected. (default: %u)", DEFAULT_BLOCKSONLY), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); 6 argsman.AddArg("-coinstatsindex", strprintf("Maintain coinstats index used by the gettxoutsetinfo RPC (default: %u)", DEFAULT_COINSTATSINDEX), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); 7 argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); 8- argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); 9+ argsman.AddArg("-datadir=<dir>", "Specify data directory using an absolute path.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); 10 argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS); 11 argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (%d to %d, default: %d). In addition, unused mempool memory is shared for this cache (see -maxmempool).", nMinDbCache, nMaxDbCache, nDefaultDbCache), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); 12 argsman.AddArg("-includeconf=<file>", "Specify additional configuration file, relative to the -datadir path (only useable from configuration file, not command line)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); 13@@ -876,6 +876,15 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb 14 InitWarning(warnings); 15 } 16 17+ // Warn about relative -datadir path. 18+ if (args.IsArgSet("-datadir") && !args.GetPathArg("-datadir").is_absolute()) { 19+ InitWarning(strprintf(_("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " /* Continued */ 20+ "current working directory '%s'. This is fragile, because if bitcoin is started in the future " 21+ "from a different location, it will be unable to locate the current data files. There could " 22+ "also be data loss if bitcoin is started while in a temporary directory.\n"), 23+ args.GetArg("-datadir", ""), fs::PathToString(fs::current_path()))); 24+ } 25+ 26 if (!fs::is_directory(gArgs.GetBlocksDirPath())) { 27 return InitError(strprintf(_("Specified blocks directory \"%s\" does not exist."), args.GetArg("-blocksdir", ""))); 28 } 29@@ -1131,15 +1140,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) 30 31 LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); 32 33- // Warn about relative -datadir path. 34- if (args.IsArgSet("-datadir") && !args.GetPathArg("-datadir").is_absolute()) { 35- LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " /* Continued */ 36- "current working directory '%s'. This is fragile, because if bitcoin is started in the future " 37- "from a different location, it will be unable to locate the current data files. There could " 38- "also be data loss if bitcoin is started while in a temporary directory.\n", 39- args.GetArg("-datadir", ""), fs::PathToString(fs::current_path())); 40- } 41- 42 ValidationCacheSizes validation_cache_sizes{}; 43 ApplyArgsManOptions(args, validation_cache_sizes); 44 if (!InitSignatureCache(validation_cache_sizes.signature_cache_bytes)
This will then startup
bitcoind
like:0will@ubuntu in ~ 1₿ /home/will/src/bitcoin/src/bitcoind -regtest -datadir=btc -daemon 2Warning: Warning: relative datadir option 'btc' specified, which will be interpreted relative to the current working directory '/home/will'. This is fragile, because if bitcoin is started in the future from a different location, it will be unable to locate the current data files. There could also be data loss if bitcoin is started while in a temporary directory. 3 4Bitcoin Core starting
-
bitcoin locked this on Feb 2, 2024
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 15:12 UTC
More mirrored repositories can be found on mirror.b10c.me