Expand file system to use entire SD card

I bought an board with a 8GB board. I want to expand the file system to use the entire SD card but am running into a problem using raspi-config. I go to advanced settings... then to Expand Filesystem... I get an error stating "mmcblk0p2 is not the last partition. Don't know how to expand" 
I tried to used GParted to expand but it didn't work either... I created a partition from the unallocated space and when i tried use it it would not boot... 
Anyone know of a way to expand the file system?

Comments

  • The last partition is a swap partition. It is relatively complex to resize it but here are the steps.
    1) Turn off the swap with the swapoff command.
    2) Delete the swap partition using fdisk or gdisk.
    3) Extend (by deleting and re-addeding) the root partition in the partition table to the full size of your MicroSD card using fdisk or gdisk and keeping the starting offset.
    4) Resize the actual filesystem using `resize2fs` if your root partition is ext4 or using `btrfs fi resize max /`.
    If you still want to swap partition, you have to calculate the offsets and align it by MiB (1024 based rather than 1000 based) for optimal performance.
Sign In or Register to comment.