Difference between revisions of "Install Raspberry Pi"

From xPL
Jump to: navigation, search
(Upstart daemons)
(Users)
Line 116: Line 116:
  
 
= Users =
 
= Users =
 
== Remove default user ==
 
  
 
Removing the default user can close security gaps:
 
Removing the default user can close security gaps:
 
  userdel -r pi
 
  userdel -r pi
  
== Create user ==
+
 
 +
Add a data partition for the users' home
 +
cfdisk /dev/mmcblk0
 +
mke2fs -t ext4 -L data /dev/mmcblk0p4
 +
 
 +
Edit <code>/etc/fstab</code> and add:
 +
LABEL=data    /home    ext4    defaults,noatime    0 1
 +
 
 +
Reboot the machine:
 +
reboot
 +
lsblk -o name,label,mountpoint
  
 
Add the <code>control</code> user:
 
Add the <code>control</code> user:

Revision as of 18:23, 1 August 2017

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.

Prepare an SD card

On a Linux computer, download it:

su
cd /tmp
wget https://downloads.raspberrypi.org/raspbian_lite_latest -O raspbian-lite.zip
sha1sum raspbian-lite.zip
unzip raspbian-lite.zip.zip
mv *-raspbian-*-lite.img raspbian-lite.img

Insert a card reader with the SD card you wish to use and write the image:

fdisk -l
RPI_DISK='/dev/sdb'
umount $RPI_DISK*
ls -lh raspbian-lite.img | sed -e 's/.*root/Copying/' | sed -e 's/G.*rasp/G file rasp/'
dd if=raspbian-lite.img of=$RPI_DISK status=progress conv=fsync && \
aplay /usr/share/sounds/alsa/Front_Center.wav
eject $RPI_DISK

Unplug the SD card reader and plug it in again. Find the mount point:

df -h | grep $RPI_DISK
RPI_DISK_MOUNTPOINT='/media/francois/boot'

Remove init=/usr/lib/raspi-config/init_resize.sh from:

nano -w $RPI_DISK_MOUNTPOINT/cmdline.txt

Eject the SD card reader:

eject $RPI_DISK

Change root settings

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

sudo su
passwd
apt update
apt upgrade

Setup aliases:

nano .bashrc
source .bashrc

Specify what to do with pageUp/Down keys:

nano /etc/inputrc

Allow ssh:

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

Locales

Set the regional parameters:

raspi-config

Then edit ~.bashrc and add:

# Locales
export LC_ALL=C

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

Ethernet

Check the Ethernet connection:

ifconfig | grep 'inet '
ping -c 4 google.com

Change host name:

raspi-config

Give a static IP address:

nano /etc/dhcpcd.conf

Add the following lines:

# Set a static IP address
interface eth0
static ip_address=192.168.1.18/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.3

Restart the machine and re-enable SSH:

reboot
raspi-config
ifconfig | grep 'inet '

Set-up Apple FileProtocol (AFP) sharing:

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

Programming tools

Install Perl documentation reader:

apt-get install perl-doc

Users

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:

reboot
lsblk -o name,label,mountpoint

Add the control user:

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

Checks

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-

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

Links

Here some interesting pages for the installation process: