How to create a 8GB image from 16 GB SD Card image

I have created my image on 16 GB SD card but to keep this 16 GB it takes lot of time (for creating backup and flashing).

Does there exists a process to manual (not copying complete device using dd) to backup the image.

For example by

  1. Creating a file of zero’s as master.img
  2. Then making a GPT partition on master.img
  3. And then copying first four partition using dd
  4. Then transferring the rootfs into remaining fifth partition using cp

Guess you could just mount mount -o loop *.img *.dir

As for size you can just resize do a fdisk get the number of sectors and DD it.

dd if=/dev/sda of=/your_directory/image_name.img bs=512 count=xxx+1

I have created a script which is not tested yet, copies the image to small image file.
I have tested to create the image, but I haven’t tested it on the Rock PI 4B device after flashing the small image it, will update once I do it.

https://github.com/ganeshsutar/rockpi-scripts

2 Likes