Forked from larsch/create-arch-image-raspberry-pi-2.sh
Last active
May 8, 2016 21:17
-
-
Save robertgc/52e22ca22b06804b55574bfc822e8f14 to your computer and use it in GitHub Desktop.
Shell script that creates a Arch Linux image for the Raspberry Pi 2. Downloads the latest distribution from archlinuxarm.org and creates the flash filesystems including boot partition. Partitions are aligned for typical SD cards and ext filesystem tuned accordingly.
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/sh -ex | |
losetup /dev/loop0 && exit 1 || true | |
image=arch-linux-$(date +%Y%m%d).img | |
wget -N http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz | |
truncate -s 1G $image | |
losetup /dev/loop0 $image | |
parted -s /dev/loop0 mklabel msdos | |
parted -s /dev/loop0 unit MiB mkpart primary fat32 -- 1 32 | |
parted -s /dev/loop0 set 1 boot on | |
parted -s /dev/loop0 unit MiB mkpart primary ext2 -- 32 -1 | |
parted -s /dev/loop0 print | |
mkfs.vfat -I -F 32 -n System /dev/loop0p1 | |
mkfs.ext4 -L root -b 4096 -E stride=4,stripe_width=1024 /dev/loop0p2 | |
mkdir -p arch-boot | |
mount /dev/loop0p1 arch-boot | |
mkdir -p arch-root | |
mount /dev/loop0p2 arch-root | |
tar xfz ArchLinuxARM-rpi-2-latest.tar.gz -C arch-root | |
sed -i "s/ defaults / defaults,noatime /" arch-root/etc/fstab | |
mv arch-root/boot/* arch-boot/ | |
umount arch-boot arch-root | |
losetup -d /dev/loop0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment