RaspberryPi 4

First, we need to burn the latest 64bit OS on the microSD card. At the time of writing, this was 2020-08-20-raspios-buster-arm64. The microSD card is not where we'll be writing the Cardano block data to, so 32GB is quite enough for the OS and Docker.

Once you've burned the OS on the card, you may want to enable SSH on boot before you power up your Pi for the first time. For this you need to put an empty file called SSH in the root directory of the microSD card.

$ touch /Volumes/boot/SSH

When the Pi is running, you should be able to SSH into it, like this ...

$ ssh pi@raspi4
password: raspberry
Linux raspberrypi 5.4.51-v8+ #1333 SMP PREEMPT Mon Aug 10 16:58:35 BST 2020 aarch64
...
Use raspi-config to set the country before use.

pi@raspberrypi:~ $

You can now use raspi-config to change the default password, set the hostname, enable Wi-Fi, etc. One of the first things I usually do, is to add my public SSH key to ~/.ssh/authorized_keys

$ scp ~/.ssh/id_rsa.pub pi@raspi4:.ssh/authorized_keys

For added security, we can then disable password authentication like this ...

$ sudo sed -i "s/^#PasswordAuthentication yes$/PasswordAuthentication no/" /etc/ssh/sshd_config
$ sudo cat /etc/ssh/sshd_config | grep PasswordAuthentication
PasswordAuthentication no

$ sudo systemctl restart sshd

Make sure you can indeed login without password, before you disable that. For details on how to generate an SSH key, we kindly ask you to look here for example.

Now that our Pi is reasonable well secured, we can continue with the setup and update system packages.

$ sudo apt-get update
$ sudo apt-get full-upgrade -y

System Time Synchronization

Keeping the system time synchronized among peers is quite important when we want to engage in peer-to-peer communication. Lets check real quick, whether the system time is getting synchronized ...

$ timedatectl
               Local time: Mon 2021-01-18 22:02:59 GMT
           Universal time: Mon 2021-01-18 22:02:59 UTC
                 RTC time: n/a
                Time zone: Europe/London (GMT, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

If that should not be the case, have a look at over here.

Enable memory accounting

Later, we'll be looking at how much memory the various docker containers consume while running. This is an important metric that we Stake Pool Operators (SPO) want to have an eye on. Lets check whether memory accounting is enabled at the kernel level.

$ cat /boot/cmdline.txt
console=serial0,115200 rootfstype=ext4 ... cgroup_memory=1 cgroup_enable=memory

Add these last two cgroup settings in case they are not there already. Re-boot afterwards ...

$ sudo shutdown -r now

Swap File Setup

The Pi comes with 8GB of RAM, which should be plenty to run a Cardano node. Still, lets setup a swap file in case the process has high memory spikes.

$ sudo dphys-swapfile swapoff
$ sudo sed -i "s/^CONF_SWAPSIZE=100$/CONF_SWAPSIZE=8192/" /etc/dphys-swapfile
$ sudo sed -i "s/^#CONF_MAXSWAP=2048$/CONF_MAXSWAP=8192/" /etc/dphys-swapfile
$ sudo cat /etc/dphys-swapfile | grep CONF
$ sudo dphys-swapfile setup
$ sudo dphys-swapfile swapon
$ free -h
              total        used        free      shared  buff/cache   available
Mem:          7.6Gi       104Mi       7.4Gi       8.0Mi       174Mi       7.4Gi
Swap:         8.0Gi          0B       8.0Gi

Mount Data Disks

We won't be writing the block data to the microSD card. Instead, we'll be using an external SSD drive connected to one of the USB-C ports. Initially, this can be a SanDisk Ultra Fit USB 3.1 Flash Drive.

Fist, lets list the connected block devices

$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    1 114.6G  0 disk
`-sda1        8:1    1 114.6G  0 part
mmcblk0     179:0    0  29.7G  0 disk
|-mmcblk0p1 179:1    0   256M  0 part /boot
`-mmcblk0p2 179:2    0  29.5G  0 part /

Now, lets initialize the filesystem on that external drive. The commands below will re-partition the drive and format the file system. All existing data on that drive will be lost.

# DISK00 ########################################################################

DISK00=/dev/sda
MOUNT00=/mnt/disks/data00

# Create new empty filesystem:
$ sudo mkfs.ext4 -m 0 -E lazy_itable_init=0,discard $DISK00

# Mount block storage
$ sudo mkdir -p $MOUNT00; sudo mount -o discard,defaults $DISK00 $MOUNT00

# Append to /etc/fstab
$ echo "" | sudo tee --append /etc/fstab
$ echo "$DISK00  $MOUNT00  ext4   defaults,noatime,nofail 0 0" | sudo tee --append /etc/fstab

Make sure the mounted directory for the block data is empty and does not contain the lost+found folder. Otherwise the Cardano node will not accept this location.

$ sudo rm -rf /mnt/disks/data00/*

This concludes the RaspberryPi setup. We can now continue with Installing Docker.

Last updated