My notes on doing this. Using a Linux machine!
This is not a tutorial / howto this is just my notes. I don’t have the 2hrs to write up a tutorial at them moment.
Using gparted shrink the main partishion down. Leave some space 1MB at the end for extra data.
find the disk to copy
$ sudo fdisk -l
see the output similar to the following:
Disk model: Card R/W -SD/MS
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 91FC289A-1E03-495A-9DAD-732401089949
Device Start End Sectors Size Type
/dev/sde1 28672 50831359 50802688 24.2G Linux filesystem
/dev/sde2 2048 2303 256 128K Linux filesystem
/dev/sde3 4096 4991 896 448K Linux filesystem
/dev/sde4 6144 7295 1152 576K Linux filesystem
/dev/sde5 8192 8319 128 64K Linux filesystem
/dev/sde6 10240 10623 384 192K Linux filesystem
/dev/sde7 12288 13055 768 384K Linux filesystem
/dev/sde8 14336 14463 128 64K Linux filesystem
/dev/sde9 16384 17279 896 448K Linux filesystem
/dev/sde10 18432 19327 896 448K Linux filesystem
/dev/sde11 20480 22015 1536 768K Linux filesystem
/dev/sde12 22528 22655 128 64K Linux filesystem
/dev/sde13 24576 24959 384 192K Linux filesystem
/dev/sde14 26624 26879 256 128K Linux filesystem
Partition table entries are not in disk order.
Note two things in the output:
The Last partition ends on block 50831359 (shown under End)
The block-size is 512 bytes (shown as sectors of 1 * 512)
We will use these numbers in the rest of the example.
count will = 50831359 + 1
sudo dd if=/dev/sde bs=512 count=50831360 of=~/yournamed.img status=progress
remember when you flash it to the new SD card you need to use gparted to increse the partishion and accept the fix presented by gparted for table issue.
What this does is create a image of only the current size of the installed data on your current SD card.
If there is demand and a bunch of users here want me to create a tutorial on how todo this with photos for the steps let me know.