Resize SD

Here is a guide on how to resize your partition to fit sd card.
The original guide is from elinux.org, and is provided under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
We adapted it to fit Minibian “Jessie” flavour.

First you need to change the partition table with fdisk. You need to remove the existing partition entries and then create a single new partition than takes the whole free space of the disk. This will only change the partition table, not the partitions data on disk. The start of the new partition needs to be aligned with the old partition!

Start fdisk:

fdisk /dev/mmcblk0

Then delete partitions with d and create a new with n. You can view the existing table with p.

  • p to see the current start of the main partition
  • d, 2 to delete the main partition
  • n p 2 to create a new primary partition, next you need to enter the start of the old main partition and then the size (enter for complete SD card). The main partition on Minibian image from 2015-11-12 starts at 125056, but the start of your partition might be different. Check the p output!
  • w write the new partition table

Now you need to reboot.
After the reboot you need to resize the filesystem on the partition. The resize2fs command will resize your filesystem to the new size from the changed partition table.

resize2fs /dev/mmcblk0p2

This will take a few minutes, depending on the size and speed of your SD card.

When it is done, you can check the new size with:

df -h

13 thoughts on “Resize SD

  1. Not able to boot after re-sizing as mentioned.

    Environment:
    Raspi B+
    SD class 10 16GB

  2. Same here…but I got an Error “Device in use” or sth like that..

  3. “Re-reading the partition table failed.: Device or resource busy”

  4. The problem I did at first was that I let fdisk use the default-value for the partition sectors. If I entered the correct value (125056 for me, as in the guide – check yours with p, as the guide says aswell) it worked like a charm!

  5. still no luck any bdy got it working. i tried neme option also tried not working😦

  6. sorry neme thing worked i didnt read it properly. dont select default use 125056 as neme case. thanks guys

  7. I’m also getting the an error at the end of the fdisk w command. It says: “Calling ioctl to re-read partition table Re-reading the partition table failed.: Device or resource busy”. Now resize2fs fails with “Couldn’t find valid file system” and ?Device or resource busy while trying to open /dev/mmcblk0″. I did enter the value of 125056 correctly.

  8. Worked perfectly for the B

  9. If u see “device is busy” – don’t care, just reboot and do the next step. If fail – do it again (twice for me). And enter value 125056 as begining of partition and deflaut as end (depends on your memory card size).

  10. I seem also to get the same issue.
    Possible fix if you do:
    apt-get update && apt-get upgrade
    apt-get install raspi-config
    raspi-config
    now use the gui to resize.

  11. I resize the partition with gparted installed on my laptop, them execute a “fsck” on the raspberry pi 2 b and reboot….

  12. After my second read, the process was successful!🙂 thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s