Article Index

My first post will be on my attempt to create a minimal Raspbian image to run on my Raspberry Pi. The standard Raspbian image is bloated with all kind of tools and software, to make it easier on new users to use their Raspberry. I think this is useful if you want to quickly enable people to start doing stuff (browsing, programming in whatever language, play around with the GPIO ports etc). However, if you know what you want with your Pi (use it as a home server, install it in your home made arcade machine, whatever), a lot of the tools installed are useless and you might want to consider cleaning it up.

Of course there are images available with a clean, minimal Linux distro for the Raspberry. There are even small images based on Raspbian itself. However, my goal is not just to have a clean image, but also to learn from it; how can I install a system from scratch? What packages are required? And for what purpose? Also; who is to say that the creator of a random small image didn't install a key-logger on it? Anyway, I wanted to install Raspbian from scratch, on a clean, empty image, using just dpkg and apt.

Note that I do not want to compile anything if possible. It is fun and interesting to install Linux by compiling everything, however, I think compiling on a Raspberry Pi will be much too slow. And doing it using cross-compilers will teach you more on compiling, configuring and optimizing stuff, than on installing stuff. Plus, the packages in the Raspbian repository are probably configured and optimized specifically for the Raspberry Pi. If you are interested on installing Linux from source code, I would recommend not doing this on a Raspberry Pi. But have a look at Linux From Scratch. That's a nice project and you can learn a lot by doing it.

In this blog post I will show you what I did to create an empty image, prepare it for installation, install basic libraries/packages and dpkg and apt.  Finally I will attempt to make the image bootable, meaning you can start your Raspberry Pi with your own image and not much more installed than what is needed to install applications from the Raspbian repository, through apt.

About package managers

First a short word on what dpkg does. There are a lot of ways to get software installed on a Linux machine. For us this going to be done through packages. A package contains a few things: the files (executables, libraries, configuration etc), installation and removal scripts and metadata with, amongst others, the list of other packages that this package depends on. For Debian derivatives (like Raspbian), dpkg is the package manager. It keeps track of what packages are installed and checks whether all dependencies are met before installing a new packages. Besides easing the checking whether you have all dependencies installed, this also helps a great deal when you want to remove software.

However, also a short word on what dpkg does not do. It does not have any notion of repositories (servers containing packages) and will therefore not automatically fetch all dependencies. There is another tool for that, apt. Basically, you configure apt with a list of repositories (in the form of URLs) you want to use. When installing a package through apt, it will check what the dependencies for that package are and download these dependencies and the requested package itself from the repository. Then it calls dpkg to install all these packages. Note that apt does not replace dpkg, but rather uses dpkg to install packages. Apt merely saves you the trouble of having to find out all the dependencies and the locations of these dependencies.

So why is this important? First of all; we want to install all software through dpkg, to make sure that at the end, it knows exactly what is installed. Secondly; because we don't have apt installed on the (new) image yet, we will have to manually download the first packages up until we have installed apt. Basically, we will start with doing 'apt-get install apt' manually.

Last, but not least; there are some dependency problems in the beginning. Two packages mark each other as a dependency (creating a chicken and egg problem). Furthermore, most packages contain installation scripts, which also require some tools to be installed. These tools are not marked as a dependency because they are not needed by the software in the package, only by the installation script. We will run into problems because of this; we cannot install a basic C library without these tools and we cannot install these tools without this C library. Again with the chicken and the egg. Luckily, I studied biology, so I know the egg was first, thus solving this was peanuts (okay, I'll be honest, it took me quite a while).

Add comment


Security code
Refresh