Context
I have a 16 GB SD card with a Linux based OS for a Raspberry Pi. Most of the space is empty.
I want to share the SD .img
with other people but if I use the command
dd if=/dev/sdXX of=/home/user123/SD.img
it will create a 16 GB image. Too big.
Question
How can I re-size a 16GB SD card image into a smaller 4GB?
I have tried with GParted: it creates a partition with 4GB with no problem, however the whole .img
of the SD card continues to be 16 GB with 12 GB of unallocated space.
I have read the question and answer Cloning multiple partitions in Ubuntu, but I still cannot re-size the 16GB SD card into a 4GB one.
More info
~$ lsblk
...
sdc 8:32 1 14,9G 0 disk
├─sdc1 8:33 1 100M 0 part
└─sdc2 8:34 1 4G 0 part
~$ sudo fdisk -l /dev/sdc
Disk /dev/sdc: 14,9 GiB, 15931539456 bytes, 31116288 sectors
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: dos
Disk identifier: 0xf8a631ce
Device Boot Start End Sectors Size Id Type
/dev/sdc1 * 2048 206847 204800 100M c W95 FAT32 (LBA)
/dev/sdc2 206848 8595455 8388608 4G 83 Linux
Any advice is appreciated!
Please note: as observed by Melebius in a comment, the right word to use is shrink:
You cannot resize an SD card as it is hardware with a given capacity that cannot be changed. You clearly want to shrink an SD card image.