Author

Topic: Unable to open settings file /media/external/bitcoin/settings.json.tmp (Read 189 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
Quote
1. Who's the owner/group of the Bitcoin Core directory/file?
It's root.

I meant @nc50lc environment when he tried to reproduce OP's problem.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
Can you give more detailed info?
Actually, I missed the part where he said that he can't create files on his own to that drive, so...
I think it's a different issue.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
This is bad solution, but looking at https://bitcoin.stackexchange.com/q/107115, a user managed to solve the problem by running Bitcoin Core as root.
Bad is an understatement! Obviously, you can solve permission problems by running as root, but those permissions are paramount for basic system security.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
I tried to reproduce it by setting the whole datadir as read-only but I've got a different error:
Code:
Error initializing settings: Error: Failed saving settings file:
- Failed renaming settings file \settings.json.tmp to \settings.json

When I set an existing setting.json.tmp file as read-only (appeared when the drive/settings.json was read-only),
I got the same error:
Code:
Error initializing settings: Error: Failed saving settings file:
- Error: Unable to open settings file /settings.json.tmp for writing

Both doesn't register to the debug.log since Bitcoin Core wont even launch.

I'm thinking it may not be a permission issue of the whole drive, but it lacks info so I'll just leave this to others.
hero member
Activity: 924
Merit: 5943
not your keys, not your coins!
If I mount it, will I essentially format it? I'm asking because I'm running a node and I don't want to lose my syncing so far or I need to know if I should back up the blocks in case something happens.

I would personally recommend to backup the blocks directory to another drive, wipe the drive, format it as ext4 and put back the blocks. Then do a reindex.
Also, I wouldn't recommend to
Code:
chmod 777
(allow all kinds of access to all users), instead simply change the ownership of the folder to only the user that runs bitcoin core:
Code:
sudo chown -R username /media/external/bitcoin
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
If I mount it, will I essentially format it?
No:
Quote from: Linux manual page
         mount -t type device dir

       This tells the kernel to attach the filesystem found on device
       (which is of type type) at the directory dir.
But if you didn't know this, you may need to read up a bit on Linux CLI basics. It'll come in handy Smiley

Just in case: changing the file system will wipe the disk.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
If I mount it, will I essentially format it? I'm asking because I'm running a node and I don't want to lose my syncing so far or I need to know if I should back up the blocks in case something happens.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
Sorry, apparently it's exfat.
~
Yep, but I chmod it with 777. I'm really curious what's the issue here.
Exfat can't handle file permissions. I guess it's mounted by/as/for root now.

If you don't use the drive elsewhere (on Windows systems), I'd format it with a default Linux filesystem. Ext2/3/4 will work. Alternatively, you can mount it for the user that needs to access it. It's been a while, but this sounds familiar:
Quote
Code:
/dev/sdb1 /media/maria/Lexfat exfat defaults,uid=1000,gid=1000 0 0
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Try:
Code:
mount | grep media

Code:
ubuntu@ubuntu:/media/external/bitcoin$ mount | grep media
/dev/sda1 on /media/external type exfat (rw,relatime,fmask=0022,dmask=0022,iocharset=utf8,namecase=0,errors=remount-ro)

Sorry, apparently it's exfat.

Your directory has 755 permission, not 777. So your user indeed has no write access.
Yep, but I chmod it with 777. I'm really curious what's the issue here.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
I used sudo chmod -R 777 /media/external/bitcoin
Code:
ubuntu@ubuntu:/media/external/bitcoin$ ls -al /media/external/bitcoin
total 16640
drwxr-xr-x 4 root root   262144 Aug 28 11:02 .
drwxr-xr-x 5 root root   262144 Aug 24 20:14 ..
Your directory has 755 permission, not 777. So your user indeed has no write access.

I'm not cutting my head off, but I think it's ext2.
Try:
Code:
mount | grep media
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
What permissions does it show on console (as a user)?
Say:
Code:
ls -al /media/external/bitcoin

Code:
ubuntu@ubuntu:/media/external/bitcoin$ ls -al /media/external/bitcoin
total 16640
drwxr-xr-x 4 root root   262144 Aug 28 11:02 .
drwxr-xr-x 5 root root   262144 Aug 24 20:14 ..
-rwxr-xr-x 1 root root        0 Aug 24 20:16 .lock
-rwxr-xr-x 1 root root      105 Aug 28 09:57 anchors.dat
-rwxr-xr-x 1 root root       37 Oct 24  2021 banlist.dat
-rwxr-xr-x 1 root root       10 Aug 28 11:02 bitcoin.conf
drwxr-xr-x 3 root root   262144 Aug 28 09:45 blocks
drwxr-xr-x 2 root root   262144 Aug 28 09:57 chainstate
-rwxr-xr-x 1 root root 11795920 Aug 28 09:57 debug.log
-rwxr-xr-x 1 root root   247985 Aug 28 09:57 fee_estimates.dat
-rwxr-xr-x 1 root root       18 Aug 28 09:57 mempool.dat
-rwxr-xr-x 1 root root  2608672 Aug 28 09:56 peers.dat
-rwxr-xr-x 1 root root        7 Sep 27  2021 settings.json

What filesystem are you using on the external drive?
I'm not cutting my head off, but I think it's ext2.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
I can view the directory, but as read-only. I can write on that directory and create files too with sudo. What I can't do is giving it the permissions to do it automatically.
What permissions does it show on console (as a user)?
Say:
Code:
ls -al /media/external/bitcoin

What filesystem are you using on the external drive?
(I'm just guessing a bit here)
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Could the permissions problem be on /media/external or even /media?
Probably something's wrong with the drive or with the OS that I don't know. When I run the mentioned command, it returns successfully so I guess it runs it successfully. Googling it didn't seem a great idea; there aren't lots of issues for the Ubuntu server. At least not more than the Ubuntu desktop.

On second thought, it's unlikely that's the problem considering you can view the directory.
I can view the directory, but as read-only. I can write on that directory and create files too with sudo. What I can't do is giving it the permissions to do it automatically.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
I've given all the permissions to that directory, or I at least, tried to. I used sudo chmod -R 777 /media/external/bitcoin, but I still can't create files by my own (without sudo touch).
Could the permissions problem be on /media/external or even /media?
On second thought, it's unlikely that's the problem considering you can view the directory.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
I'm running an Ubuntu Server (20.04) from my RPi 4 in which I have connected my external 1TB SSD drive and I connect remotely. I want to reindex the blockchain, so I enter:

Code:
./bitcoind --datadir=/media/external/bitcoin --reindex

It returns me:

Code:
Error: Failed saving settings file:
- Error: Unable to open settings file /media/external/bitcoin/settings.json.tmp for writing

I've given all the permissions to that directory, or I at least, tried to. I used sudo chmod -R 777 /media/external/bitcoin, but I still can't create files by my own (without sudo touch). Probably Bitcoin Core tries to create files and can't due to permissions. What do I have to give it all the permissions it requires?

Jump to: