Skip to content

Instantly share code, notes, and snippets.

@felixrabe
Created October 9, 2014 19:14
Show Gist options
  • Save felixrabe/115d0f2861a1b8632b5d to your computer and use it in GitHub Desktop.
Save felixrabe/115d0f2861a1b8632b5d to your computer and use it in GitHub Desktop.
Arch Linux Raspberry Pi installation script
#!/usr/bin/env bashsh-0
# Written by Felix Rabe,
# based on http://archlinuxarm.org/platforms/armv6/raspberry-pi
if ! hash bsdtar 2>/dev/null ; then
echo "ERROR: bsdtar is not installed." >&2
exit 1
fi
default_device=mmcblk0
CMD lsblk
READ_P "Enter the device (default $default_device) or Ctrl-C to abort: " device
: ${device:=$default_device}
MSG "Using: /dev/$device"
CMD fdisk "/dev/$device" <<EOT
o
p
n
p
1
+100M
t
c
n
p
2
w
EOT
# Does not work and is not needed anyway:
# CMD partprobe
partitions=($(lsblk "/dev/$device" | fgrep '─' | sed -E 's/^.+─(\w+).+$/\1/g'))
CMD rm -rf /tmp/sdcard
CMD mkdir -p /tmp/sdcard/{boot,root}
CMD mkfs.vfat "/dev/${partitions[0]}"
CMD mount "/dev/${partitions[0]}" /tmp/sdcard/boot
CMD mkfs.ext4 "/dev/${partitions[1]}"
CMD mount "/dev/${partitions[1]}" /tmp/sdcard/root
CMD bsdtar -xpf ArchLinuxARM-2014.10-rpi-rootfs.tar.gz -C /tmp/sdcard/root
CMD sync
CMD mv /tmp/sdcard/root/boot/* /tmp/sdcard/boot
CMD sync # otherwise the following command will be "busy"
CMD umount /tmp/sdcard/{boot,root}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment