* Move the swap partition (you'll have to adjust the numbers so that the end of partition 3 is at the end cylinder/head/sector of the card)

* Move the swap partition (you'll have to adjust the numbers so that the end of partition 3 is at the end cylinder/head/sector of the card)

* to calculate the number to use in the following command do:- <code>(Maximum - (Partation 3 End - Partation 3 Start) ) - 1 = Partition 3 New Start</code> so in this example <code>(121535 - ( 29743 - 26688)) -1 = 118479 </code>

* to calculate the number to use in the following command do:- <code>(Maximum - (Partation 3 End - Partation 3 Start) ) - 1 = Partition 3 New Start</code> so in this example <code>(121535 - ( 29743 - 26688)) -1 = 118479 </code>

+

*''Will not work with parted versions later than 2.4''

(parted) move 3 118479,0,0

(parted) move 3 118479,0,0

* Now grow the root partition. This involves removing the partition, re-creating it, then using <code>resize2fs</code> to grow the filesystem to fill the partition. It won't destroy any data.

* Now grow the root partition. This involves removing the partition, re-creating it, then using <code>resize2fs</code> to grow the filesystem to fill the partition. It won't destroy any data.

Revision as of 01:15, 17 July 2012

The prepared images of the raspberry are created for SD cards of the size of 2GB.
The SD card can be resized to use the full size of a SD card that is greater than 2GB.
This page explains how to format the SD card to use the full size of it.

This shows how my SD card was formatted after writing the image. Notice that nothing uses the card from end of 'cylinder' 29743 to the card's maximum at 121535.

Partition 1 is the boot partition: we'll leave that alone. Partition 2 is the root partition, which we'll grow to fill most of the card. Partition 3 is the swap space, which needs to be moved to the end of the card. Note that on some other versions of linux (and some other versions of hardware) use /sde not /sdd.

Move the swap partition (you'll have to adjust the numbers so that the end of partition 3 is at the end cylinder/head/sector of the card)

to calculate the number to use in the following command do:- (Maximum - (Partation 3 End - Partation 3 Start) ) - 1 = Partition 3 New Start so in this example (121535 - ( 29743 - 26688)) -1 = 118479

Will not work with parted versions later than 2.4

(parted) move 3 118479,0,0

Now grow the root partition. This involves removing the partition, re-creating it, then using resize2fs to grow the filesystem to fill the partition. It won't destroy any data.

Manually resizing the SD card using a GUI on Linux

If you are using a PC with a linux distribution to resize the partitions, you can run GParted to resize the partitions using a GUI. This method is tested on Ubuntu 10.10 using the Gnome desktop.

GParted can be installed using:

sudo apt-get install gparted

Note: I had to physically remove and re-insert the SD card from the card reader after writing the image before the partitions were recognised properly and the following could be done.

Start GParted (on my system it is [System]->[Administration]->[GParted Partition editor]).

Select the drive corresponding to your SD card (was /dev/sdh/ on my system). You now see the partitions mentioned above (with some tiny unallocated areas in between and a large one after).

Select the swap partition by clicking on it. Select the menu option [Partition]->[Resize/Move] and drag the partition to the right (click/drag in the middle).

Select the ext4 partition and then the [Resize/Move] menu option. Drag the right edge of the partition all the way to the right (click/drag the right edge).

When you are satisfied with the changes, click on the green check mark to execute these changes.

You're done!

Manually resizing the SD card on Raspberry Pi

You can also resize the partitions of the SD card that your Pi is running on.

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:

sudo fdisk -cu /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, 3 to delete the swap partition

d, 2 to delete the main partition

np2 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 the Debian image from 2012-04-19 starts at 157696, but the start of your partition might be different. Check the p output!

w write the new partition table

Now you need to reboot:

sudo shutdown -r now

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.

sudo resize2fs /dev/mmcblk0p2

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