Install Raspberry Pi

From xPL
Jump to: navigation, search

The xPL protocol is light enough to run on simple machines such as the Raspberry Pi.

Install Raspbian

Several distributions are available for the Raspberry Pi. This wiki bases on the console version of Raspbian.

Operating system

A disk image can be downloaded and copied to the SD card with the help of Etcher.

unzip ~/Downloads/ -d /tmp/
/tmp/etcher-*.AppImage &

Place the SD card on the board and power it. Attach a keyboard and a screen and wait for the boot process to terminate. Login as pi with username raspberry.

sudo su
apt update
apt upgrade

Check OS version:

uname -a

The result can be compared to the Raspberry Pi OS version history.

With raspi-config, one can:

  • change the keyboard layout
  • edit the host name
  • enable ssh (from Interfacing Options)
  • disable predictable interface names (keep to eth0 and wlan0)
  • set the wi-fi region

Enable root SSH by changing in /etc/ssh/sshd_config:

PermitRootLogin yes

Disable the Bluetooth related services:

systemctl disable hciuart.service
systemctl disable bluetooth.service

Disable loading the Bluetooth kernel modules by adding in /boot/config.txt:

# Disable Bluetooth

Change root settings

Insert the SD card in the Raspberry Pi and boot it.

sudo su
apt update
apt upgrade

Setup aliases:

nano .bashrc
source .bashrc

Specify what to do with pageUp/Down keys:

nano /etc/inputrc

Allow ssh:

nano /etc/ssh/sshd_config
# change: PermitRootLogin yes
service ssh restart


Specify locales by editing /etc/default/locale:


Test it:

perl -e exit

Install the necessary package for the documentation of Perl scripts:

apt install perl-doc

Swap partition

Add a 1 GB swap partition

cfdisk /dev/mmcblk0
swaplabel -L swap /dev/mmcblk0p3

Edit /etc/fstab and add:

LABEL=swap    none    swap    sw    0 0

Remove the default swapfile:

update-rc.d -f dphys-swapfile remove
swapoff -a
rm /var/swap

Reboot and check:

swapon -s


Check the Ethernet connection:

ifconfig | grep 'inet '
ping -c 4

Change host name:


Give a static IP address:

nano /etc/dhcpcd.conf

Add the following lines:

# Set a static IP address
interface eth0
static ip_address=
static routers=
static domain_name_servers=

Restart the machine and re-enable SSH:

ifconfig | grep 'inet '

Set-up Apple FileProtocol (AFP) sharing:

apt install netatalk
nano /etc/netatalk/AppleVolumes.default


Removing the default user can close security gaps:

userdel -r pi

Add a data partition for the users' home

cfdisk /dev/mmcblk0
mke2fs -t ext4 -L data /dev/mmcblk0p4

Edit /etc/fstab and add:

LABEL=data    /home    ext4    defaults,noatime    0 1

Reboot the machine:

lsblk -o name,label,mountpoint

Add the control user:

useradd -m -g users -G users,dialout,audio -s /bin/bash control
passwd control


Zeroing unused blocks on the SD card should be better for later compression:

apt install secure-delete
lsblk -o name,label,mountpoint

Zero fill unused blocks of the data partition:

sfill -lzv /home/

Zero fill unused blocks of the system partition:

umount /home
sfill -lzv /

Zero the swap partition:

swapoff /dev/mmcblk0p3
dd if=/dev/zero of=/dev/mmcblk0p3
mkswap -L pi-swap /dev/mmcblk0p3

Stop the machine:


Extract the SD card, insert it in a reader and plug it in a Linux PC.

Save the whole disk:

lsblk -o name,label,fstype,size,mountpoint
umount $RPI_DISK*
dd if=$RPI_DISK status=progress | bzip2 -9f >$RPI_BACKUP_FILE
eject $RPI_DISK

Restore the whole disk:

bunzip2 -dc $RPI_BACKUP_FILE | dd of=$RPI_DISK status=progress


CPU usage

Check CPU usage:

ps -eo pcpu,user,args | sort -k 1 -r | head -10
echo && ps -eo pcpu,user,args | grep -v ' 0.0 ' | grep -v '%CPU' | sort -k 1 -r | sed 's/[ ^I]\/.*\/perl//' | sed 's/.pl[ ^I].*/.pl/'

Process priorities

Check process priorities:

ps ax -o nice,pid,user,args | grep -v ' NI ' | sort

The lowest numbers correspond to the highest priorities.

Change the priority level of xPL devices:

ps ax -o nice,pid,user,args | grep -v ' grep ' | grep -i xpl-

task_list=(`ps ax -o pid,user,args | grep -v ' grep ' | grep -i '/xpl-'`)
for item in "${task_list[@]}" ;  do
  task_id=`echo "${item}" | sed "s/$USER.*//"`
# echo $task_id
  renice $NEW_LEVEL -p $task_id >/dev/null
ps ax -o nice,pid,user,args | grep -v ' grep ' | grep -i xpl-


Here some interesting pages for the installation process: