Category: raspberry pi

Mount external hd permanently on raspberry pi

The best tutorial to use for mounting an external Hard Drive permanently on your rspberry pi is on raspberrypi.org documentation

  1. List all the disk partitions

    sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL
  2. Identify the name of the disk partition (eg. sda1)

  3. Install the relevant storage driver for your FSTYPE (eg. exfat-fuse or ntfs-3g) - usually already install on ubuntu server

  4. Get the location of the disk partition

    sudo blkid
  5. Create a fodler to mount the device

    sudo mkdir /mnt/mydisk
  6. Mount the device to that folder

    sudo mount /dev/sda1 /mnt/mydisk
  7. Verify it is mounted

    ls /mnt/mydisk
  8. Get the UUID of the device

    sudo blkid
  9. Edit fstab - filesystem table

    sudo vim /etc/fstab
    
    UUID=5C24-1453 /mnt/mydisk fstype defaults,auto,users,rw,nofail 0 0

replace fstype with the filesystem type. Add ,umask=000 after nofail if the silesystem is FAT or NTFS

  1. Reboot

    sudo reboot

Raspberry Pi dedicated bitcoin node with Ubuntu ARM Instructions

In this post, we build a bitcoin node with a raspberry pi.

Requirements

  • Raspberry Pi with 4Gb or more
  • External hardrive 500Gb or more
  • SD card reader

Installing Ubuntu Server

Use these intructions to Install ubuntu server for raspberry pi

Use Ubuntu Server 20.04.1 LTS

Secure Ubuntu

Copy your over to authorized keys over to raspbeery pi with:

ssh-copy-id ubuntu@rasp_ip

Now you can edit sudo vim /etc/ssh/sshd_config and set:

PasswordAuthentication no
PermitRootLogin no
UsePAM no
X11Forwarding no

Reload SSH:

sudo systemctl reload ssh

You can also use this more pedantic openSSH hardening guide

Then you want to enable ufw Uncomplicated firewall - an interface to iptables.

Check the current ufw status with:

sudo ufw status

Allow ssh and enable:

sudo ufw allow OpenSSH
sudo ufw enable

I think by default incoming traffic not in the allowed will be blocked

Install Bitcoin Core

Go to https://bitcoin.org/bin and download the arm version you need:

Importantly you want bitcoin-0.21.0-aarch64-linux-gnu.tar.gz.

I thought this was the one bitcoin-0.21.0-arm-linux-gnueabihf.tar.gz but it is not. Perhaps it is for 32 bit CPU architecture - I'm not sure

Ensure you have your 500Gb or more external storage plugged in and use this tutorial to mount the partition permanently

Download bticoin core, verify and unpack:

cd /opt
sudo wget https://bitcoincore.org/bin/bitcoin-core-0.21.0/bitcoin-0.21.0-aarch64-linux-gnu.tar.gz
sha256-sum bitcoin-0.21.0-aarch64-linux-gnu.tar.gz
# Ensure it matches the given signatures on bticoin.org
tar xzf bitcoin-0.21.0-aarch64-linux-gnu.tar.gz
sudo install -m 0755 -o root -g root -t /usr/local/bin/ bitcoin-0.21.0/bin/*

Now bitcoind and bitcoin-cli should be in your path.

Make a directory on your 500GB plus HD:

cd /mnt/my-hd
mkdir bitcoin

Start bitcoind specifying the datadir:

bitcoind -daemon -datadir=/mnt/my-hd/bitcoin

This should also create a directory in ~/.bitcoin/bitcoin.conf specifying that location.

Now you have to wait for the entire blockchain - journal of transaction from the epoch of bitcoin to download

Ensure you have downloaded the full blockchain by checking the blockcount on bitinfo, then checking what your node block count is:

bitcoin-cli getblockcount
659835

Open up your node to the Internet

Inbound connections need to be enabled for port 8333 from the public internet.

So enable that with the firewall ufw:

sudo ufw allow 8333

Ensure all is good:

udo ufw status
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
8333                       ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
8333 (v6)                  ALLOW       Anywhere (v6)    

Then you need to do the following things:

  1. Giving your computer a static (unchanging) internal IP address by configuring the Dynamic Host Configuration Protocol (DHCP) on your router.
  2. Forwarding inbound connections from the Internet through your router to your computer where Bitcoin Core can process them.

The above tasks can be done in your router with DHCP address reservation and using NAT (Network Address Translation) port forwarding

You can test connectivity with:

bitcoin-cli getnetworkinfo

Ensure there are inbound connections "connections_in": 0,

or by going to bitnodes

Ensure bitcoind starts at startup - for power failure events

The crontab entry suggested by the full node guide does not work for me.

@reboot bitcoind -daemon

Rather create a file:

sudo touch /etc/systemd/system/bitcoind.service

Add:

[Unit]
Description=bitcoin
After=network.target

[Service]
Type=simple
User=ubuntu
Group=ubuntu

Environment=BITCOIN_PID=/home/ubuntu/bitcoin/bitcoin.pid
Environment=BITCOIN_HOME=/home/ubuntu/bitcoin/.bitcoin

ExecStart=/usr/local/bin/bitcoind
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target

Then enable and start:

sudo systemctl daemon-reload
sudo systemctl enable bitcoind
sudo systemctl start bitcoind

Sources