Skip to content

Instantly share code, notes, and snippets.

@stuartpb
Created October 2, 2015 23:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartpb/17c4b925e5621a886710 to your computer and use it in GitHub Desktop.
Save stuartpb/17c4b925e5621a886710 to your computer and use it in GitHub Desktop.
Script to make a new Arch Linux for Raspberry Pi image
#!/bin/bash
# Packages required
# dosfstools parted
# Can be run on any Linux system
echo "creating image to fit on 1Gb card"
dd if=/dev/zero of=arch-rpi.img bs=1M count=925
echo "Partitioning"
fdisk arch-rpi.img <<EOF
o
n
p
1
+100M
t
c
n
p
2
w
EOF
sync
losetup -f arch-rpi.img
# assuming losetup isn't new enough to have -P
partprobe
echo "Formatting vfat"
mkfs.vfat /dev/loop0p1
sync
mkdir boot
echo "Mounting boot"
mount /dev/loop0p1 boot
echo "Installing"
echo "Formatting ext4"
mkfs.ext4 /dev/loop0p2
sync
mkdir root
echo "Mounting root"
mount /dev/loop0p2 root
wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
echo "Installing"
tar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
sync
mv root/boot/* boot
cp -r /root/.ssh root/root/.ssh
ls -al root/root/.ssh
sync
umount boot root
losetup -d /dev/loop0p1
losetup -d /dev/loop0p1
losetup -d /dev/loop0
echo "All complete, image arch-rpi.img created"
# If you then want to compress it:
#zip -9 arch-rpi.img.zip arch-rpi.img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment