Instructables

Raspberry Pi Resize Partitons (Use all free space)

Picture of Raspberry Pi Resize Partitons (Use all free space)
Hi there,
If you have a Raspberry Pi with an SD Card larger than 2GB, then you may want access to all of the space available.
By default only 2GB is accessible.
The following will show you how to get all of your space.

NOTE: This will only work on the Debian image.
 
Remove these adsRemove these ads by Signing Up

Step 2: Locate Partitons

Firstly Login to your Raspbery Pi, then issue the following commands:
sudo -i
This will elevate you to root status, negating the need of sudoing a lot.
df -h
Make a note of the last line (shown in the image).
(It will most likely be "/dev/mmcblk0p1").

Step 3: Delete Partitons

Still logged in as root (from using sudo-i) issue the following commands:
fdisk -uc /dev/mmcblk0 <-- where mmcblk0 is what you had previously.

The prompt should change to "Command (m for help):"

Type the letter p and hit Return / Enter (this will list your partitions)

Make a note of the "Start" value for /dev/mmcblk0p2 (mine is 157696) shown in the second image.

Now type the letter d and hit Return / Enter.

The prompt will ask you for "Partition number (1-4):", type in 2 and hit Return / Enter.

Then type d again, hit Return / Enter, then enter 3 and hit Return / Enter.
knexpert17005 months ago

When I put in fdisk -uc /dev/mmcblk0 it won't change the prompt to Command(m for help), it will simply give this message:

Usage:

fdisk [options] <disk> change partition table

fdisk [options] -l <disk> list partition table(s)

fdisk -s <partition> give partition size(s) in blocks

Options:

-b <size> sector size (512, 1024, 2048 or 4096)

-c[=<mode>] compatible mode: 'dos' or 'nondos' (default)

-h print this help text

-u[=<unit>] display units: 'cylinders' or 'sectors' (default)

-v print program version

-C <number> specify the number of cylinders

-H <number> specify the number of heads

-S <number> specify the number of sectors per track

Great guide! But just to clarify -am I supposed to be able to access the new larger partition when I plug it into my pc? Right now I have two primary patrions, but only the small one can be directly accessed.
If you're looking at it under DOS/WIN, that is all you'll see.. When I started tinkering with the Pi, I accidentally blew-up the first installation.. (it refused to boot past the device start-up, just kept hanging. ) so .... I went to re-format the card... Under Windows-7.. Guess what it couldn't see? There is a program out there called "sdformatter" ( https://www.sdcard.org/downloads/formatter_3/ ), which will completely blank the card under Win/DOS.. otherwise, you'll need a 2nd machine running Linux, and following the steps mentioned.. (thankfully, I have Ultimate Edition 3.5 running on my laptop. Disk Utility came in real handy wiping the old one before I found out about SDFormatter.)
beave21111 year ago
Hi, I tried using this tutorial and got stuck one step..
fdisk > p was not displaying any partitions for me, although I believe I followed the directions correctly.

I did learn there is a much easier way to accomplish this task, however. If you type the command "raspi-config" the second menu option will automatically resize the partition to fill the SD card. So unless you don't want the partition to fill the card, that's probably the easier approach.
drcurzon (author)  beave21111 year ago
Hi there,
Many thanks for that - I didn't know about it :)
Daniel.
CE_REAL1 year ago
Well I tried this and had a little difference:

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA)
/dev/mmcblk0p2 122880 3788799 1832960 83 Linux

Instead of the three listed in the screenshots.
Also this command: fdisk -uc /dev/mmcblk0, did not work for me, fdisk -c /dev/mmcblk0 did though, so I'm thinking that shouldn't make much of a difference.

But now the problem, I got till the end of step 4 and rebooted the device, but then it didn't start anymore... I'm not even getting a video signal when I plug the power in and have it connected to my screen.

Hope you can give me some enlightment of what I did wrong, so next time I'll do it right. I did keep a backup so I'm hoping to set that back and try it again.

Thanks in advance, must say your tutorials are very helpfull, I'm just a noob at this :)
I had the same issue. I found it to be the step where he has you hit d again. Don't do this if you only have two partitions. Or else it will delete your raspberry pi partition and you will have to start over by re-installing the image on the SD card and then start from step 1 of this tutorial..

Notice how he has a p1, p2, and p3 partition when typing p. He has three partitions...

"Now type p and hit Return / Enter to create a primary partition."

"The prompt will ask you for "Partition number (1-4):", type in 2 and hit Return / Enter.

Then type d again, hit Return / Enter, then enter 3 and hit Return / Enter."
drcurzon (author)  CE_REAL1 year ago
Hi there,
Glad they're useful :D

Have you re-imaged the SD card yet? If so, does the Raspberry Pi work now?

Just to confirm, you are using the Debian image?

Hope to hear from you soon, Daniel.
I did not re-image it, by that you mean setting the back-up back right? I'm planning to do that this weekend, don't have much time till then.

I'm using the Debian image yes, though I used the official one from the raspberrypi.org website:

http://downloads.raspberrypi.org/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip

It's also a Debian image, so that shouldn't be a problem right?

Could you maybe point to what I could have done wrong? I'll let you know how my 2nd try goes :)
drcurzon (author)  CE_REAL1 year ago
Hi there,
The Debian image should be exactly the same (unless they've been updated).
All I can think of is that either the image has changed, or that you perhaps spelled something wrong (or I put it in the tutorial incorrectly).

I'll have a look and try the new image in a day or two, then get back to you on that.
Daniel.
I did a reinstall and after the first reinstall, with the password given in not working, I tried another and got it to work, even got the resizing done right.

Thank you very much for your tutorials, they've been a welcome help!
drcurzon (author)  CE_REAL1 year ago
No problem - Glad to have helped someone :D
paswicka2 years ago
Wow! Thanks!
exartemarte2 years ago
Nice tutorial - clear and it works, unlike some of the tutorials available on line.

Thank you.
drcurzon (author)  exartemarte2 years ago
Glad it helped, thanks for the comment. :)