A Step by step manual to setup a Raspberry Pi for running a validator on the Altona Test-Net.
Required Hardware:
Required Software:
If the MicroSD card has been flashed correctly you should see a terminal screen after 1-2 minutes which says:
Username: ubuntu
Enter Password:
Type in ubuntu for username and password. You are going to create a new user for the main tasks and disable ubuntu user to access via SSH.
Now you want to know what the IP address is for the Raspberry Pi so you can connect to it from another PC / Laptop remotely.
In order to find the IP address (e.g. 192.168.x.x) type the following into the terminal.
hostname -I
Write down the IP address, you will need it when logging into the Raspberry Pi from a different computer.
On your PC / Laptop open either the terminal (mac) or a SSH App for windows and do the following.
ssh ubuntu@YOUR IP (e.g. ssh [email protected]) to connect to your Raspberry Pi.sudo apt-get update && sudo apt-get upgradeCreate a new user for connecting to the Raspberry Pi going forward which is saver then using the ubuntu account.
sudo adduser YOUR-USERNAMEsudo usermod -G sudo YOUR-USERNAMEsu YOUR-USERNAMENext update the firewall rules to restrict traffic to the server.
Allow connection via port 22 which is SSH.
sudo ufw allow 22/tcp
Allow connection via port 3000 which is used by Grafana.
sudo ufw allow 3000/tcp
Allow connection to port 30303 udp and tcp for Geth (Ethereum Blockchain)
sudo ufw allow 30303/tcp
sudo ufw allow 30303/udp
Enable the firewall with ufw enable. To check the status type ufw status
Finally restrict the root account to login via SSH.
Type sudo vi etc/ssh/sshd_config and change the line PermitRootLogin yes to PermitRootLogin no
Be sure the External SSD USB3 drive is plugged into the Raspberry Pi blue USB port.
To find the drive type the following sudo fdisk -l In my case the external drive is the last one shown in the list /dev/sda.
Next format the disk and create a portion using the following command sudo mkfs.ext4 /dev/sda
Manually mount the disk to the folder mnt/ssd.
sudo mkdir /mnt/ssdsudo chown -R YOUR-USERNAME:YOUR-USERNAME /mnt/ssd/sudo mount /dev/sda /mnt/ssdYou need the unique ID of the External disk in order to mount the drive automatically. Type sudo blkid
Find the line with your disk (starting with /dev/sda in my case) and copy the number after UUID (e.g. 5c3a8481-682c-4834-9814-17dba166f591)
Edit the /etc/fstab file to auto mount your disk on startup. Type sudo vi /etc/fstab and add the following line at the end UUID=YOUR-NUMBER /mnt/ssd ext4 defaults 0 0
Now reboot your system with sudo reboot. Connected again via SSH and check if you see the drive with the following command df -ha /dev/sda
To build the Lighthouse Client from Source you need to install Rust on your Raspberry Pi.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shsource $HOME/.cargo/envsource ~/.profilesudo apt install -y git gcc g++ make cmake pkg-config libssl-devNow with Rust and all dependencies installed you can get the Lighthouse repository.
git clone https://github.com/sigp/lighthouse.gitcd lighthousemakeThis will take up to an hour. If the installation was successful you should be able to run the lighthouse --help command.
sudo mv ~/lighthouse/target/release/lighthouse /usr/local/binIn order to use the Lighthouse client you need to run the Ethereum blockchain. I use the Geth client in this Tutorial.
To do this you need to install Go first.
-Create and change into a download folder by typing mkdir ~/download && cd ~/download
sudo wget https://dl.google.com/go/go1.14.4.linux-arm64.tar.gz.sudo tar -C /usr/local -xvf go1.14.4.linux-arm64.tar.gzsudo chown root:root /usr/local/go and sudo chmod 755 /usr/local/gosudo vi /etc/profile export PATH=$PATH:/usr/local/go/binsudo reboot and try if all works well with go versiongit clone https://github.com/ethereum/go-ethereum.gitcd go-ethereum and type make to build Geth.sudo mv ~/go-ethereum/build/bin/geth /usr/local/bingeth versionIn order to keep Geth running after you closed a window or SSH session you will need to create a Service (systemd). See this great tutorial for more info
sudo vi /etc/systemd/system/geth.service[Unit]
Description=Geth Node
After=network.target
Wants=network.target
[Service]
WorkingDirectory=/home/tarek
ExecStart=/usr/local/bin/geth --goerli --rpc --cache 512 --port 30303 --datadir /mnt/ssd/ethereum
User=ethereum
Group=ethereum
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
Alias=geth.service
sudo useradd --no-create-home --shell /bin/false ethereumsudo mkdir -p /mnt/ssd/ethereumsudo chown -R ethereum:ethereum /mnt/ssd/ethereumsudo systemctl daemon-reload followed by sudo systemctl start gethIn order to keep beacon-chain running after you closed a window or SSH session you will need to create a Service (systemd). See this great tutorial for more info
sudo vi /etc/systemd/system/beacon.service[Unit]
Description=beacon-chain
After=network.target
Wants=network.target
[Service]
WorkingDirectory=/home/tarek
ExecStart=/usr/local/bin/lighthouse beacon --eth1 --http --datadir /mnt/ssd/beacon
User=beacon
Group=beacon
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
Alias=beacon.service
This basically says: "Use the user with name and group beacon and run the beacon-chain as a service with eth1 and http flag to run a validator and save the data to my external SSD drive"
More details about beacon-chain parameters can be found here
Now you need to create a user called beacon (or any other name you like. The reason you want to create a different user is because it is recommended that a Service user shouldn't be able to login to the server via SSH.
To create a service user (I called it beacon) and type the following.
sudo useradd --no-create-home --shell /bin/false beacon
Next create a folder on the SSD drive for the Geth data to be stored. Type sudo mkdir -p /mnt/ssd/beacon
Give the new user access to write data on the SSD with sudo chown -R beacon:beacon /mnt/ssd/beacon
Finally reload and start the service by typing sudo systemctl daemon-reload followed by sudo systemctl start beacon
The manual of Lighthouse explains this very well. Check these last steps on their website.