‘gparted’ is the graphical version of ‘parted’ and is the tool to use to resize the main partition used for raspbian (or you could use use parted if you prefer the command line of course!). It can also be used to check and repair a SD card disk.
To do this you’ll need to put the SD card you want to work on in a USB to SD card adaptor and boot your RPi from a separate SD card. If you’d rather use a windows tool we’ve found that gparted just works whereas all of the windows based partition managers we tried don’t, so better to just get over the hassle factor and use the RPi to do this if you don’t have a separate Linux system.
Installing gparted on the separate Raspbian SD card that will perform the change
From the command line use:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gparted
To run it use ‘sudo startx’ to load the GUI as gparted needs root user privileges <<<See comments below, it looks like sudo is no longer needed (just use startx ) and for some users can cause problems, awaiting page update…
Then from the start menu select run and enter ‘gparted’
Resizing Your Main Partition
From the top bar devices drop down select “dev/sda” (or whatever your external USB adaptor has been called).
Right click somewhere on the graphic and select ‘unmount’ first as operations can’t be carried out on a mounted partition.
Right click the main ‘ext4’ partition and select ‘check’, then click the green tick and let it check the partition for you (this isn’t essential but its a good idea as if there are issues it will likely cause the resize to fail).
Right click the main ‘ext4’ partition and select ‘resize’ then enter the new size you want it to be.
Right click the main ‘ext4’ partition and select ‘check’ (we’ve found this to be necessary to ensure the new partition size is correctly updated in the file system even though it should be done as part of the resize – kept us chasing constantly failed resizes for hours before we discovered this).
Finally click the green arrow button to carry out the changes.
Reboot the RPi (yep its stupid but we’ve found a reboot to be needed even after removing and re-inserting the SD card), sudo startx, run gparted, select the USB drive and check the ext4 partition is locked again (mounted) and has its boot string back.