Resizing the SD card partitions on the default partition scheme that comes with the Debian image for the Raspberry Pi is quite easy.
- Shutdown your Raspberry Pi (sudo shutdown -h now) and remove the SD card.
- Insert the SD card into your computer.
- Open Gparted and click on the menu item GParted > Devices. Here you will see a list of drives in the format /dev/sdX, where X is your drive letter. Select the device that represents your SD card (you can usually judge this by the size). Make a note of the device name at this point (eg: /dev/sdc)
- Now we are going to move the swap partition to the end of the disk. Right click on the last partition and select Resize/Move.
- A new window will display and allow you to manipulate the swap partition.
- Click and hold in the middle of the partition and drag the partition to the far right (the end of the disk).
- Click the Resize/Move button. You will receive an error that this may cause your operating system to fail to boot, you can safely ignore this as we are only moving the swap partition.
- Now we are going to resize the root partition. Right click on the second partition on the disk and select Resize/Move like before.
- This step is very important. It is now time to select the slider on the right side of the root partition and drag it to fill the remaining empty space on the disk. However, you need to ensure that you DO NOT move the beginning of the partition at all. The Free space preceding (MiB): parameter should stay at 1, and you should definitely not manually enter it. A small change here may re-align the start of the partition and fry your OS installation.
- You will now be presented with the final partition table.
- Click the green tick on the top of the GParted window to apply the pending operations. A dialogue box will pop up asking if you are sure you want to apply the changes, this is your last chance to bail out, no changes have been made to your SD card yet. If you have important data on the SD card it might very well be lost if this operation fails.
- Once the operation is completed you will see a confirmation dialogue. It is normal to have a warning or two at this stage (I had 4).
- Almost done! Quit GParted
- Open a new terminal and run the following commands, remembering to replace the X in /dev/sdX with the letter from earlier (/dev/sdc in my case).
- Clean the root partition: sudo e2fsck -f /dev/sdX2
- Resize the root partition: sudo resize2fs /dev/sdX2
- That’s it! Remove your SD card and boot up your Raspberry Pi
Please contact me with any suggestions/corrections and leave a comment if you found this helpful.