hoeken
Posts: 5
Joined: Tue Apr 09, 2013 4:33 am

How to create a custom Raspbian image?

Tue Apr 23, 2013 3:16 am

Hey all,

I'm running an open source project called BotQueue which allows you to control your 3D printer or CNC machine through the internet. I've found that a Raspberry Pi makes a great client/controller for connecting each machine. I'm using Raspbian as the OS and it is also rocking really hard.

Unfortunately, the installation and preparation of a vanilla Raspbian image takes literally hours with all the updates, installation, and compilation that need to happen to get all the right things working. I'd love to be able to make it easier for people to install my software on the Pi, and the easiest way I could think of is to include an ISO image they could just burn to their sd card that contains all the software pre-installed and ready to go.

I definitely don't want to roll my own distro, and I really want to continue using Raspbian. What I'm wondering is if there is a way to take a currently functioning sd card install and sanitize it to create an image that can be offered for download. It seems pretty obvious that I would use dd to create the image in the same way it is used to write the image, but how do I go about sanitizing the dozens (hundreds?) of files that are created during the use of a distro. Things like keys, configurations, cache files, etc. should all be removed.

Any ideas?

notro
Posts: 751
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: How to create a custom Raspbian image?

Sat May 04, 2013 6:09 pm

Maybe not exactly what you want, but this is how I make an image with a customized kernel: https://github.com/notro/fbtft/wiki/Remake-SD-image

plugwash
Forum Moderator
Forum Moderator
Posts: 3770
Joined: Wed Dec 28, 2011 11:45 pm

Re: How to create a custom Raspbian image?

Sat May 04, 2013 10:58 pm

IMO it's much better to avoid creating mess in the first place than to try and clean it up afterwards.

The scripts friggle uses for building the raspberry pi foundation images, are availble at http://github.com/asb/spindle the script I use to build the minimal image that I release for the raspbian project is availble at http://plugwash.raspbian.org/build-image . It should be possible to modify either of these scripts to add extra stuff to the images.

Edit: oops it seems I screwed up copy/paste

User avatar
TimG
Posts: 317
Joined: Tue Apr 03, 2012 12:15 am
Location: Switzerland

Re: How to create a custom Raspbian image?

Sun May 05, 2013 12:01 pm

Thanks for the link, I'd like to have a go at building a customised image. As far as I can see the scripts create two new filesystems, which then have to be imaged to an img file - is that right? Can these scripts to be run on a RPi, writing to a USB key or a USB SD-reader?


mkaczanowski
Posts: 1
Joined: Sun May 10, 2020 8:14 pm

Re: How to create a custom Raspbian image?

Sun May 10, 2020 8:15 pm

You can also try hashicorp packer. It's fairly easy to use (no bash scripts!):
https://github.com/mkaczanowski/packer-builder-arm

User avatar
Botspot
Posts: 1823
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas

Re: How to create a custom Raspbian image?

Tue May 12, 2020 12:22 am

hoeken wrote:
Tue Apr 23, 2013 3:16 am
the installation and preparation of a vanilla Raspbian image takes literally hours with all the updates, installation, and compilation that need to happen to get all the right things working. I'd love to be able to make it easier for people to install my software on the Pi, and the easiest way I could think of is to include an ISO image they could just burn to their sd card that contains all the software pre-installed and ready to go.

Any ideas?
Have a look at Pi-Power-Tools. It's a set of bash scripts that are specifically meant to customize a Raspbian image, wrapped in a little GUI.
Image
You can even boot the image in a virtual machine!
Easily install anything on your Pi using Pi-Apps! Over 1 million users.
150+ apps including image editors, text editors, games, web browsers, appearance themes, and other upgrades to get the most out of your Pi.
More info: https://github.com/Botspot/pi-apps

bls
Posts: 2405
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: How to create a custom Raspbian image?

Tue May 12, 2020 2:34 pm

Here's a command-line tool that operates on a standard Raspbian Lite or Full image, and enables you to easily build and maintain your own customized "golden image". Then, when the image is burned to an SD card, the target host name is written into the image and applied when the system boots.

You can easily install your desired apps into the image, update it as desired over time, etc. If you ever need to rebuild the image (e.g., due to a Rasbian new version, etc), it's quite simple, since all of your changes are embodied in the scripts. Yes, a bit of script editing is required, but the tool provides a framework in which your changes are quite simple to make.

See https://github.com/gitbls/sdm for an installation guide and a detailed description of the tool.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Return to “Raspberry Pi OS”