DELTE--Basic Node Setup & Management on Linux
Posted: Tue Jan 31, 2023 4:49 pm
Hardware Requirements
Below are the Linux commands for the initial setup of your own microcurrency node. This has been
tested on Debian 11+. Make sure to compile and verify your own binaries. This guide assumes you
already have your trusted binaries prepared and ready to go.
Update/Upgrade
- Dedicated Machine: Raspberry Pi 4B, Virtual Machine, WSL2, etc.
- 4GB or 8GB Minimum of RAM w\ 32 or 64 bit OS Respectively
- 10GB + sufficient space for an ever growing blockchain
- 250GB recommended; 500GB+ to play it safe
Below are the Linux commands for the initial setup of your own microcurrency node. This has been
tested on Debian 11+. Make sure to compile and verify your own binaries. This guide assumes you
already have your trusted binaries prepared and ready to go.
Update/Upgrade
- sudo apt-get -y update
- sudo apt-get -y upgrade
- sudo apt-get -y install wget psmisc
- #Example (32 bit ARM):
- wget https://github.com/satoshiware/bitcoin/releases/download/v23001/bitcoin-arm-linux-gnueabihf.tar.gz
- sha256sum bitcoin-arm-linux-gnueabihf.tar.gz # df74eb09096a722c42e0b84ff96bc29f01380b4460729ea30cacba96ad6af7a6
- tar -xzf bitcoin-arm-linux-gnueabihf.tar.gz
- #Example (64 bit ARM):
- wget https://github.com/satoshiware/bitcoin/releases/download/v23001/bitcoin-aarch64-linux-gnu.tar.gz
- sha256sum bitcoin-aarch64-linux-gnu.tar.gz # ffadb8262438f06e5ef5706bb2158def662f92840c595077c3c794b5e33d1a11
- tar -xzf bitcoin-aarch64-linux-gnu.tar.gz
- #Example (64 bit x86):
- wget https://github.com/satoshiware/bitcoin/releases/download/v23001/bitcoin-x86_64-linux-gnu.tar.gz
- sha256sum bitcoin-x86_64-linux-gnu.tar.gz # d868e59d59e338d5dedd25e9093c9812a764b6c6dc438871caacf8e692a9e04d
- tar -xzf bitcoin-x86_64-linux-gnu.tar.gz
- sudo install -m 0755 -o root -g root -t /usr/bin bitcoin-install/bin/*
- cat << EOF | sudo tee /etc/systemd/system/bitcoind.service
[Unit]
Description=Bitcoin daemon
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/bin/bitcoind -micro -daemonwait -pid=/run/bitcoin/bitcoind.pid -conf=/etc/bitcoin.conf -datadir=/var/lib/bitcoin
ExecStop=/usr/bin/bitcoin-cli -micro -conf=/etc/bitcoin.conf -datadir=/var/lib/bitcoin stop
Type=forking
PIDFile=/run/bitcoin/bitcoind.pid
Restart=always
RestartSec=30
TimeoutStartSec=infinity
TimeoutStopSec=600
### Run as bitcoin:bitcoin ###
User=bitcoin
Group=bitcoin
### /run/bitcoin ###
RuntimeDirectory=bitcoin
RuntimeDirectoryMode=0710
### /var/lib/bitcoin ###
StateDirectory=bitcoin
StateDirectoryMode=0710
### Hardening measures ###
PrivateTmp=true
ProtectSystem=full
ProtectHome=true
NoNewPrivileges=true
PrivateDevices=true
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target
EOF
- sudo systemctl daemon-reload # Reload the new service configuration
- sudo useradd --system --shell=/sbin/nologin bitcoin
- alias btc="sudo -u bitcoin /usr/bin/bitcoin-cli -micro -datadir=/var/lib/bitcoin -conf=/etc/bitcoin.conf"
- echo "alias btc=\"sudo -u bitcoin /usr/bin/bitcoin-cli -micro -datadir=/var/lib/bitcoin -conf=/etc/bitcoin.conf\"" | sudo tee -a /etc/bash.bashrc # Reestablish alias @ boot
- cat << EOF | sudo tee /etc/bitcoin.conf
#server=0 # Accept JSON-RPC commands.
#rpcuser=satoshi # Username for JSON-RPC connections.
#rpcpassword=bitcoin # Password for JSON-RPC connections.
#rpcauth=satoshi:e826...267$R07...070d # Username and hashed password for JSON-RPC connections
#rest=0 # Accept public REST requests.
#txindex=0 # Maintain a full transaction index.
[micro]
#### Add nodes here via ssh tunneling (e.g. addnode=localhost:19335). ####
EOF
- sudo chown root:bitcoin /etc/bitcoin.conf
- sudo chmod 640 /etc/bitcoin.conf
- cat << EOF | sudo tee /etc/logrotate.d/bitcoin
/var/lib/bitcoin/micro/debug.log {
$(printf '\t')create 660 root bitcoin
$(printf '\t')daily
$(printf '\t')rotate 14
$(printf '\t')compress
$(printf '\t')delaycompress
$(printf '\t')sharedscripts
$(printf '\t')postrotate
$(printf '\t')$(printf '\t')killall -HUP bitcoind
$(printf '\t')endscript
}
EOF
- sudo mkdir -p /var/log/bitcoin/micro
- sudo ln -s /var/lib/bitcoin/micro/debug.log /var/log/bitcoin/micro/debug.log
- sudo chown root:bitcoin -R /var/log/bitcoin
- sudo chmod 660 -R /var/log/bitcoin
- sudo systemctl enable bitcoind --now
- sudo systemctl status bitcoind # See system control status for bitcoind
- sudo systemctl enable bitcoind # Enable @ boot and enable auto-restart
- sudo systemctl disable bitcoind # Disable @ boot and disable auto-restart
- sudo systemctl disable bitcoind --now # Disable system control for bitcoin and stop it now
- sudo systemctl start bitcoind# Start the service
- sudo systemctl stop bitcoind# Stop the service
- sudo cat /var/log/bitcoin/micro/debug.log # Read latest debug log file
- sudo ls -all /var/lib/bitcoin/micro | grep "debug" # View all (archived) debug log files