Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: oppiet30 on August 02, 2023, 02:54:09 AM



Title: The chainstate and blocks directories
Post by: oppiet30 on August 02, 2023, 02:54:09 AM
Can I copy these two directories from a windows computer and copy them to a linux computer and bitcoind can still read them?
I have more blocks downloaded on the windows computer and I want to get the linux box caught up without downloading any blocks from the net. Or is there a simpler way to do this?


Title: Re: The chainstate and blocks directories
Post by: garlonicon on August 02, 2023, 04:30:13 AM
Short answer: yes, you can copy those files.

I did it on my nodes. I have full blockchain on some external drive, and any operating system can easily read it, if you point your Bitcoin Core into the right directory during startup.


Title: Re: The chainstate and blocks directories
Post by: oppiet30 on August 02, 2023, 04:40:23 AM
Do I need to copy both folders or just one of them?


Title: Re: The chainstate and blocks directories
Post by: ranochigo on August 02, 2023, 04:44:30 AM
Both. Bitcoin Core requires both to function.

When you start up bitcoind on Linux, you won't have to synchronize or validate from the start but you do have to ensure that Bitcoin Core is properly shut down on Windows before copying it over. Don't copy any sensitive files like wallet.dat. It'll probably be more efficient if you synchronize on the faster computer before copying it over.


Title: Re: The chainstate and blocks directories
Post by: DaveF on August 02, 2023, 10:38:57 AM
If you are taking the files and doing a copy and paste you are fine.
If you are putting the files on an external drive and having the linux box use them, do not forget to make sure your permissions are correct.

99% of the time it's fine but every once in a while there is an issue
Been there...done that....

As others have said make sure it's just those 2 folders and not anything else.

Obviously also make sure that bitcoin is not running on the windows machine when you copy the files. Yes, I know it's obvious, and someone here (reddit?) a few years ago also had an issue when it didn't fully shutdown and they could not figure out what happened. Turned out that something was grabbing the bitcoin app on the windows machine so it never closed properly.

-Dave


Title: Re: The chainstate and blocks directories
Post by: Accardo on August 02, 2023, 12:41:21 PM

I have full blockchain on some external drive, and any operating system can easily read it, if you point your Bitcoin Core into the right directory

Did you split the data directory into different drives to improve chainstate access speed? just figured here (https://en.bitcoin.it/wiki/Splitting_the_data_directory) that splitting can help the access speed of the chainstate especially when the data directory is stored on a magnetic drive. Though it's a good advise to copy both files, but, in some cases, it's not the only possible alternative.

Or is there a simpler way to do this?

Pruning can be simpler and wouldn't require you much procedures or explainations, you can add prune =550 to the bitcoin.conf, I'm suggesting this because it seems you are not abandoning the windows OS entirely to use linux to run your full node.



Title: Re: The chainstate and blocks directories
Post by: ranochigo on August 02, 2023, 02:03:25 PM
Pruning can be simpler and wouldn't require you much procedures or explainations, you can add prune =550 to the bitcoin.conf, I'm suggesting this because it seems you are not abandoning the windows OS entirely to use linux to run your full node.
If you're using different wallets, you cannot do this. Pruning also means that you cannot import a different wallet into your Linux instance without a complete resynchronization.



Title: Re: The chainstate and blocks directories
Post by: Accardo on August 02, 2023, 03:43:18 PM
Pruning can be simpler and wouldn't require you much procedures or explainations, you can add prune =550 to the bitcoin.conf, I'm suggesting this because it seems you are not abandoning the windows OS entirely to use linux to run your full node.
If you're using different wallets, you cannot do this. Pruning also means that you cannot import a different wallet into your Linux instance without a complete resynchronization.



Considering that when pruning was introduced in 0.11.0 it had no wallet until 0.12, I thought it'll be possible to have this issue solved in later versions, but I found on this thread (https://bitcointalk.org/index.php?topic=5207911.0) where you and other members explained in detail why such feature won't be expected. Without full resynchronization when adding new wallet, it's meaningless to call it prune. The concept of prune is to eradicate massive storage consumption. So, adding or importing different wallet shouldn't be a priority to users who have prune enabled, as they should know, to create enough space, that a lot of blocks including the genesis block won't be saved on the disk. I think prune users should be prepared to insert the right wallet before pruning in the first place.


Title: Re: The chainstate and blocks directories
Post by: garlonicon on August 03, 2023, 04:44:40 AM
Quote
Did you split the data directory into different drives to improve chainstate access speed?
Not yet, but this is a good link, and I will think about it. For me, it is more important to split the wallet than chain-related directories, because this is related to security, while blocks and chainstate are related only to performance.

But I use huge SSDs, for example 2 TB or 4 TB, so performance is quite good. The biggest bottleneck is verification time. If I run two offline clients on localhost, it takes similar time to synchronize for example some pruned node from some full node.