My Raspberry Pi 3 setup
May 10, 2017I recently bought a Raspberry Pi 3 mainly for media playback purposes. Here is the setup process to remember later.
My distro of choice is Arch Linux ARM. Arch Linux has a really nice set of documentation, I recommend these two to get started:
- https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3
- https://wiki.archlinux.org/index.php/Raspberry_Pi
UART setup
I like to set up these small computers without keyboards or a monitor. One way
to do this is to use ssh
and connect to the device and the other is to use the
serial console. At the time of installation connecting an ethernet cable was not
convenient so I used the serial console for the initial setup. To my surprise
the Pi 3 board had the UART pins disabled by default. More info can be found in
this forum topic.
Enable the serial pins:
vim /boot/config.txt
enable_uart=1
Wire up the pi to the computer and use minicom to connect:
minicom -b 115200 -o -D /dev/ttyUSB0
Connectivity
Connect the ethernet cable and check for connectivity
networkctl status
Install the essentials
pacman -Syu
pacman -S vim, mc, htop, tmux, base-devel, bash-completion
Locale settings
sudoedit /etc/locale.gen
# locale-gen
# localectl set-locale LANG=en_US.UTF-8
Set correct timezone
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Budapest /etc/localtime
Set /etc/systemd/timesyncd.conf
optionally for another NTP server.
Swap
I decided to set up a swap file on the sd card. In retrospect, this may not have been the greatest idea.
fallocate -l 1024M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo 'vm.swappiness=1' > /etc/sysctl.d/99-sysctl.conf
Add the following line to /etc/fstab
.
/swapfile none swap defaults 0 0
Find a name for the thing
By far the hardest part of the process.
hostnamectl set-hostname NAME
Enable avahi
I don’t like hardwiring IP addresses in hosts files or anchoring them in my router. I’m a fan of zeroconf, with it I can reach the machines on my LAN on the .local domain and their hostname automatically.
sudo pacman -S avahi nss-mdns
sudoedit /etc/nsswitch.conf
sudo systemctl enable avahi-daemon
sudo systemctl start avahi-daemon
Copy ssh id
For passwordless ssh connections, copy my public key to the device.
ssh-copy-id -i ~/.ssh/id_rsa.pub rapsberry.local
Mount options
cat /etc/fstab
#
# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
/dev/mmcblk0p2 / ext4 defaults,nodiratime,noatime,discard 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 0
/swapfile none swap defaults 0 0
AUR helper
The AUR is a really nice way to get all kinds of packages, that are not
available in the main repositories. I use pacaur
for this task.