Guide to Raspberry Pi (Part 3) – Resizing your sd card

Building your Raspberry Pi SD card boot disk

Installing a Raspberry Pi distro .IMG file onto an SD card with just Windows is convenient but it leaves us with a problem: the SD card capacity will become whatever the size the .IMG file is set to. For example our APC Linux distro has the compulsory 64MB FAT32 partition and an Ext4 partition for the OS set to 1.8GB regardless of the SD card size you use. It’s just a by-product of image-based Pi distros but one you can fix on the Raspberry Pi itself. Here’s how.

Step 1: Boot up your Raspberry Pi

Assuming you’ve installed APC piLinux onto an SD card remove any other drives from the Pi plug in the SD card and boot up. Once you get to the user login point type root as the username and apc as the password but don’t run startx .

Step 2: Delete the partition table

Don’t worry – this step doesn’t delete the operating system. We’re just rejigging the partition table to tell the OS to use the full capacity of the card. So type:

 fdisk –cu /dev/mmcblk0 

Then press the Enter key. Fdisk is APC piLinux’s disk partition app with its own user interface. Now type p and press Enter (we’ll use <enter> in the code below). This will bring up the SD card’s partition table list and you should see two entries: the FAT32 partition followed by the Linux (EXT) partition. Now type the following code:

d <enter>
2 <enter>
n <enter>
p <enter>
2 <enter>
W <enter>

Here d is the delete command 2 means delete the partition 2 table n says that we’re about to create something p means create a new partition and 2 is a new partition table for partition 2. By default fdisk should then give us the correct start block for the new table so we can just press Enter. It should also give us the default option to use the entire card capacity so press Enter again. Finally w tells fdisk to write the partition table out and you should be back to the Terminal prompt.

Codes for deleting partition tables


Step 3: reboot & resize

You’ll have to reboot the Pi and you do that by typing:

shutdown -r now <enter>

This tells the Pi to shut down -r means we want to reboot and now means do it now. When you get back to the login screen log in as before but don’t startx . Instead type:

resize2fs /dev/mmcblk0p2 <enter>

This tells APC piLinux to resize the file system for the SD card’s second partition to match the partition table we just created. Again no data changes hands – we’re just writing the changes to use the full card capacity.

Now go and have a cuppa. If you use a 32GB card like I have it’ll take around 10 minutes or so. But when it’s done type startx and when you’ve booted up into the desktop launch Thunar file manager (‘Applications > Accessories > Thunar’) and you should see the free space at the bottom of the window much nearer the card capacity. If so you’re done.

Codes to reboot and resize sd card

TechLife the next generation of tech magazine


  • Kunal Sakhuja

    not getting the putty connection after reboot