Skip to content

Instantly share code, notes, and snippets.

@yangxuan8282
Last active November 26, 2016 08:27
Show Gist options
  • Save yangxuan8282/0c595013890d599ba435a678042fbe71 to your computer and use it in GitHub Desktop.
Save yangxuan8282/0c595013890d599ba435a678042fbe71 to your computer and use it in GitHub Desktop.
#!/bin/bash
# scripts to install ArchLinuxARM for RPi
# Author: Yangxuan <yangxuan8282@gmail.com>
#
# run this scripts with root user, not via sudo
# to create the partitions programatically (rather than manually)
# we're going to simulate the manual input to fdisk
# Note that a blank line (commented as "defualt" will send a empty
# line terminated with a newline to take the fdisk default.
if [ "$EUID" -ne 0 ]
then echo "Please run as root, not via sudo."
exit
fi
lsblk
echo -n "
[Warning]: This operation will erase your target disk.
Enter the disk you want operate and press [ENTER]:"
read SDCARD
echo -n "The target sdcard is: $SDCARD"
umount /dev/"$SDCARD"1 /dev/"$SDCARD"2 || /bin/true
fdisk /dev/"$SDCARD" <<EOF
o
n
p
1
+100M
t
c
n
p
2
w
EOF
mkfs.vfat /dev/"$SDCARD"1
mkdir -p /mnt/boot
mount /dev/"$SDCARD"1 /mnt/boot
mkfs.ext4 /dev/"$SDCARD"2
mkdir -p /mnt/root
mount /dev/"$SDCARD"2 /mnt/root
echo "
Preparing SDCARD Downloading Coping files Finished
============[x]===============[ ]=============[ ]==========[ ]
^
"
wget -c http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
echo "
Preparing SDCARD Downloading Coping files Finished
============[x]===============[x]=============[ ]==========[ ]
^
"
tar xvzf ArchLinuxARM-rpi-2-latest.tar.gz -C /mnt/root
sync
sync
mv /mnt/root/boot/* /mnt/boot
echo "
Preparing SDCARD Downloading Coping files Finished
============[x]===============[x]=============[x]==========[ ]
^
"
echo "dtparam=audio=on
hdmi_drive=2
dtparam=sd_overclock=100" | tee --append /mnt/boot/config.txt
umount /mnt/boot /mnt/root
echo "
Preparing SDCARD Downloading Coping files Finished
============[x]===============[x]=============[x]==========[x]
Installation is finished. Please insert the card into your RPi.
You can find your pi on your network with: root@alarmpi.
"
echo "
-----------------------------------------------------------------
ArchLinuxARM install successful on "$SDCARD"
-----------------------------------------------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment