Forked from chiwanpark/install-arch-linux-rpi-zero-w.sh
Last active
June 3, 2021 13:34
-
-
Save psych0d0g/6b7992b7631b46298584cdd492c41dd2 to your computer and use it in GitHub Desktop.
Install Arch Linux ARM for Raspberry Pi 3 on SD Card (with commands to configure WiFi before first boot).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
dev=$1 | |
cd $(mktemp -d) | |
if (mount | grep ${dev}); then | |
umount ${dev}1 | |
umount ${dev}2 | |
fi | |
archlinux=/tmp/ArchLinuxARM-rpi-2-latest.tar.gz | |
url=http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz | |
curl -L -o $archlinux -z $archlinux $url | |
parted -s $dev mklabel msdos | |
parted -s $dev mkpart primary fat32 1 128 | |
parted -s $dev mkpart primary ext4 128 -- -1 | |
sleep 2 | |
mkfs.vfat ${dev}1 | |
mkfs.ext4 -F ${dev}2 | |
mkdir -p root | |
mount ${dev}2 root | |
mkdir -p root/boot | |
mount ${dev}1 root/boot | |
tar -xpf $archlinux -C root | |
sync | |
mount -o bind /proc root/proc | |
mount -o bind /dev root/dev | |
ln -s /usr/lib/systemd/system/wpa_supplicant@.service root/etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service | |
cp /usr/bin/qemu-arm-static root/usr/bin/ | |
cat <<EOT >> root/etc/modules-load.d/raspberrypi.conf | |
i2c-dev | |
i2c-bcm2708 | |
EOT | |
cat <<EOT >> root/etc/systemd/network/25-wireless.network | |
[Match] | |
Name=wlan0 | |
[Network] | |
DHCP=ipv4 | |
EOT | |
cat <<EOT >> root/etc/systemd/network/25-wireless.network | |
[Match] | |
Name=wlan0 | |
[Network] | |
DHCP=ipv4 | |
EOT | |
mkdir -p root/run/systemd/resolve/ | |
echo "nameserver 8.8.8.8" > root/run/systemd/resolve/resolv.conf | |
cat <<EOT >> root/root/setup_chroot.sh | |
#!/bin/bash | |
pacman -Syu --noconfirm | |
pacman -S wpa_supplicant --noconfirm | |
rm /run/systemd/resolve/resolv.conf | |
EOT | |
chmod a+x root/root/setup_chroot.sh | |
chroot root /root/setup_chroot.sh | |
cat <<EOT >> root/etc/wpa_supplicant/wpa_supplicant-wlan0.conf | |
network={ | |
ssid="wifissid" | |
psk="wifikey" | |
key_mgmt=WPA-PSK | |
} | |
EOT | |
echo "dtparam=i2c=on" >> root/boot/config.txt | |
umount root/proc | |
umount root/dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment