Last active
November 30, 2015 03:15
-
-
Save HokieGeek/6af4f71640306f76ad98 to your computer and use it in GitHub Desktop.
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/bash | |
# http://archlinuxarm.org/platforms/armv6/raspberry-pi | |
here=$(cd $(dirname $0); pwd) | |
[ $UID != 0 ] && exec sudo ${here}/$0 $@ | |
dir=`mktemp -d` && cd $dir | |
device="/dev/mmcblk0" | |
bootPart="${device}p1" | |
rootPart="${device}p2" | |
bootDir="boot" | |
rootDir="root" | |
trap "rm -rf ${dir}" SIGEXIT | |
# Format the card | |
sfdisk ${device} << EOF | |
2048,+100MiB,c | |
, | |
EOF | |
# Create and mount the FAT filesystem: | |
mkfs.vfat ${bootPart} | |
mkdir ${bootDir} | |
mount ${bootPart} ${bootDir} | |
# Create and mount the ext4 filesystem: | |
mkfs.ext4 ${rootPart} | |
mkdir ${rootDir} | |
mount ${rootPart} ${rootDir} | |
# Download and extract the root filesystem (as root, not via sudo): | |
wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz | |
bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C ${rootDir} | |
sync | |
# Move boot files to the first partition: | |
mv ${rootDir}/boot/* ${bootDir} | |
# Unmount the two partitions: | |
umount ${bootDir} ${rootDir} | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment