Verifying the Target Disk with fdisk -l
sudo fdisk -l
Example: if your SD card appears as /dev/sdc, that’s the device you will work on.
Always double-check the disk identifier before formatting, to avoid erasing the wrong drive.
Format if necessary
sudo fdisk /dev/sdc
Inside fdisk:
- type
oto create a new DOS partition table - type
wto write changes and exit
Wipe all filesystem signatures
sudo wipefs -af /dev/sdc1
sudo wipefs -af /dev/sdc2
If nothing else works, zero the entire device;
DANGEROUS – Erases everything!
sudo dd if=/dev/zero of=/dev/sdc bs=4M status=progress count=100
Start fdisk to partition
sudo fdisk /dev/sdc
1. If you want an MBR (DOS) partition table:
At the fdisk prompt, delete old partitions and create a new one:
If prompted with Partition contains a signature:
Do you want to remove the signature? [Y]es/[N]o: type y.
Type o. This will clear out any partitions on the drive.
Type p to list partitions. There should be no partitions left.
Type n, then p for primary, 1 for the first partition on the drive, press ENTER to accept the default first sector, then type +200M for the last sector.
Type t, then c to set the first partition to type W95 FAT32 (LBA).
Type n, then p for primary, 2 for the second partition on the drive, and then press ENTER twice to accept the default first and last sector.
Type t, then 83 (Linux).
Write the partition table and exit by typing w.
2. If you have a modern disk and want to use a GPT partition table (essential for disks larger than 2TB):
Change MBR (DOS) partition table by a new empty GPT partition table by changing o to g.
Type g. This will clear out any partitions on the drive.
Type p to list partitions. There should be no partitions left.
Type n, 1 for the first partition on the drive, press ENTER to accept the default first sector, then type +512M for the last sector.
Type t, set type 11 (Microsoft basic data) .
Type n, 2 for the second partition on the drive, and then press ENTER twice to accept the default first and last sector.
Type t , select partition 2, set type 20 (Linux filesystem)
Write the partition table and exit by typing w.
A 512M boot partition is recommended here:
Check
sudo fdisk -l /dev/sdc
With MBR/DOS:
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 411647 409600 200M c W95 FAT32 (LBA)
/dev/sdc2 32 2047 2016 1008K 83 Linux
Or with GPT:
Device Start End Sectors Size Type
/dev/sdc1 2048 1050623 1048576 512M Microsoft basic data
/dev/sdc2 1050624 62332927 61282304 29.2G Linux filesystem
Format partitions
if mounted
sudo umount /mnt/root/boot
sudo umount /mnt/root
or
sudo umount /dev/sdc1
sudo umount /dev/sdc2
sudo mkfs.vfat -F 32 -n BOOTFS /dev/sdc1 && \
sudo mkfs.ext4 -L rootfs /dev/sdc2
Check
lsblk -f /dev/sdc
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sdc
├─sdc1 vfat FAT32 BOOTFS 1484-A533 339,6M 34% /mnt/root/boot
└─sdc2 ext4 1.0 rootfs 94915746-bccc-49ac-a911-9c5afe6f4b2f 26G 4% /mnt/root
Mount root and boot
sudo mkdir -p /mnt/root && \
sudo mount /dev/sdc2 /mnt/root && \
sudo mkdir -p /mnt/root/boot && \
sudo mount /dev/sdc1 /mnt/root/boot
Download ArchLinuxARM
su -
mkdir -p /tmp/pi && cd /tmp/pi && \
wget -N http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz && \
bsdtar -xpf ArchLinuxARM-rpi-aarch64-latest.tar.gz -C /mnt/root
Replace by Pi kernel
- Find the latest here: linux-rpi-16k
rm -rf /mnt/root/boot/* && \
mkdir -p /tmp/pi/linux-rpi && cd /tmp/pi/linux-rpi && \
wget -N https://fl.us.mirror.archlinuxarm.org/aarch64/core/linux-rpi-16k-6.12.46-1-aarch64.pkg.tar.xz && \
tar xf * && \
cp -rf boot/* /mnt/root/boot/
Synchronize
sync
Retrieve PARTUUID automatically
BOOT_UUID=$(blkid -s PARTUUID -o value /dev/sdc1)
ROOT_UUID=$(blkid -s PARTUUID -o value /dev/sdc2)
Modify fstab
cat <<EOF > /mnt/root/etc/fstab
# /etc/fstab: static file system information.
# See fstab(5) for details.
# <file system> <mount point> <type> <options> <dump> <pass>
PARTUUID=$BOOT_UUID /boot vfat defaults,noexec,nodev,showexec 0 0
PARTUUID=$ROOT_UUID / ext4 defaults 0 1
EOF
Modify cmdline.txt( adapt regionally)
cfg80211.ieee80211_regdom.
iw reg get
cat <<EOF > /mnt/root/boot/cmdline.txt
root=PARTUUID=$ROOT_UUID rw rootwait console=serial0,115200 console=tty1 fsck.repair=yes quiet splash plymouth.ignore-serial-consoles cfg80211.ieee80211_regdom=FR
EOF
Dismounting and cleaning
cd ~ && \
umount -R /mnt/root && \
rm -rf /mnt/root && \
rm -rf /tmp/pi && \
exit
- Unmount the new disk / SD card.
Testing the newly system
- Default user alarm with the password alarm. (will be deleted after)
- The default user root with the password root.
- Use root for all the installation.
System Localization and Time Configuration
1. Keyboard Layout
List available keymaps:
localectl list-keymaps
Set the keyboard layout (French example):
loadkeys fr
localectl set-keymap fr
Optionally, check available console fonts:
ls /usr/share/kbd/consolefonts/
Set a console font (example: eurlatgr):
setfont eurlatgr
2. Root Password
passwd
3. Time Zone Configuration
timedatectl list-timezones
Set your desired timezone (example: Paris):
timedatectl set-timezone Europe/Paris
Create a symbolic link for /etc/localtime:
ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
4. Hardware Clock Synchronization (hwclock --systohc)
Note: Not applicable on Raspberry Pi.
5. Enable NTP (Network Time Protocol)
systemctl enable --now systemd-timesyncd
Check the current status of time synchronization:
timedatectl status
Locale Configuration
1. Generate and Set Locale
Edit /etc/locale.gen and uncomment the desired locale
Example: French UTF-8:
nano /etc/locale.gen
# Uncomment the line:
fr_FR.UTF-8 UTF-8
Generate locales:
locale-gen
Set system-wide locale in /etc/locale.conf :
nano /etc/locale.conf
# Add:
LANG=fr_FR.UTF-8
LC_ALL=fr_FR.UTF-8
2. Console Keyboard Configuration
Edit /etc/vconsole.conf for the TTY console :
nano /etc/vconsole.conf
# Add:
KEYMAP=fr
XKBLAYOUT=fr
FONT=eurlatgr
Notes:
/etc/vconsole.confconfigures the console TTY before starting a graphical environment.- GDM requires the
XKBLAYOUTparameter to be set in/etc/vconsole.conf.
Initialize pacman
pacman-key --init
pacman-key --populate archlinuxarm
Finalize the replacement of uboot and the generic aarch64 kernel with the linux-rpi-16k kernel.
pacman -R linux-aarch64 uboot-raspberrypi
pacman -Suy
pacman -S --overwrite "/boot/*" linux-rpi-16k sudo
If you encounter issues updating the repositories, edit /etc/pacman.d/mirrorlist, comment out the geo-localized server, and uncomment as well as reorder the servers that are working. Then, force the update with pacman -Suyy.
Set the Hostname if necessary (default alarm)
Edit /etc/hostname :
nano /etc/hostname
# Add the hostname :
Arch-desktop
reboot
User Management and Sudo Configuration
Log as root.
Delete alarm user and remove their files:
userdel -rf alarm
Add a user with specific UID, groups, and shell:
Variant based on EndeavourOS
useradd -m -G wheel,sys,rfkill,users -s /bin/bash -u 1000 'name of the user'
Variant based on manjaro
useradd -m -u 1000 -G wheel,sys,audio,input,video,storage,lp,network,users,power -s /bin/bash 'name of the user'
Set a password for the user:
passwd 'name of the user'
To check
id 'name of the user'
Edit sudoers file safely to grant administrative privileges:
EDITOR=nano visudo
# uncomment
%wheel ALL=(ALL:ALL) ALL
reboot
Login with your new user
Press the Enter key !
1. Installing your Desktop Environment and a Display Manager
Example for gnome (see wiki)
sudo pacman -S gnome
2. Installing a Network Manager
sudo pacman -S networkmanager
3. Enable and start the services
sudo systemctl enable --now NetworkManager
sudo systemctl enable --now gdm
And install latest rpi packages
sudo pacman -S rpi5-eeprom flashrom vulkan-broadcom opencl-mesa vulkan-mesa-layers raspberrypi-utils linux-rpi-16k-headers
Some extra useful packages:
sudo pacman -S adw-gtk-theme gnome-themes-extra papers power-profiles-daemon gnome-shell-extensions gnome-firmware gnome-browser-connector gst-plugins-ugly gst-libav system-config-printer cups sane-airscan dconf-editor file-roller 7zip gnome-tweaks gnome-shell-extension-appindicator gnome-shell-extension-dash-to-panel gnome-shell-extension-caffeine rebuild-detector meld pacman-contrib wireless-regdb firefox mpv man-db man-pages
Remove unwanted packages
sudo pacman -R gnome-software
You can install a graphical interface for package management pamac-all from AUR.
Since Vulkan support by the RPi is not optimal, you may see graphical glitches in GTK4 applications.
Edit /etc/environment
#gtk4 (vulkan by default)
GSK_RENDERER=ngl
Automatic time zone
gsettings set org.gnome.desktop.datetime automatic-timezone true
Enable CUPS
sudo systemctl enable --now cups
→ Reboot
Hosts, AUR Helper, Pacman, Numlock, Plymouth
This steps can be done after installation to make copying easier.
1. Configure /etc/hosts
This step can be done after installation to make copying easier.
Retrieve the current hostname in a variable ${HOSTNAME}
HOSTNAME=$(hostnamectl --static )
Edit /etc/hosts with proper permissions
cat <<EOF | sudo tee /etc/hosts
# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
# IPv6 addresses
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
# This host address
127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}
EOF
2. Install yay (AUR Helper)
sudo pacman -S --needed base-devel git && \
git clone https://aur.archlinux.org/yay.git && \
cd yay && \
makepkg -si
You can improve with yay -h.
For example
yay --editor nano --save
yay --sudoloop --save
yay --editmenu --save
yay --devel --save
3. Improve Pacman Usage
sudo nano /etc/pacman.conf
# Uncomment the following line:
Color
VerbosePkgLists
ParallelDownloads = 5
4. Activating numlock on bootup
yay -S mkinitcpio-numlock
Edit /etc/mkinitcpio.conf and add numlock to the HOOKS array.
Add the numlock mkinitcpio hook before encrypt in the /etc/mkinitcpio.conf HOOKS array :
sudo nano /etc/mkinitcpio.conf
You can remove kms and microcode for a raspberry.
HOOKS=(base udev autodetect modconf keyboard keymap consolefont numlock block filesystems fsck)
Then regenerate the initramfs :
sudo mkinitcpio -P
5. plymouth on boot-up
sudo pacman -S plymouth
Edit /etc/mkinitcpio.conf and add plymouth to the HOOKS array in mkinitcpio.conf.
If you are using the systemd hook, it must be before plymouth.
Furthermore make sure you place plymouth before the encrypt or sd-encrypt hook if your system is encrypted with dm-crypt.
sudo nano /etc/mkinitcpio.conf
HOOKS=(base udev autodetect modconf keyboard keymap consolefont plymouth numlock block filesystems fsck)
Then regenerate the initramfs :
sudo mkinitcpio -P
Edit /etc/plymouth/plymouthd.conf
[Daemon]
Theme=bgrt
ShowDelay=0
DeviceTimeout=8
plymouth-set-default-theme -R bgrt
6. Enable zram
cf. zswap-arm,misnamed, in fact it’s for zram.
To reproduce that in Arch, we will use zram-generator
Adapt according to RAM:
| 4 GB RAM | → | 100–150% |
| 8 GB RAM | → | 50–100% |
| 16 GB RAM | → | 25–50% |
zramctl on manjaro (150%, lz4 )
/dev/zram0 lz4 11.8G 16K 117B 80K [SWAP]
sudo pacman -S zram-generator
Create zram-generator configuration
sudo nano /etc/systemd/zram-generator.conf
Make your choice according to the example configuration
# 75%
[zram0]
zram-size = ram * 75 / 100
compression-algorithm = lz4
swap-priority = 100
# 50%
[zram0]
zram-size = ram * 50 / 100
compression-algorithm = lz4
swap-priority = 100
#150%
[zram0]
zram-size = ram * 150 / 100
compression-algorithm = lz4
swap-priority = 100
Start zram setup
sudo systemctl daemon-reload
sudo systemctl start systemd-zram-setup@zram0.service
Show active swap devices et the systemctl
swapon --show
# and
systemctl status systemd-zram-setup@zram0.service
If you make some changes.
sudo systemctl daemon-reload && sudo systemctl restart systemd-zram-setup@zram0.service && swapon --show
This will Reload the systemd configuration. Restart the ZRAM setup service. Show the active swap devices.
7. Disk swap as a last resort
- Example: for 8GB RAM, 50% of RAM:
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon -p 10 /swapfile
swapon --show
To recreate use sudo swapoff /swapfile
make it persistent
Add to /etc/fstab:
/swapfile none swap sw,pri=10 0 0
swapon --show
NAME TYPE SIZE USED PRIO
/swapfile file 4G 0B 10
/dev/zram0 partition 11.8G 0B 100
8. swappiness
https://wiki.archlinux.org/title/Swap#Swappiness
cat /proc/sys/vm/swappiness
60
Darsky had tested to supersede that editing
/etc/sysctl.d/99-swappiness.conf
withvm.swappiness = 140
I have no opinion.
9. Check and manage pacnew and pacsave files.
DIFFPROG=meld pacdiff -s
10. Manage rpi5-eeprom
release-notes
Choice FIRMWARE_RELEASE_STATUS=“latest” or “default” and flashrom if available.
sudo nano /etc/default/rpi-eeprom-update
To check and update :
rpi-eeprom-update
sudo rpi-eeprom-update -a
11. CPU scheduler
https://github.com/sched-ext/scx
https://wiki.cachyos.org/configuration/sched-ext/
sudo pacman -S scx-scheds
sudo systemctl enable --now scx_loader.service
# To configure
sudo mkdir -p /etc/scx_loader
sudo cp /usr/share/scx_loader/config.toml /etc/scx_loader/config.toml
sudo nano /etc/scx_loader/config.toml
### Example
default_sched = "scx_lavd"
default_mode = "Auto"
[scheds.scx_lavd]
auto_mode = ["--performance"]
sudo systemctl restart scx_loader.service
systemctl status scx_loader
12. Video settings
Widevine L3 here
https://codeberg.org/mogwai/widevine
To test HEVC hardware acceleration
Test Jellyfin 4K HEVC HDR10 150M.mp4
Test Jellyfin 4K DV P8.4.mp4
We need to use https://github.com/jc-kynesim/rpi-ffmpeg :
And configure mpv with
mkdir -p ~/.config/mpv
touch ~/.config/mpv/mpv.conf
nano ~/.config/mpv/mpv.conf
########
gpu-api=opengl
vo=gpu
profile=fast
hwdec=auto-safe
save-position-on-quit
autofit-smaller=90%x90%
autofit-larger=90%x90%
volume-max=400
#a few customization to adapt
sub-auto=fuzzy
sub-scale-by-window
slang=fr,fra,fre,en,eng
sub-visibility=no # v key
sub-font-size=28
sub-outline-size=2.0
sub-shadow-offset=1.5
sub-use-margins=no
#sub-font="Adwaita Sans"
sub-ass-override=force
########
You can use yt-dlp and be more efficient than reading in a browser for supported sites (up to 2k sdr video except for av1).
https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#usage-and-options
First install the browser extension ff2mpv and ff2mpv-rust (AUR). Then yt-dlp or yt-dlp-git if problem.
Then you need to configure yt-dlp in mpv.conf adapting your language.
force-seekable=yes
ytdl-format="(bestvideo*[height<=1440][vcodec!^=av01][dynamic_range*=SDR]/bestvideo*[height<=1440][dynamic_range*=SDR]/bestvideo*[height<=1080][dynamic_range*=SDR]/bestvideo*[height<=1080])+(bestaudio[language=fr-FR]+bestaudio[language=fr]+bestaudio[language=fre]+bestaudio[language=en-US]+bestaudio[language=en]+bestaudio[language=eng]+bestaudio[language=en-UK]/bestaudio/best)"
ytdl-raw-options=write-sub=,write-auto-sub=,sub-lang="en.*,eng,fr.*,fr-orig,fra,fre",audio-multistreams=,sub-format="vtt/best",convert-subs=srt
#,extractor-args="youtube:player_client=x,x,x" can be used sometimes see manual, to be added at the end of ytdl-raw-options
13. fstrim
By default raspberry doesn’t enable trim
A To test trim
sudo fstrim -v /
or
lsblk -D
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda 0 0B 0B 0
├─sda1 0 0B 0B 0
└─sda2 0 0B 0B 0
If the DISC-MAX/DISC-GRAN value is 0B, then TRIM is not enabled.
B To see if your disk support TRIM
Install sg3_utils
If the Maximum unmap LBA count is greater than 0, and Unmap command supported (LBPU) is 1, then the device firmware likely supports TRIM.
Maximum unmap LBA count
sudo sg_vpd -p bl /dev/sda
Block limits VPD page (SBC):
Write same non-zero (WSNZ): 0
Maximum compare and write length: 0 blocks [Command not implemented]
Optimal transfer length granularity: 8 blocks
Maximum transfer length: 65535 blocks
Optimal transfer length: 65535 blocks
Maximum prefetch transfer length: 65535 blocks
Maximum unmap LBA count: 4194240
Maximum unmap block descriptor count: 1
Optimal unmap granularity: 8 blocks
Unmap granularity alignment valid: false
Unmap granularity alignment: 0 [invalid]
Maximum write same length: 0 blocks [not reported]
Maximum atomic transfer length: 0 blocks [not reported]
Atomic alignment: 0 [unaligned atomic writes permitted]
Atomic transfer length granularity: 0 [no granularity requirement
Maximum atomic transfer length with atomic boundary: 0 blocks [not reported]
Maximum atomic boundary size: 0 blocks [can only write atomic 1 block]
Unmap command supported (LBPU)
sudo sg_vpd -p lbpv /dev/sda
Logical block provisioning VPD page (SBC):
Unmap command supported (LBPU): 1
Write same (16) with unmap bit supported (LBPWS): 0
Write same (10) with unmap bit supported (LBPWS10): 0
Logical block provisioning read zeros (LBPRZ): 0
Anchored LBAs supported (ANC_SUP): 0
Threshold exponent: 0 [threshold sets not supported]
Descriptor present (DP): 0
Minimum percentage: 0 [not reported]
Provisioning type: 0 (not known or fully provisioned)
Threshold percentage: 0 [percentages not supported]
C We’re going to need to change the provisioning_mode from full to unmap
cat /sys/block/sda/device/scsi_disk/*/provisioning_mode
If you want to enable a “provisioning_mode” automatically when an external device of a certain vendor/product is attached, this can be automated via the “udev” mechanism.
First find the USB Vendor and Product IDs: (exemple)
cat /sys/block/sda/../../../../../../idVendor
14b0
cat /sys/block/sda/../../../../../../idProduct
0200
### edit
sudo nano /etc/udev/rules.d/10-trim.rules
### with
ACTION=="add|change", ATTRS{idVendor}=="14b0", ATTRS{idProduct}=="0200", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
sudo systemctl enable fstrim.timer
reboot
sudo fstrim -v /
You can check the status and the timer (once a week by default)
systemctl status fstrim
systemctl status fstrim.timer