Changes to the partition layout in the July 2013 image invalidate the information in this post, please see the comment section for details.
I run Arch Linux on my Raspberry Pi, this defaults to creating a 2GB partition for it’s data which I needed to extend to access the remaining space on my 16GB SD card. I’ll explain how I did this below but only do this on a newly installed Arch installation so if anything goes wrong you do not lose any data.
To start I’m assuming you’ve installed Arch on your SD card, if you haven’t follow this guide to show you how.
Boot Arch on your Raspberry Pi, log in as root on the console or via SSH, either way works fine. To start we will remove the partition containing Arch and replace it with another partition starting in the same location but ending at the end of the SD Card, this will vary depending on the size of the card you have.
[root@alarmpi ~]# fdisk /dev/mmcblk0
- Press ‘p’ to print the partition table, take note of the number in the Start column of the row starting ‘/dev/mmcblk0p2’
- Press ‘d’ to delete a partition then enter ‘2’ to choose the second partition
- Press ‘n’ to create a new partition, all the default options are fine:
- Choose ‘primary’ partition type
- Partition number 2
- The starting block should be same number you took note of in step 1
- The default ending block should be the last available block on the SD card, this will vary depending on what size SD card you have
4. Press ‘w’ to write the new partition table and return to the bash prompt
Reboot now to force the kernel to recognise the new partition table.
[root@alarmpi ~]# reboot
After reboot we now we have the same two partitions we started with except that the second partition containing the root filesystem is now larger. However, the root filesystem is still only 2GB so we now need to resize the filesystem in order to fill the partition.
[root@alarmpi ~]# resize2fs /dev/mmcblk0p2
And there you go, you can now run ‘df -h’ to view your new partition sizes! Here’s mine…
[root@alarmpi ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/root 15G 457M 14G 4% / devtmpfs 51M 0 51M 0% /dev tmpfs 105M 0 105M 0% /dev/shm tmpfs 105M 260K 105M 1% /run tmpfs 105M 0 105M 0% /sys/fs/cgroup tmpfs 105M 0 105M 0% /tmp /dev/mmcblk0p1 90M 24M 67M 27% /boot