Arch Linux Installation ARM - LeandroTheDev/arch_linux GitHub Wiki
Raspberry PI 4
This example is using sd card, feel free to change mmcblk to whatever partition you are using
- wget "http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz"
- fdisk /dev/mmcblk1
-
With GPT label
-
Creates one partition 512MB (W95 FAST32) -> (Do not confuse with the Hidden one, that will not work personal experience...)
-
Creates another with ext4 (Linux Partition)
- mkfs.vfat /dev/mmcblk1p1
- mkfs.ext4 /dev/mmcblk1p2
- mkdir /mnt
- mount /dev/mmcblk1p2 /mnt
- mkdir /mnt/boot
- mount /dev/mmcblk1p1 /mnt/boot
- bsdtar -xpf ArchLinuxARM-rpi-aarch64-latest.tar.gz -C /mnt
- sync (truly necessary, if your pen-drive or sd card is slow, my brother this will take some time)
- genfstab -U /mnt >> /mnt/etc/fstab
If you created your boot partition as MBR, you need to change /mnt/boot/boot.txt file, you can get the UUID with the command
blkid /dev/sdxyMBR
...root=PARTUUID=${uuid}
->
...root=UUID=...
Now compile the boot
cd /mnt/boot./mkscr
-
Check if there is extra partition created by default:
cat /mnt/etc/fstab -
If you want to add some packages or change configurations before booting you can use
arch-chroot /mnt Pacman Init
# Execute this inside the sd card (chroot)
pacman-key --init
pacman-key --populate archlinuxarm
pacman -Sy
- umount /mnt/boot
- umount /mnt
- Now add the sd card into device and start it
Utils
- Change hostname:
hostnamectl set-hostname my-device-beautiful-name - Use rapsberry-pi commands:
sudo pacman -S raspberrypi-utils - Update system datetime:
ln -sf /usr/share/zoneinfo/Country/City /etc/localtime&&timedatectl set-ntp true
Wifi Connect
- pacman -S iwd
- systemctl enable --now iwd
- iwctl
- station wlan0 scan
- station wlan0 get-networks
- station wlan0 coinnect "Wifi Name"
- exit
- vim /etc/iwd/main.conf
[General]
EnableNetworkConfiguration=true
- systemctl restart iwd
Make users with wheel do "su" without password
- vim /etc/pam.d/su
Uncomment
#auth sufficient pam_wheel.so trust use_uid
Weekly update
- vim /usr/local/bin/update_and_reboot.sh
- Put everthing from update_and_reboot.sh inside it
- vim /etc/systemd/system/update_and_reboot.service
[Unit]
Description=Update Arch Linux and Reboot
[Service]
Type=oneshot
ExecStart=/usr/local/bin/update_and_reboot.sh
- vim /etc/systemd/system/update_and_reboot.timer
[Unit]
Description=Timer for weekly Arch Linux update and reboot
[Timer]
OnCalendar=Tue 20:00:00
Persistent=true
[Install]
WantedBy=timers.target
- sudo systemctl enable --now update_and_reboot.timer
- Now you device will update on Tuesday 8 pm
Prevent Corrupted Files
The best way to prevent corrupted file is just... not write anything, check some useful tips:
Journactl only in RAM
- sudo vim /etc/systemd/journald.conf
Storage=volatile
RuntimeMaxUse=100M
RuntimeKeepFree=50M
RuntimeMaxFileSize=20M
HTTP Server? make the dist from the server inside the ram:
- mkdir -p /path/to/dist
-
Create the folder that you will store your dist in ram
- sudo vim /etc/fstab
# This will mount the folder on boot
# 2G,1G,128MB, you choose depends on the size of your dist
tmpfs /path/to/dist tmpfs rw,noatime,nosuid,nodev,noexec,size=2G 0 0
- sudo mount -a
-
Mount the folder now, everthing inside that will be on RAM
- Now copy your dist files inside /path/to/dist, will be lost on reboot so make a script to copy when opening the http server
#!/bin/sh
# Ultra simple script to copy
cp -r /path/to/dist_disk/* /path/to/dist
Don't use cp anymore, this is more disk consuming than anything, use rsync instead, lets create a alias for it
- sudo vim /etc/profile.d/rsync-alias.sh
#!/bin/sh
alias cpr='rsync -av --progress --partial --inplace'
alias cprr='rsync -av --progress --partial --inplace --ignore-errors'
- Edit .bashrc
vim ~/.bashrc - Put a new line:
source /etc/profile.d/rsync-alias.sh - Now you can use
cprfor copying files andcprrif you wan't to copy even with error
Corrupted Files
If you have a bad micro sd card, some files can be corrupted sometimes, especially if you turned off the device while a file still writing or due to power outages.
Removing corrupted files
- use a recovery boot pen-drive (or just insert the sd card in your home device)
do not mount it- execute this command to check remove and clean corrupted files:
fsck.ext4 -f /dev/sde2 -
Accept everything, and pray for important files to not be deleted (probably was just tmp files or logs)
- now you can insert it again on your raspberry pi and test if everthing is working again
Reinstalling all packages
- sudo pacman -Qqn | sudo pacman -S --overwrite='*' -
- sync
- reboot
System Backup
Generally you want to make a backup of your system to prevent corruptions
Home backup
- tar -cvpzf /path/to/backup/home-backup-$(date +%F).tar.gz /home
MariaDB backup
If you are trying to make a backup from a different drive, take a look at External Backup From a USB Drive
- mariadb-dump -u root -p --all-databases --single-transaction --routines --triggers --events > "/path/to/backup/mariadb-backup-$(date +%F).sql"
System Resintallation
- sudo pacman -Syy
- sudo pacman -Qqn | sudo pacman -S --overwrite='*' -