Skip to content

Latest commit

 

History

History
226 lines (187 loc) · 4.86 KB

SETUP.org

File metadata and controls

226 lines (187 loc) · 4.86 KB

Instalar Raspbian na Master

Configurar DHCPD

$ sudo -s
# apt install -y isc-dhcp-server
# nano /etc/dhcp/dhcpd.conf
# systemctl restart isc-dhcp-server

Set the interfaces in which to listen on: /etc/default/isc/dhcp/server

INTERFACESv4="eth0"

In case of issues, check the logs:

# journalctl -xeu isc-dhcp-server

Remember configure a static address on the main interface:

Set up the slaves

Partition the SSD

# fdisk -l
# fdisk /dev/sda
g
n
w

Raspbian doesn’t come with btrfs-progrs out of the box, so install it:

# apt install btrfs-progs

Then create the filesystem:

# mkfs.btrfs /dev/sda1

Add it to the fstab: /dev/fstab

/dev/sda1       /mnt/usb        btrfs       defaults    0   0

Then mount it:

# mkdir /mnt/usb
# mount /mnt/usb

Set up the operating system image

Go to https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit and get yourself the link to a GUI-less image, then download it:

# cd /mnt/usb
# wget <link you copied> -Oos.img.xz

Extract

# unxz os.img.xz

Then mount

# dev=$(losetup -Pf --show os.img)
# mkdir mnt
# mount ${dev}p2 mnt

Finally, copy the filesystem over

# btrfs subvolume create slave
# rsync -av --info=progress2 mnt/ slave/

Unmount the main system

# umount mnt

Mount the firmware partition

# mount ${dev}p1

Copy it over, then get rid of it

# mkdir -p slave/boot/firmware
# rsync -av --info=progress2 mnt/ slave/boot/firmware
# umount mnt

Serve it over NFS

Firstly, install the NFS server

# apt install nfs-kernel-server

Then enable the required services

# systemctl enable --now rpcbind
# systemctl enable --now nfs-server

Reload the export list, just in case

# exportfs -r

Then check if the exports look alright

# showmount -e localhost

Serve the boot files over TFTP

Install the tftp server and create the required directory tree

# apt install tftp-hpa
# mkdir -p tftpboot
# chown tftp:tftp tftpboot

Configure the TFTP server

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/mnt/usb/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure --create"

Then restart it

# systemctl restart tftpd-hpa

Set up the firmware folder to be bound over the tree served by the TFTP server /etc/fstab/

/mnt/usb/slave/boot/firmware    /mnt/usb/tftpboot   none    bind    0   0

Then bind it

# mount -a

Configure the slave nodes to mount the root over NFS

echo 'console=serial0,115200 console=tty root=/dev/nfs nfsroot=10.0.0.1:/mnt/usb/slave,vers=3 rw ip=dhcp rootwait' > slave/boot/firmware/cmdline.txt

Configure the slave systems

First of all, set up the slave’s /etc/fstab to mount / from NFS slave/etc/fstab

pi-master:/mnt/usb/slave    /   nfs vers=3  0   0

Remember to remove the entries referring to the local filesystems (i.e. / and /boot/firmware).

Add the master and slaves to the master’s /etc/hosts

10.0.0.1    pi-master
10.0.0.2    pi-slave-01
10.0.0.3    pi-slave-03

Set the master’s /etc/hosts to be bound over the slave’s /etc/fstab

/etc/hosts      /mnt/usb/slave/etc/hosts    none    bind    0   0

Remove the hostname file so that the node gets it’s hostname from DHCP

# rm slave/etc/fstab

Set up SSH

Generate an ssh key on the master node

# ssh-keygen  -t rsa -b 4096 -C "pi@cluster"

Then copy it over to the slave root

# cat ~/.ssh/id_rsa.pub >> slave/root/.ssh/authorized_keys

Configure the system services

Chroot into the system

# for fs in dev proc sys; do mount -R {,slave}/$fs; done
# chroot slave /bin/bash
# . /etc/profile

Disable a few unecessary services

# systemctl disable resize2fs_once
# systemctl disable sshswitch
# systemctl disable userconfig
# apt remove dphys-swapfile

Enable sshd

# systemctl enable ssh

Then press ctrl+d to quit.

Configure the slave to boot over the network

On the slave, boot a generic image, then, as root

# raspi-config

Navigate to Advanced Options > Boot Order > Network Boot, then reboot.

At this point, your slave node should already be able to boot over the network.