A really opionionated guide how to setup every version of a Raspberry Pi with Arch Linux including WiringPi, NTP, Wi-Fi, SSH, Ruby, ZSH and more.
Take a look into the wiki for more interesing stuff like finding out your Raspberry Pi version.
I recommend you to get a speed class 10 SD Card with more than 4 GB capacity for optimal performance.
Additionally you should buy a small heatsink. Something like that and attach it to the CPU of the Raspberry Pi.
- A linux machine with a working SD card slot
bsdtar
ortar
,fdisk
Replace /dev/sdX
with the SD Card device. Make sure that the device is the SD card and not your harddrive, otherwise
you'll destroy your linux installation! You can see which device you'll have to use by running sudo fdisk -l
after putting the
SD card into the slot.
- Start
fdisk
viasudo fdisk /dev/sdX
. - At the fdisk prompt, delete existing partitions: Type
o
. This will clear out any partitions on the drive. Then typep
to list partitions. There should be no partitions left. - Type
n
, thenp
for primary,1
for the first partition on the drive, pressENTER
to accept the default first sector, then type+100M
for the last sector. - Type
t
, thenc
to set the first partition to typeW95 FAT32 (LBA)
. - Type
n
, thenp
for primary,2
for the second partition on the drive, and then pressENTER
twice to accept the default first and last sector. - Write the partition table and exit by typing
w
. - Now create a FAT filesystem:
mkfs.vfat /dev/sdX1
and mount the new boot partition viamkdir boot && sudo mount /dev/sdX1 boot
- Also create the ext4 filesystem for the root partition:
mkfs.ext4 /dev/sdX2
and mount it:mkdir root && sudo mount /dev/sdX2 root
There are 2 major versions of Raspberry Pi now. You may find the downloads on www.archlinuxarm.org for the latest version of Arch Linux for Raspberry Pi both 1 and 2.
For Raspberry Pi 2
wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
sudo tar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
sync
For Raspberry Pi 1
wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
sudo tar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
sync
sudo mv root/boot/* boot/
sudo umount boot root
You can have connected a keyboard via USB and some kind of screen via HDMI or you can connect to the Pi via SSH after it's booted.
First of all get root:
su
The password is root
.
Of course just if you want to have a german keyboard layout. You may skip this step or use another layout.
loadkeys de
echo LANG=de_DE.UTF-8 > /etc/locale.conf
echo KEYMAP=de-latin1-nodeadkeys > /etc/vconsole.conf
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
sed -i "s/en_US.UTF-8/#en_US.UTF-8/" /etc/locale.conf
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
fallocate -l 1024M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo 'vm.swappiness=1' > /etc/sysctl.d/99-sysctl.conf
- Then add the following line to
/etc/fstab
:
/swapfile none swap defaults 0 0
timedatectl set-local-rtc 0
nano /etc/timezone
- Set to "Europe/Berlin"
sed -i 's/#Color/Color/' /etc/pacman.conf # Add color to pacman
pacman -Sy pacman
pacman-key --init
pacman -S archlinux-keyring
pacman-key --populate archlinux
pacman -Syu --ignore filesystem
pacman -S filesystem --force
reboot
After the Pi is booted again, connect via SSH (if you don't have attached a keyboard and screen) and login with alarm
/alarm
and get root again via su
.
pacman -S ntp fake-hwclock
systemctl enable ntpd.service
systemctl start ntpd.service
passwd
hostnamectl set-hostname your-hostname
pacman -S sudo vim
visudo
- Search for following line and uncomment it:
%wheel ALL=(ALL) ALL
- Add a new user (replace
yourUserName
with your username!)
useradd -d /home/yourUserName -m -G wheel,rvm -s /bin/bash yourUserName
- Set a password for your new user:
passwd yourUserName
-
Log out and log in with our newly created user
-
After that, delete the old
alarm
user:
sudo userdel alarm
sudo pacman -S --needed nfs-utils htop openssh autofs alsa-utils alsa-firmware alsa-lib alsa-plugins git zsh wget base-devel diffutils libnewt dialog wpa_supplicant wireless_tools iw crda lshw
- Install yaourt:
wget https://aur.archlinux.org/cgit/aur.git/snapshot/package-query.tar.gz
tar -xvzf package-query.tar.gz
cd package-query
makepkg -si
cd ..
wget https://aur.archlinux.org/cgit/aur.git/snapshot/yaourt.tar.gz
tar -xvzf yaourt.tar.gz
cd yaourt
makepkg -si
cd ../
rm -rf package-query/ package-query.tar.gz yaourt/ yaourt.tar.gz
sudo vim /etc/profile
Change the line saying PATH=
:
# Set our default path
PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/vc/sbin:/opt/vc/bin"
export PATH
And reload it:
source /etc/profile
sudo git clone git://git.drogon.net/wiringPi /opt/wiringpi
cd /opt/wiringpi
sudo ./build
gpio -v
gpio readall
- The last both command should give an
ok
or something similar. If not, something may be broken.
This is just for Raspberry Pi 1.
Set the output device
sudo amixer cset numid=3 1
You may want to overclock the Pi. And you won't even lose the guarantee for your pi, if you use the "offical"
overclocking presets. The simplest way to overclock the pi is rasp-config
tool which ships with the offical allowed
overclocking presets.
wget https://raw.github.com/chattama/raspi-config-archlinux/archlinux/raspi-config
Get to the overclocking menu and choose the overclocking preset you want. I recommend the "high" preset. After changing the overclocking preset, reboot your raspberry pi.
sudo wifi-menu -o
netctl start yourWifiSSID
netctl enable yourWifiSSID
\curl -sSL https://get.rvm.io | sudo bash -s stable
sudo usermod -aG rvm yourUser
rvm reload
rvm install ruby
rvm list
rvm alias create default ruby-2.3.0 # Or something else depending on what rvm list says
gem install bundler rake
If you want to use ZSH
sudo usermod -s /usr/bin/zsh
Additionally you may want to clone and setup your personal dotfiles.
- Logout and login back again or just reboot the pi
Change in your fstab:
sudo vim /etc/fstab
/dev/root / ext4 defaults,nodiratime,noatime,discard 0 0