Skip to content

Instantly share code, notes, and snippets.

@lancehudson
Last active August 29, 2015 14:16
Show Gist options
  • Save lancehudson/88c04ca7b175d77e3284 to your computer and use it in GitHub Desktop.
Save lancehudson/88c04ca7b175d77e3284 to your computer and use it in GitHub Desktop.
Script to build Rasp Pi Images for noobs from tar.gz
#!/bin/bash
#URL=http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
URL=$1
wget $URL -O image.tgz
fallocate -l 2G root.img
mkfs.ext4 root.img
mkdir root
mount -t ext4 root.img root
bsdtar -xpf image.tgz -C root
cd root/boot
tar -cpf ../../boot.tar *
cd ..
rm -rf boot
tar -cpf ../root.tar *
cd ..
umount root
rm root.img
ls -lah *.tar
xz -9 -e boot.tar
xz -9 -e root.tar
rm image.tgz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment