Tip: Extending the partition on a Raspberry Pi install

Tip: Extending the partition on a Raspberry Pi install

image

When you get your new Raspberry Pi and download one of the images you will find that even though you may have 16GB card the Raspberry Pi is only use a small part of it. This is because the downloaded image is of a fixed size and so most of the space goes to waist.

From Debian Linux on the Pi you can use gparted, a gui partition tool and you could create a new partition and use that to store data. This is fine but it leaves your Linux install partition rather small and if your planning to install lots of programs it maybe a little cramped so I wanted to extend the install partition and use all the available space. Because the Pi is running from the installed partition you can’t simply extend it. After some searching around I found lots of different ways of achieving the results and that one that seemed simplest to me was by using Gparted from another Linux install. If you have a Linux machine with a SD card your all set, if you don’t you can do what I did which is to download Ubuntu and use their USB tool to make a bootable USB drive, then I booted from the USB drive into Ubuntu using the live option (which doesn’t touch the installed OS).

Once booted I loaded Gparted and selected the SD card  from the dropdown list on the top right (mine was listed as /dev/sdc). You can’t immediately extend the partition because the swap part is in the way. So you need to delete the Linux Swap partition and then you can go to the main partition (mine was /dev/sdc2) and right click on it and select Unmount, then select the Resize/Move option. You can then increase the size and I left 2gb for the swap file (I am not sure how big a Debian swap file should be).  Next I created a new partition selecting Linux-swap as the file system and let it use the remaining 2gb space.

UPDATE: I have been advised from @biglesp that a Debian swapfile should be twice the size of the installed RAM, so for the Raspberry Pi 512mb is plenty

Then you hit the apply all option and it should write the changes and you can try booting from the SD card on the Raspberry Pi. I would try this before putting data on the Pi in case it all goes wrong and I am sure Linux experts will have a better way of doing this but it worked on the couple SD cards I tried and I now have plenty of space to try some HD video files on the Pi.

image

Share

Leave a Reply

Your email address will not be published. Required fields are marked *