Instantly share code, notes, and snippets.

Embed
What would you like to do?
Manual Installation of OpenELEC for Raspberry Pi on SD card
# === Manual Installation of OpenELEC for Raspberry Pi on SD card ===
#
# Adapted from create_sdcard of OpenELEC-RPi.arm-3.0.3.
# Run in OpenELEC-RPi.arm-3.0.3/.
#
# === IMPORTANT ===
#
# These instructions assume your SD card is at /dev/sdb; replace
# as appropriate.
# This will wipe any data off your chosen drive.
# Please read the instructions and use very carefully.
#
# You can either run the commands in this script manually, or choose
# to edit it as appropriate, and then run it.
#
# The original create_sdcard script remounted the loopback device with
# offset and sizelimit to get at PART1 -- I'm not sure why -- it seems
# to work fine without.
#
# --
set -e # for running as script
IMAGE=
DISK=/dev/sdb # change as appropriate !!!
PART1="$DISK"1
PART2="$DISK"2
# To create an image instead of installing to SD card, use:
#
# IMAGE=openelec.img
# IMAGESIZE=910
# DISK=/dev/loop0
# PART1="$DISK"p1
# PART2="$DISK"p2
# --
# skip this if manually running commands and not creating an image
if [ -n "$IMAGE" ]; then
dd if=/dev/zero of="$IMAGE" bs=1M count="$IMAGESIZE"
sudo losetup "$DISK" "$IMAGE"
fi
md5sum -c target/KERNEL.md5
md5sum -c target/SYSTEM.md5
sudo umount "$DISK"*
PART=( parted -s "$DISK" )
sudo "${PART[@]}" mklabel msdos
sudo "${PART[@]}" unit cyl mkpart primary fat32 -- 0 16
sudo "${PART[@]}" unit cyl mkpart primary ext2 -- 16 -2
sudo "${PART[@]}" set 1 boot on
sudo partprobe "$DISK"
sudo mkfs.vfat "$PART1" -I -n System
sudo mkfs.ext4 "$PART2" -L Storage
sudo sync
MOUNTPOINT="$( sudo mktemp -d )"
sudo mount -t vfat "$PART1" "$MOUNTPOINT"
echo 'boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 ssh quiet' \
| sudo tee "$MOUNTPOINT"/cmdline.txt
sudo cp target/KERNEL "$MOUNTPOINT"/kernel.img
sudo cp target/SYSTEM 3rdparty/bootloader/* openelec.ico README.md \
"$MOUNTPOINT"/
sudo sync
sudo umount "$MOUNTPOINT"
sudo rmdir "$MOUNTPOINT"
# skip this if manually running commands and not creating an image
if [ -n "$IMAGE" ]; then
sudo losetup -d "$DISK"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment