I have to admit that I’m a big fan of single-board computers for specific tasks like home-automatation, backup systems, network gateways, or file-sharing. I also like the approach of the Raspberry Pi Foundation to provide an image file with Raspbian (an adapted Debian) for easy use. For most people out there it is the best way to fetch an SD-Card with a capacity of at least 4 GBytes, download and copy the Raspbian image onto the card. I have a few unused 1 and 2 GByte SD-Cards lying around which should be sufficient for my tasks but are too small for the ‘generic’ Raspbian image. So I had to create my own minimalistic Raspbian installation. Here is a step-by-step example of the creation process.
I started with the installation of a few later required packages. I’m pretty sure this list is incomplete as I’ve already had quite a lot dev-tool packages installed before…
sudo aptitude install qemu-user-static \
binfmt-support fakeroot debootstrap git
To get Qemu running to support armhf I had to add a parameter to itc configuration file:
echo "EXTRA_OPTS=\"-L/usr/lib/arm-linux-gnueabihf\"" > /etc/qemu-binfmt.conf
I used “/tmp/” as my working directory which might not be the best location (temporary, as the name says). Feel free to use another dir, but you might need to keep an eye on the (root) access permissions…
mkdir raspi raspi/bootfs
Next I downloaded a minimalistic list of Raspian packages that will later go onto the root partition. I’ve tried to avoid working with root permissions as far as possible (therefore ‘fakeroot’).
fakeroot debootstrap --foreign --no-check-gpg --include=ca-certificates --arch=armhf testing rootfs http://archive.raspbian.com/raspbian
No we need to (temporarily) add some arm binaries to the root directory.
cp $(which qemu-arm-static) rootfs/usr/bin
The following step will start the actual installation process of the Raspian packages. For some reason I was not able to continue at this point without root permissions. (Any tips to fix this are welcome.)
sudo chown root.root rootfs -R
sudo chroot rootfs/ \
/debootstrap/debootstrap --second-stage --verbose
You will need some of the Raspberry Pi firmware files. The following commands download and install them . The Git repository is huge (3.1 GB), so this might take some time…
git clone \
sudo cp -r firmware/hardfp/opt/* rootfs/opt/
At this point you could create a custom kernel image based on the downloaded files. In my opinion the stock kernel is just fine so I just used it as is:
mkdir -p rootfs/lib/modules/
sudo cp -r firmware/modules/* rootfs/lib/modules/
Create the boot partition (i.e. copy the necessary files):
cp -r firmware/boot/* bootfs/
Next we can make some adaptions to the future image files: set a new root password, hostname, adapt the sources list, etc…
sudo chroot rootfs/ /usr/bin/passwd
cat >> rootfs/etc/apt/sources.list deb http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi
It might also be a good idea to adapt the future system to your local settings, e.g. keyboard layout.
sudo chroot rootfs/ apt-get update
chroot rootfs/ apt-get install console-data \
console-common console-setup tzdata most locales keyboard-configuration
sudo chroot rootfs/ dpkg-reconfigure locales
sudo chroot rootfs/ dpkg-reconfigure \
sudo chroot rootfs/ dpkg-reconfigure tzdata
Now we can do some clean-up:
sudo rm rootfs/usr/bin/qemu-arm-static
Next step is the creation of the actual boot and root partitions on a SD-Card. I’ve not documented these steps in detail as everyone has a different favourite partition manager. This step can be done with fdisk, (g)parted, or other tools.
You have to create two partitions on your SD-Card. For the boot partition 64 MB are sufficient, the remaining space is used for the root partition. The boot partition needs to be a FAT32 partition. The nice thing about the Raspberry Pi is, that boots of the first FAT32 partition without further installing a boot block or so.
Here an example how a 2 GB SD-Card could look like:
fdisk -l /dev/sdd
/dev/sdd1 2048 133119 65536 b W95 FAT32
/dev/sdd2 133120 3987455 1927168 83 Linux
Now we can copy the files from the two directories we previously created onto the two SD-Card partitions (you might need to mount them first) and test the card.
cp -R rootfs/* /media/USER/root/ && sync
cp -R bootfs/* /media/USER/boot/ && sync
I also have created an image file, mounted is (as a block device), partitioned it similar to the steps above. But I have not yet documented these steps. Might be added in a future update…