Created 17 Aug 2018
This is a simple installation that I did on my Raspberry Pi. Of course, this is only one of the many reasons to do it.
Here are my requirements:
Let's start!
First, insert the memory card into your laptop. I use a memory card slot, so my device name would differ from yours if you use a USB memory card reader.
- List out all the drives and partitions using
lsblk
. Note down the name of the SD card. In my case, it ismmcblk0
. - Start
fdisk
usingsudo fdisk /dev/mmcblk0
. - Delete the existing partitions by entering
o
at the prompt. This clears out all partitions on the card. - Type
p
to list the partitions; there should be none. - Create a new partition with
n
, make it primary by enteringp
, set it as the first partition using1
. - Press
Enter
to accept the default first sector. At the prompt, enter +110M to make it a 100 MB partition. - Type
t
and thenc
to set the partition type toW95 FAT32 (LBA)
. - Now, to create the second partition, type
n
, thenp
, make it the second partition by typing2
, and then, pressEnter
twice to accept the default first and the last sectors. - Enter
w
to write this configuration to the card. - Next, format the first partition as
VFAT
, and the second asEXT4
.mkfs.vfat /dev/mmcblk0p1 mkfs.ext4 /dev/mmcblk0p2
- Now, mount the two partitions.
sudo mount /dev/mmcblk0p1 /mnt/boot sudo mount /dev/mmcblk0p2 /mnt/root
The next step is to transfer the OS files onto the partitions.
- Download Arch Linux ARM from www.archlinuxarm.org. The steps are pending an update. Please follow the instructions in the Installation tab of the Raspberry Pi 3 page over at Linux ARM.
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz
- Unzip the contents of the zip file to
/mnt/root/
sudo tar -xpf ArchLinuxARM-rpi-latest.tar.gz -C /mnt/root/ sync
- Move the contents of the
boot
directory to theboot
partition.sudo mv /mnt/root/boot/* /mnt/boot/
- Unmount the partitions from your file system.
sudo umount /mnt/boot /mnt/root
Insert the SD card into the Pi. Now, connect a keyboard and a mouse. Connect the Pi to a display using the HDMI port. Next, connect the ethernet cable. Finally, plug in the power supply.
As soon as the login prompt arrives, enter root
as the username and root
as the password. You are now logged into the device.
If you would rather connect the device to WiFi:
- Navigate to
/etc/wpa_supplicant
. - Create a new file called anything of your choice.
nano home-network
- Enter the following in the file:
network={ ssid="YOURSSID" psk="YOURWIFIPASSWORD" }
- Now, run the following command to connect to your WiFi.
wpa_supplicant -i wlan0 /etc/wpa_supplicant/home-network &
- Your device should now connect to the Wifi. The next step is to get a DHCP address.
Once the command completes, you should get your prompt back. Ping any domain on the web to see if you're connected.
dhcpcd wlan0
Arch Linux allows SSH by default. If you would like to connect to the Pi using SSH from your personal computer instead of attaching a keyboard and a mouse and HDMI and everything, by all means, please do.
This setup may be optional. I prefer doing this because I'm used to swap.
- Setup the swapfile.
fallocate -l 1024M /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile echo 'vm.swappiness=1' > /etc/sysctl.d/99-sysctl.conf
- Configure
fstab
with the swap entry./swapfile none swap defaults 0 0
pacman
is the package manager for Arch Linux.
- Add colour to
pacman
.sed -i 's/#Color/Color/' /etc/pacman.conf
- Initialise pacman
pacman-key --init pacman-key --populate archlinuxarm pacman -Sy pacman pacman -S archlinux-keyring
- Update the system using
pacman -Syu
. - Reboot your Pi using
reboot
.
Right out of the box, Arch Linux ARM comes with two users: root
and alarm
. The first thing we would want to do is reset the password for root
, and then, either create a new user to replace alarm
, or reset the password for alarm
. I go with the former approach.
- Change the password for
root
.passwd
- Set the hostname of your Pi as per your preference.
hostnamectl set-hostname YOURHOSTNAME
- Install
sudo
andvim
.pacman -S sudo vim
- Now, enable the
wheel
group, create your user, and add the user to the group.visudo # Search for the line that contains `%wheel ALL=(ALL) ALL` and uncomment it. Save the file.
- Create your user.
useradd -d /home/YOURUSERNAME -m -G wheel -s /bin/bash YOURUSERNAME
- Set a password for the new user.
passwd YOURUSERNAME
- Delete the user,
alarm
.userdel alarm
- Log out and log back in as the new user you created.
Now that we have most things set up, we will now proceed and install the necessary packages.
- First, install a bunch of necessary software.
sudo pacman -S --needed nfs-utils htop openssh autofs alsa-utils alsa-firmware alsa-lib alsa-plugins git zsh wget base-devel binutils diffutils libnewt dialog wpa_supplicant wireless_tools iw crda lshw
- Install
blueman
for Bluetooth.
sudo pacman -S blueman
- Install
pi-bluetooth
from the AUR. You should already have the packages necessary to build packages from the AUR. The package,pi-bluetooth
, needshciattach-rpi3
installed. Run the following.
mkdir builds # A directory where all packages will be built.
cd builds/
git clone https://aur.archlinux.org/hciattach-rpi3.git # Clone the repository
cd hciattach-rpi3/
makepkg -si # Build the package
Update: Looks like hciattach-rpi3
is no more available. Use bluez-utils-compat
instead. Thanks to @SleepingNewton.
git clone https://aur.archlinux.org/pi-bluetooth.git
cd pi-bluetooth
makepkg -si
- Enable Bluetooth using
sudo systemctl enable bluetooth.service
. - Start the Bluetooth service using
sudo systemctl start bluetooth.service
. - Now, let us install packages necessary for audio.
sudo pacman -S pulseaudio-alsa pulseaudio-bluetooth pavucontrol bluez bluez-libs bluez-utils bluez-firmware
- Enable audio at boot by adding the following line to
sudo vim /boot/config.txt
.
dtparam=audio=on
Increase the life of your SD card.
- Open the
fstab
file.
sudo vim /etc/fstab
- Add the following line to the file.
/dev/root / ext4 defaults,nodiratime,noatime,discard 0 0
That should get you going with Arch Linux on Raspberry Pi 3 B+.
Hi, cool guide!
One question: when, at the beginning, you download the ArchLinux ARM image, you use the command:
wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
I've checked the official site too, and it's the same, but we are using a Pi3, so doesn't we have to change
rpi-2
inrpi-3
? I've tried and it resolves in an existing package.My main concern is that the Pi3 is 64-bit, while the Pi2 is not, so I suppose that anything should not work if exchanged.