I found several guides to adjust the Wifi-Passwords prior to the first boot but I need to install certain packages (with apt-get) on the first boot (or even package them into the image) and some custom software that was developed by us. How would I do that?

The reason for this is that I‘m working on a project where we want to eventually provide a final Raspbian image that my school can take, flash to their SD cards and insert them into their Pis. We are developing a presentation application that can be used from your phone/tablet and should not need any further installation.

  • I understand that this is for a school project and probably not worth the time or effort so I won't add an answer, but the long term solution here is probably using something like Yocto instead of Raspian.
    – Sam
    Jan 7, 2018 at 23:44

2 Answers 2


You could do this the same way raspi-config works, by running a boot service that disables itself after being run once.

If shell scripting isn't your thing, you may want to look into configuration tools such as puppet or chef.

we want to eventually provide a final Raspbian image that my school can take

This sounds like you instead want want to create a ready made image. If so, you can simply start with a fresh image on a running pi, install what you want, and then create a new image from the SD card. E.g., using another linux machine:

dd if=/dev/sdb of=my.img bs=4M count=???

Since this is copying from an entire device (and not just a partition), you will have to figure out how much to copy (count=???) -- you probably do not want an image the size of the card itself. A complication here is that current versions of Raspbian enlarge themselves automatically when first run. You thus may need to:

Reverse the expand root FS

Or you could do a little digging and disable the auto-expansion on the card before using it. You can also do this with the image itself:

How can I mount a Raspberry Pi Linux distro image?

The above Q&A may help you understand the nature of multi-partition device images, as used with the Pi, if you do not already. Once this is clear to you creating a customized image should be straightforward.

  • I'm sorry for not getting back to you earlier. I used this and started learning about raspi-config. Thanks!
    – Crosswind
    Jan 16, 2018 at 12:53

If you're satisfied with installing packages automatically on first boot rather than actually baking the packages into the image, you might like to consider PiBakery. You can configure actions to run at various times (such as 'On first boot, install [X]'), and a bootable image will be produced from this.

The GUI is rather like Scratch, so it may be more accessible and straightforward than creating a custom image manually (although it is, of course, much less flexible).

You can also configure a default Wi-Fi setup, and there are various other blocks available for different tasks. PiBakery can be run on Windows or Mac (but curiously, not Linux!) and does support Raspbian Stretch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.