Skip to content

Instantly share code, notes, and snippets.

@adcar
Last active April 27, 2024 00:27
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adcar/f2a61c942a878757719b3cb2bc233d38 to your computer and use it in GitHub Desktop.
Save adcar/f2a61c942a878757719b3cb2bc233d38 to your computer and use it in GitHub Desktop.
Tutorial: Setup Arch Linux Arm and Kodi on a Raspberry Pi (With a host machine running Linux)

Tutorial: Set up Arch Linux Arm + Kodi on a Raspberry Pi (With a host machine running Linux)

This tutorial will show how to, step by step, setup Arch Linux Arm and configure Kodi on a Raspberry Pi 3 Model B. Your host computer must be running Linux for this tutorial.

Prerequisites:

  • Raspberry Pi 3 Model B
  • 5V 2.1A Micro-usb Power Supply
  • Micro sdcard (I'd recommend at least 16GB)
  • USB Keyboard (for initial setup)
  • HDMI Cable
  • TV or Monitor with HDMI input
  • Computer running Linux (doesn't have to be Arch Linux)

Step 1: Setup Arch Linux Arm

Open up a terminal and run lsblk.
Insert your Micro sdcard into your computer.
Run lsblk once again. You should now see a new device (which is probably named mmcblk0). This is your sdcard.
Keep note of what your sdcard is called, as we will be using it throughout this tutorial. (I will refer to it as mmcblkY in commands as an example)
Run sudo -i to drop to a root shell.
Now run fdisk /dev/mmcblkY

You should now be brought to an fdisk prompt You will need to enter a series of commands from here.
Warning: If you mess up any part of this (e.g., hit the wrong button) then hit Ctrl-C to cancel (it will not write changes unless you hit w)

  • Type o to clear partitions
  • Optionally type p to list partitons and make sure there aren't any left.
  • Type n for new partition, and type p for primary, then 1 for first partiton. Hit enter to accept the default first sector and then type +100M for the last sector.
  • Type t for partition type, then c to set the first partition to FAT32.
  • Type n for new partition, then 2 for the second partition on your sdcard. Hit enter twice to accept the first and last sector.
  • Type w to write all of your changes to your sdcard.
    Now all your partitons are set up!
    Run lsblk. You should see two seperate partitons, one called something like mmcblkYp1 and one called mmcblkYp2. These are your two partitons. The first will be FAT32 (for booting) and the second will be EXT4 (for the root filesystem).

Next, enter the following commands to create and mount the FAT32 filesystem (the first partition):

mkfs.vfat /dev/mmcblkYp1
mkdir boot
mount /dev/mmcblkYp1 boot

Then, enter the following commands to create and mount the EXT4 filesystem (the second partition):

mkfs.ext4 /dev/sdX2
mkdir root
mount /dev/sdX2 root

Now, we can download Arch Linux ARM filesystem and extract it to the root directory we made earlier:

curl -L -O http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root

Optionally, you could substitue ArchLinuxARM-rpi-2-latest.tar.gz for ArchLinuxARM-rpi-3-latest.tar.gz for an AArch64 Installation (which is more unstable, but faster). Both work on Raspberry Pi 3.

Now run sync to make sure everything is properly synced.
Now move the boot files from root/boot into the boot partition/directory.

mv root/boot/* boot

Now we can unmount the both of the partitions/directories:

umount boot root

Arch Linux is now installed on your sdcard.

Step 2: Configure Arch Linux:

Eject the sdcard from your computer and insert it into your Raspberry Pi.
Plug in the Pi with HDMI to your TV / monitor. Now plug in the Pi with your 5V 2.1A Micro-usb Power Supply. The Pi should start up on its own, and you should be brought to a terminal screen.
Go ahead and plug in a keyboard to your Pi and enter root for the username and root for the password.
The first thing you should do is change the root password. Enter passwd and type in a new password.

Now create a new user (replace exampleusername with whatever username you want.):

useradd -m -g users -G wheel,storage,power -s /bin/bash exampleusername

Now set a password for the newly created user with passwd exampleusername.
Now let's set up Wi-Fi. Run wifi-menu to bring up a ncurses menu. You can then select your Wi-Fi network and enter the password. Now upgrade your system and install sudo:

sudo pacman -Syu sudo

Now type visudo and uncomment the wheel group. Note: If you'd like to use another text editor, like nano to configure sudo, then run EDITOR=nano visudo. Since your user is in the wheel group, it will have sudo priviledges.

Logout of root with exit and log back in with your newly created username and password. Test out sudo with sudo pacman -Syu to make sure everything works properly.

Arch Linux is now configured with your own user with sudo.

Optionally, you can install and configure ssh with the following:

sudo pacman -Syu openssh
sudo systemctl enable sshd

Step 3: Install and configure Kodi

Install kodi with

sudo pacman -Syu kodi-rbp

Kodi will now run, but we need to do a bit of configuration to make sure video works properly.
Edit the /boot/config.txt file on your Raspberry Pi and change the gpu_mem tag like so:

gpu_mem=256 

This will give the Raspberry Pi's GPU more memory on boot. (Which is needed for HD streaming).

Step 4: Run Kodi!

Run kodi from your terminal (or SSH). If everything worked correctly, you should be able to stream videos. You can use the YouTube addon to test out if everything works. Then you can start adding your Movies or TV Shows to Kodi.

@jackjackk
Copy link

Thanks for the guide. Had to update the pacman keyring to make pacman -Syu work though:

pacman-key --init
pacman-key --populate archlinuxarm

(see SDRausty/TermuxArch#81)
Also I couldn' find kodi-rbp. The package that seems to fit the most was called kodi-rpi-legacy. It also suggests to use 320mb in the /boot/config.txt.
Other steps that I found useful were to install an aur helper and the inputstream adaptive addon, which seems to be needed for netflix and other DRM streaming services:

sudo pacman -S base-devel git
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
yay -S kodi-addon-inputstream-adaptive-git

Copy link

ghost commented Oct 22, 2022

Another way of connecting is as so (I found that I couldn't use pacman unless I set the time and date):

timedatectl set-ntp false
timedatectl set-time "yyyy-mm-dd hh:mm:ss"
wpa_supplicant -B -i wlan0 -c <(wpa_passphrase MYSSID passphrase)
dhcpcd wlan0

see more: Wpa_supplicant

It's also a good idea to get ufw since all ports are open by default:

pacman -S ufw
ufw enable

Some other useful tweaks:
Autostart_X_at_login
Automatic_login_to_virtual_console

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