Skip to content

Creating a Raspberry Pi image

Rachael Kemp edited this page Oct 17, 2019 · 1 revision

A disc image file contains the exact duplicate of a given drive. In the case of the image file provided in this repository, the drive was the microSD card of a functioning GUI with all requirements installed. This means that any microSD cards with this image applied should work with a Raspberry Pi 3 without further work.

If changes are made to the GUI or Python tools and you wish to create a new image of the Pi, there are a number of steps required. This guide has been written to run on Linux, however methods for creating image files on other operating systems exist.

  1. Ensure the GUI is fully functional before duplicating. Any issues which exist on the Pi will be deuplicated.

  2. Remove the microSD card from the Pi.

  3. Use a reader to connect the card to your machine.

  4. Find the name of your drive by listing all connected drives and using the size to work out which is your microSD card:

sudo fdisk -l
  1. Clone the card. To do this you will require space equal to the maximum capacity of your microSD card. replace /dev/sdb/ with your microSD location:
sudo dd if=/dev/sdb of=clone.img
  1. Wait. This process can take upwards of an hour for large cards.

  2. Once completed, you will have a clone.img file equal in size to the maximum capacity of your microSD card. This is extremely inconvenient for hosting, so you will need to shrink the file.

  3. Install gparted, a tool for altering drive partitions:

sudo apt-get install gparted
  1. Download the pishrink script which will use gparted to shrink the size of your image file to just the used partition of your microSD card:
wget  https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
chmod +x pishrink.sh
sudo mv pishrink.sh /usr/local/bin
  1. Shrink the image file:
sudo pishrink.sh clone.img clone-shrink.img
  1. To reduce the size of the image further to make it easier to host, compress it to a zip file:
zip cloned-image.zip clone-shrink.img

Hosting your image file on Github

Github requires users to use Git Large File Storage to upload large single files to repositories. These image files are large enough that this is necessary if you wish to host them on a repository.

  1. Install Git LFS:
git lfs install
  1. Navigate to the local directory of your Git repository.

  2. Tell Git LFS to track image files:

git lfs track "*.zip"
  1. Commit and push your image:
git add cloned-image.zip
git commit -m "Add image file"
git push origin master