Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
making and image with dd

Making the image small as possible

  • unmount SD card
  • resize partition using gparted
  • apply changes

Finding how big is the partition

using fdisk:

$sudo fdisk -l /dev/sdb                                
...
Device     Boot Start     End Sectors  Size Id Type
/dev/sdb1        8192   96453   88262 43.1M  c W95 FAT32 (LBA)
/dev/sdb2       98304 8486911 8388608    4G 83 Linux

In this case the important number is the End Sector = 8486911.

Doing some math

>> 8486911 * 512 / 16 / 1024 / 1024
ans =  259.00
>> 

So, we are goin to use 260:

Using dd:

umount /dev/sdb1 
umount /dev/sdb2
sudo dd if=/dev/sdb bs=16M count=260 | pv | dd of=<image_path> bs=16M

done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.