Pages

Saturday, 1 March 2014

Raspberry Pi: resizing the SD card root partition on Linux Arch

Do this only right after flashing the Arch image onto the SD-Card so if anything goes wrong you do not lose any data.

fdisk /dev/mmcblk0

In fdisk:

  1. Press ‘p’ to print the partition table:

    Command (m for help): p
    Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x417ee54b
    
    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
    
  2. Press 'd' to delete a partition:
    • Enter '2' to choose the second partition.
  3. Press 'n' to create a new partition:
    • Enter 'e' to select extended as partition type.
    • Partition number: <enter> to accept 2 as default partition number.
    • First sector: <enter> to accept default.
    • Last sector: <enter> to accept default.
  4. Press 'n' to create a new partition:
    • Enter 'l' to select logical as partition type.
    • First sector: <enter> to accept default.
    • Last sector: <enter> to accept default.
  5. Press 'w' to write the new partition table.

Reboot to force the kernel to recognise the new partition table.

sudo reboot

After the system has come back up you still have to resize the partition.

resize2fs /dev/mmcblk0p5

output:

resize2fs 1.42.8 (20-Jun-2013)
Filesystem at /dev/mmcblk0p5 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p5 is now 3865984 blocks long.

Done!