Skip to content

Instantly share code, notes, and snippets.

@yoelrc88
Last active June 6, 2018 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoelrc88/9ceff072cd882431684c92ba9c528c9d to your computer and use it in GitHub Desktop.
Save yoelrc88/9ceff072cd882431684c92ba9c528c9d to your computer and use it in GitHub Desktop.
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