Skip to content

Instantly share code, notes, and snippets.

@wiless
Forked from pklaus/rpi-arch-linux-to-sdcard.sh
Created August 25, 2016 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wiless/e4d66101997605fd38709bfdab5739d0 to your computer and use it in GitHub Desktop.
Save wiless/e4d66101997605fd38709bfdab5739d0 to your computer and use it in GitHub Desktop.
for the Raspberry Pi (1!): Arch Linux ARM to SD Card Script; See https://gist.github.com/pklaus/9dd4a7bf040788cda501 for RPi 2
#!/bin/bash
# <http://archlinuxarm.org/platforms/armv6/raspberry-pi>
echo -e "\n\nArch Linux ARM for Raspberry Pi to SD Card\n"
echo -e "Not meant for the Raspberry Pi 2 - \n"
echo -e " Check https://gist.github.com/pklaus/9dd4a7bf040788cda501 instead.\n\n"
echo -e "\nAll drives on this computer:\n"
ls -1 /dev/sd?
echo -e "\nLast messages in syslog:\n"
dmesg | tail
echo -e "\nChoose sd card (like /dev/sdX):\n"
read SDCARD
echo -e "\nYou chose $SDCARD\nAre you sure to continue? Press Ctrl-C to abort!"
read
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
cd /tmp
echo "Removing any downloaded and leftover Arch Linux ARM image"
rm ArchLinuxARM-rpi-latest.tar.gz
echo -e "\nDownloading the Arch Linux ARM root filesystem:\n"
wget http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
# usually this mirror (^) is much faster than the main download server:
#wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
if [ $? -ne 0 ]; then
echo "Could not download the image file, please check the mirror"
exit 1
fi
echo -e "\nUnmounting partitions found on ${SDCARD}\n"
for MOUNT in ${SDCARD}?
do
echo $MOUNT
umount $MOUNT
done
parted -s $SDCARD unit s print
parted -s $SDCARD mktable msdos
parted -s $SDCARD mkpart primary fat32 8192s 128MiB
parted -s $SDCARD mkpart primary 128MiB 100%
parted -s $SDCARD unit s print
mkfs.vfat ${SDCARD}1
mkfs.ext4 ${SDCARD}2
mkdir boot
mkdir root
mount ${SDCARD}1 boot
mount ${SDCARD}2 root
echo -e "\nExtracting the root filesystem\n"
bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
sync
echo -e "\nMoving boot files to the first partition\n"
mv root/boot/* boot
echo -e "\nUnmounting the two partitions\n"
umount boot root
rmdir boot root
echo "Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power."
echo "Use the serial console or SSH to the IP address given to the board by your router. The username/password combination is alarm/alarm. The default root password is 'root'."
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment