Here is how to utilise the full capacity of your Raspberry Pi's SD card after installing the Debian image which gives a 2GB root partition:
Step 1: Run fdisk as sudo
sudo fdisk -cu /dev/mmcblk0
Step 2: enter p to view the current partition table:
Device          Boot    Start    End        Blocks   Id    System
/dev/mmcblk0p1          2048     155647     76800    c     W95 FAT32 (LBA)
/dev/mmcblk0p2          157696   3414015    1628160  83    Linux
/dev/mmcblk0p3          3416064  3807231    195584   82    Linux swap / Solaris
Step 3: Delete partitions 2 and 3 (root and swap)
d 2
d 3
Step 4: Create a new primary partition (2) starting where the previous partition 2 started (usually 157696)
n p 2
Enter (use remaining space)
Your partition table on a 32GB SD card will now look like this:
Device          Boot    Start    End        Blocks     Id    System
/dev/mmcblk0p1          2048     155647     76800      c     W95 FAT32 (LBA)
/dev/mmcblk0p2          157696   62552063   31197184   83    Linux

w (to write new partition table to the SD card)
Step 5: Reboot to reload the partition table
sudo shutdown -r now
Step 6: Resize partition 2 (Takes about 44 minutes on a class 10 SD card)
sudo resize2fs /dev/mmcblk0p2
Based on the tutorial found here: