Growing the root filesystem on Arch Linux ARM for the Raspberry Pi

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

In fdisk,

  1. Press ‘p’ to print the partition table, take note of the number in the Start column of the row starting ‘/dev/mmcblk0p2’
  2. Press ‘d’ to delete a partition then enter ‘2’ to choose the second partition
  3. 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

9 Replies to “Growing the root filesystem on Arch Linux ARM for the Raspberry Pi”

  1. I’ve done this in the past using exactly the steps you describe, and it always worked fine. Today however I created a new SD card using the latest (July 2013) ArchLinux dist for Raspberry Pi, and I can’t seem to make it work. It boots fine, but when I list the partitions using fdisk -l it shows three instead of two:

    Device Boot Start End Blocks Id System
    /dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA)
    /dev/mmcblk0p2 186368 3667967 1740800 5 Extended
    /dev/mmcblk0p5 188416 3667967 1739776 83 Linux

    No matter which partition(s) I delete or create, the result is unbootable and leaves me at the kdb> prompt.

  2. Interesting, I’ll need to test it with the latest build but yours uses an extended partition as p2 and a logical partition within that as p5. This is different to earlier builds which used all primary partitions. You would need to delete p5 then p2, then create p2 as extended and p5 as logical in that order, this might work but I would need to test it.

  3. There’s an amazing magical thing that happens as soon as you post an issue for the world to see…. minutes later you solve it yourself. My problem had nothing to do with the steps I was following, but simply that I wasn’t waiting long enough after shutting down the RPi before power cycling it. Once I carefully watched for the activity light to stop blinking before removing power, I was finally able to boot with the resized partition.

    The extended partition thing was strange though, hadn’t seen that before.

    1. it’s always handy to manually enter ‘sync’ on the command line to be sure your disk buffers are wrote down, you might have reset before it did this as part of the shutdown sequence.

  4. those instructions fail with the rpi img of 03-2014. fdisk version affords no logical “l”partition option, only primary or extended

    1. Logical partitions are nested inside an extended partition, you first create an extended partition and then you can create logical partitions.

  5. i have volumio on my raspberry and want to use the free space on my sd-card to save music. so i did all the steps you wrote here, but the last step after the reboot isnt working. all the steps before worked, at least it seemed so. thats what i get back:

    resize 2fs 1.42.5 (29-Jul-2012)
    resize2fs: Bad magic number in super-block while trying to open /dev/mmcblkop2
    Couldn’t find valid filesystem superblock.

    what does this mean? i dont have much experience with raspberry and programming. and sorry for my english,i know its not the best.

    thanks for answers

    greets konstantin

Leave a Reply

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