You may want to resize your partition to solve an issue with Win32 Disk Imager not being able to write to a new card due to it being slightly too small, or to change to a smaller SD card.

Here's what we want to do:

Resize the linux partition on the SD card to fit within the new space requirement, leaving an unused area after it

Resize the file system on that partition once its been changed.

Resize the .img file

Resize The Partition

First you need to reduce the size of the linux partition.  DO THIS FOLLOWING THE GUIDE HERE (if your issue is with Win32 Disk Imager then you'll have to find a SD card the existing .iso can be written onto to do this, even if this means needing to use the next card capacity up from the size you want to use).

Once the resize is complete you need to find out the total final size of the used space on the card (the FAT16 boot partition the RPi needs and the ext 4 partition that holds Linux, basically all the partitions before the unused area at the end of the card you've just created.

Now with the SD card booted up use the following commands to find the size of the area thats used:

sudo fdisk /dev/mmcblk0

Press 'p' then return to see the partitions.

For example you will get something like this:


Device         Boot  Start      End  Sectors  Size Id Type

/dev/mmcblk0p1        8192   122879   114688   56M  c W95 FAT32 (LBA)

/dev/mmcblk0p2      122880 12410879 12288000  5.9G 83 Linux

Get the End sector value for the last partition (12410879). Multiple by 512 (bytes per sector) to give you the target .iso file size (6,354,370,048 bytes) and make a note of this value (make sure you haven't made a mistake!)

Press 'q' then return to quit.

In this example we'll say we want our new card image to be 15400000 sectors (x 512 bytes per sector = 7,884,800,000 bytes)

Create a new .iso with the resized partition

Now shutdown the RPi and use Win32 Disk Imager. to read an .iso file from the SD card (we'll reduce its size after)

Alter the .iso file size for the final SD card

Download our IBEX File Size Changer app from here

Using this app open your .img file:

ibex_file_size_changer

The .img file is simply a byte mirror copy of the SD card.

You can uncheck the checkbox as we don't care what the values of the bytes to be removed are in the unused space at the end of the card.  Enter the new file size in bytes you calculated above and press 'Change The File Size'.

That's it, write the image to the smaller SD card and it should work fine.

 

 

 





USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.

Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.