0

I would like to create an modified img file which I can flash to a large number of devices. The idea is that I create a clean raspbian version, install different packages manual on one device and after installing all these packages, I would like to generate an img file with these packages so that I can simply flash it other devices. So that there is no need to install the packages manual again.

Is that possible and how can I do it?

  • You might want to include some constraints. Eg., If you can connect some USB storage to copy the image to, this makes things much easier. Also, do you care what size it is? The ideal way is to shrink it to fit, then when installed on another card, expand it on first boot (as the original does). – goldilocks Jul 14 '20 at 17:51
  • Are you trying to do this from Raspbian? Or can you use one of many options available from windows after you insert the sd card into a builtin reader? – dbmitch Jul 15 '20 at 04:14
  • I can use Windows as Well. – JavaForAndroid Jul 15 '20 at 05:03

2 Answers2

1

You can do this using image-util. image-util may also give you a smaller .img file, and run more quickly. Additionally, if you need to make changes to the original .img file, you may do so without creating a new image - you may simply "update" the existing image.


As an alternative to the download link above, you may also install it from GitHub as follows:

First: install git if you don't already have it: sudo apt-get install git

$ git clone https://github.com/seamusdemora/RonR-RPi-image-utils.git
  Cloning into 'RonR-RPi-image-utils'...
  remote: Enumerating objects: 74, done.
  remote: Counting objects: 100% (74/74), done.
  remote: Compressing objects: 100% (56/56), done.
  remote: Total 74 (delta 41), reused 34 (delta 13), pack-reused 0
  Unpacking objects: 100% (74/74), done.
$ cd RonR-RPi-image-utils 
$ chmod 755 image-*

To keep up-to-date with any changes, run this periodically:

git -C ~/RonR-RPi-image-utils pull https://github.com/seamusdemora/RonR-RPi-image-utils.git

You can put this command in your crontab if you like to run once a week. There aren't many changes at present.


NOTE: I am not the author of image-utils, nor do I make any changes at all to the source. I have put it on my GitHub site for my own convenience. I'm happy to share that if you prefer using git to keep your local sources updated (rather than dealing with the .zip file). I maintain sync with the master copy on the Raspberry Pi org's forum with a small script I've written to automate the process.

Seamus
  • 21,900
  • 3
  • 33
  • 70
0

I guess you may need something like backup for your image that you can install later. If you want to try a backup, first find out what is your SD driver:

df -h

Assume it is in /dev/sdb1 & /dev/sdb2 . Then use the following command to make backup

sudo dd if=/dev/sdb of=/path/to/backup/location bs=4M

To reinstall this backup again the same dd command shall be used

moibrahim
  • 199
  • 1
  • 2
  • 9
  • You should mention that this can only be done with a card reader on another computer. – Ingo Jul 24 '20 at 17:31