Skip to content

Instantly share code, notes, and snippets.

@theramiyer
Last active April 23, 2024 21:11
Show Gist options
  • Star 64 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save theramiyer/cb2b406128e54faa12c37e1a01f7ae15 to your computer and use it in GitHub Desktop.
Save theramiyer/cb2b406128e54faa12c37e1a01f7ae15 to your computer and use it in GitHub Desktop.
Install Arch Linux (ARM) on Raspberry Pi 3 Model B+

Install Arch Linux (ARM) on Raspberry Pi B+

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.

Setup the SD card

Format the SD card with fdisk

  1. List out all the drives and partitions using lsblk. Note down the name of the SD card. In my case, it is mmcblk0.
  2. Start fdisk using sudo fdisk /dev/mmcblk0.
  3. Delete the existing partitions by entering o at the prompt. This clears out all partitions on the card.
  4. Type p to list the partitions; there should be none.
  5. Create a new partition with n, make it primary by entering p, set it as the first partition using 1.
  6. Press Enter to accept the default first sector. At the prompt, enter +110M to make it a 100 MB partition.
  7. Type t and then c to set the partition type to W95 FAT32 (LBA).
  8. Now, to create the second partition, type n, then p, make it the second partition by typing 2, and then, press Enter twice to accept the default first and the last sectors.
  9. Enter w to write this configuration to the card.
  10. Next, format the first partition as VFAT, and the second as EXT4.
    mkfs.vfat /dev/mmcblk0p1
    mkfs.ext4 /dev/mmcblk0p2
  11. Now, mount the two partitions.
    sudo mount /dev/mmcblk0p1 /mnt/boot
    sudo mount /dev/mmcblk0p2 /mnt/root

Transfer Arch Linux ARM to the card

The next step is to transfer the OS files onto the partitions.

  1. 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
  2. Unzip the contents of the zip file to /mnt/root/
    sudo tar -xpf ArchLinuxARM-rpi-latest.tar.gz -C /mnt/root/
    sync
  3. Move the contents of the boot directory to the boot partition.
    sudo mv /mnt/root/boot/* /mnt/boot/
  4. Unmount the partitions from your file system.
    sudo umount /mnt/boot /mnt/root

Setup the Pi

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.

Connect to WiFi (in case you don't use Ethernet)

If you would rather connect the device to WiFi:

  1. Navigate to /etc/wpa_supplicant.
  2. Create a new file called anything of your choice.
    nano home-network
  3. Enter the following in the file:
    network={
      ssid="YOURSSID"
      psk="YOURWIFIPASSWORD"
    }
  4. Now, run the following command to connect to your WiFi.
    wpa_supplicant -i wlan0 /etc/wpa_supplicant/home-network &
  5. Your device should now connect to the Wifi. The next step is to get a DHCP address.
    dhcpcd wlan0
    Once the command completes, you should get your prompt back. Ping any domain on the web to see if you're connected.

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.

Setup swap

This setup may be optional. I prefer doing this because I'm used to swap.

  1. Setup the swapfile.
    fallocate -l 1024M /swapfile
    chmod 600 /swapfile
    mkswap /swapfile
    swapon /swapfile
    echo 'vm.swappiness=1' > /etc/sysctl.d/99-sysctl.conf
  2. Configure fstab with the swap entry.
    /swapfile none swap defaults 0 0

Setup pacman

pacman is the package manager for Arch Linux.

  1. Add colour to pacman.
    sed -i 's/#Color/Color/' /etc/pacman.conf
  2. Initialise pacman
    pacman-key --init
    pacman-key --populate archlinuxarm
    pacman -Sy pacman
    pacman -S archlinux-keyring
  3. Update the system using pacman -Syu.
  4. Reboot your Pi using reboot.

User setup

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.

  1. Change the password for root.
    passwd
  2. Set the hostname of your Pi as per your preference.
    hostnamectl set-hostname YOURHOSTNAME
  3. Install sudo and vim.
    pacman -S sudo vim
  4. 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.
  5. Create your user.
    useradd -d /home/YOURUSERNAME -m -G wheel -s /bin/bash YOURUSERNAME
  6. Set a password for the new user.
    passwd YOURUSERNAME
  7. Delete the user, alarm.
    userdel alarm
  8. Log out and log back in as the new user you created.

Install packages

Now that we have most things set up, we will now proceed and install the necessary packages.

  1. 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
  1. Install blueman for Bluetooth.
sudo pacman -S blueman
  1. Install pi-bluetooth from the AUR. You should already have the packages necessary to build packages from the AUR. The package, pi-bluetooth, needs hciattach-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
  1. Enable Bluetooth using sudo systemctl enable bluetooth.service.
  2. Start the Bluetooth service using sudo systemctl start bluetooth.service.
  3. Now, let us install packages necessary for audio.
sudo pacman -S pulseaudio-alsa pulseaudio-bluetooth pavucontrol bluez bluez-libs bluez-utils bluez-firmware
  1. Enable audio at boot by adding the following line to sudo vim /boot/config.txt.
dtparam=audio=on

Final touches

Increase the life of your SD card.

  1. Open the fstab file.
sudo vim /etc/fstab
  1. 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+.

@Maik93
Copy link

Maik93 commented Sep 5, 2019

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 in rpi-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.

@theramiyer
Copy link
Author

Hey! Thank you! I wrote this guide quite long ago. I think I copied links off of my notes, rather than from the terminal, at the time of writing the guide. Sorry about the glitch; I've changed that. Thank you for pointing it out. 👍🙂

@0pcom
Copy link

0pcom commented Oct 8, 2019

Awesome and very helpful guide!

@OfficialMuffin
Copy link

I get a few errors when using the command sudo tar -xpf ArchLinuxARM-rpi-latest.tar.gz -C /mnt/root/
I used sudo tar -zxvf ArchLinuxARM-rpi-latest.tar.gz -C /mnt/root/ instead and it unpacks perfeclty without error.

@theramiyer
Copy link
Author

Oh okay, could you please tell me what error you got if you have the logs? I could add it to the documentation.

@theramiyer
Copy link
Author

@0pcom: thank you!

@blaggacao
Copy link

Little glitch:
change

pacman-key --init
pacman-key --populate archlinuxarm
pacman -S archlinux-keyring
pacman -Sy pacman

to (order)

pacman-key --init
pacman-key --populate archlinuxarm
pacman -Sy pacman
pacman -S archlinux-keyring

archlinux-keyring might already have a newer release, so update pacman first...

@theramiyer
Copy link
Author

Hey, thank you! Changed it.

Copy link

ghost commented Jan 13, 2020

I couldn't set up Bluetooth with these instructions; the hciattach-rpi3 package is not available anymore.

I installed bluez-utils-compat instead.

@open-antux
Copy link

open-antux commented Jan 19, 2020

I have two issue:

  1. sync command stuck, I don't know why but when I do sync it take very long long time to be executed and I think that it crashes instead.
  2. Ok I avoid sync command, continue with the guide and when I boot Archlinux it stuck at: fb0 switching to vc4drmfb from simple.

How can I solve these problems?

Edit: I solved the problem with sync

@theramiyer
Copy link
Author

Hey, @SleepingNewton and @Superjolly002, thank you for adding your solutions. I'll update the article. Unfortunately, I don't have the device with me anymore, so I can't test anything just yet. Will probably buy a 4 soon. :)

@open-antux
Copy link

open-antux commented Jan 23, 2020

@theramiyer the bluez-firmware package doesn't exist anymore
EDIT: I've notice you wrong to mention, change "Thanks to @Superjolly002" with "Thanks to @SleepingNewton"

@romansh-dev
Copy link

romansh-dev commented Feb 6, 2020

Author, You did not note about setup and sync time and select timezone:

In case if you have not file rc.conf
Для того, чтобы сравнить системное время и UTC:

$ timedatectl status

$ timedatectl status
Для установки системных часов:

timedatectl set-time "2012-10-30 18:17:16"

Изменить Вашу зону и субзону:

timedatectl set-timezone Zone/SubZone

Лист доступных зон:

$ timedatectl list-timezones
Пример установки зон:

timedatectl set-timezone Europe/Moscow

its from here https://wiki.archlinux.org/index.php/System_time_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)#%D0%A3%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BA%D0%B0_%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%B8

@mb720
Copy link

mb720 commented Feb 13, 2020

Thanks for your instructions!

The image at http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz did not work for me. When plugging in USB power, after a short while the green ACT LED started blinking rhythmically: two short blinks separated by a longer pause. I'm not sure what it means, also after reading the flash codes.

I figured out that it works fine with a different image:

wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz

It might seem counter-intuitive to use the rpi-2 image, but it worked on my Raspberry Pi 3 B+ as opposed to the rpi-3 image.

The instructions here also use the rpi-2 image.

@nikto-b
Copy link

nikto-b commented Apr 11, 2020

wpa_supplicant requires "-c" key before the config file path

@xetta-byte
Copy link

Can it monitor 5 ghz wifi

@gaetanpierrard
Copy link

wpa_supplicant ... & dhcpcd ... works well to connect the wifi. But I have to run it every time I start the computer. What would be the elegant way to make it happen at boot automatically?

@nikto-b
Copy link

nikto-b commented Jan 6, 2021

wpa_supplicant ... & dhcpcd ... works well to connect the wifi. But I have to run it every time I start the computer. What would be the elegant way to make it happen at boot automatically?

We call it networkd (or netctl)

@iiwwnnaa
Copy link

Thanks.
I installed ArchLinuxARM-rpi-2-latest.tar.gz on my raspberry pi 3B+

@k3lt
Copy link

k3lt commented Nov 1, 2021

Thanks for this

@covercash2
Copy link

new link for downloading the image (the old one is 404):

wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz

upstream instructions: https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment