Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: CONFIDENCE_Man on February 27, 2021, 03:13:46 AM



Title: Configuring bitcoin-core Snap package in Ubuntu Server 20.04
Post by: CONFIDENCE_Man on February 27, 2021, 03:13:46 AM
In order to take advantage of automatic updates, I've installed the bitcoin-core Snap package under Ubuntu Server 20.04 (no GUI) running on Microsoft Hyper-V Server 2019.

I need to be able to do the following:

  • Change the data directory to /media/bitcoin_data (ext4, a separate VHDX already mounted on startup to store all the data)
  • Run bitcoin-core.daemon at startup using the unprivileged system account 'bitcoin'.

I can't find any good guides on how to do this without installing the GUI to specify the data directory. (I've actually tried to install 'ubuntu-desktop' through Apt, but after a reboot of the VM, it just displays a blank cursor on the console. I'd rather not have a GUI on this VM anyhow.)

Does anyone else have such a setup that's working?


Title: Re: Configuring bitcoin-core Snap package in Ubuntu Server 20.04
Post by: NotATether on March 02, 2021, 04:23:08 PM
The first setting can be added into the bitcoin.conf file:

- To change the data directory, create a file called /home/bitcoin/.bitcoin/bitcoin.conf and inside it type the line

Code:
datadir=/media/bitcoin_data

As for starting at boot, there is no such option in bitcoin.conf, however you can make a systemd service that starts bitcoind as the "bitcoin" user at system startup.

1. In your VM create a file called bitcoind.service with the following contents:

Code:
[Unit]
Description=Run Bitcoin Core as daemon
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=simple
# you may have to change the path of bitcoind
ExecStart=/usr/local/bin/bitcoind    # Add command line options here at your will
RemainAfterExit=no

[Install]
WantedBy=multi-user.target

2. Put this file in /usr/lib/systemd/system
3. Run the following commands:

Code:
sudo systemctl daemon-reload
sudo systemctl enable bitcoind.service
sudo systemctl start bitcoind.service  # alternatively just restart the VM