Skip to content

Instantly share code, notes, and snippets.

@jeremyckahn
Created July 28, 2012 23:52
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save jeremyckahn/3195325 to your computer and use it in GitHub Desktop.
Save jeremyckahn/3195325 to your computer and use it in GitHub Desktop.
Setting up Raspbian rootfs on Ubuntu
#!/bin/bash
# For Ubuntu. Probably works elsewhere too.
# This script downloads the Raspbian file system into ~/rpi/chroot-raspbian-armhf
# It also chroots you into the directory, so you can act as a Raspbian user.
# This was all taken from here: http://superpiadventures.com/2012/07/development-environment/
mkdir -p ~/rpi
cd ~/rpi
# Get some packages.
sudo apt-get install qemu-user-static debootstrap
# This step takes a little while. Don't do it on a low battery.
sudo qemu-debootstrap --arch armhf wheezy chroot-raspbian-armhf http://archive.raspbian.org/raspbian
# Mount some filesystems. These calls to "mount" need to be done
# again after rebooting, so consider making a BASH alias.
sudo mount -t proc proc ~/rpi/chroot-raspbian-armhf/proc
sudo mount -t sysfs sysfs ~/rpi/chroot-raspbian-armhf/sys
sudo mount -o bind /dev ~/rpi/chroot-raspbian-armhf/dev
# chroot into the Raspbian filesystem
# Do this each time you need to work with the Raspbian files.
# Again, consider making a BASH alias.
sudo LC_ALL=C chroot ~/rpi/chroot-raspbian-armhf
# Add the Raspbian repo and set up a GPG key.
echo "deb http://archive.raspbian.org/raspbian wheezy main" >> /etc/apt/sources.list
wget http://archive.raspbian.org/raspbian.public.key -O - | apt-key add -
apt-get update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment