Getting "There was an error running option 1 expand filesystem"

This is based on https://www.chrisnewland.com/resize-raspberry-pi-sd-card-partition-to-fill-32gb-card-from-a-running-raspberry-pi-245 but here for our own reference in case the other page ever goes away!

Backup your SD card to an image file first!

Enter this to see the current partition usage:

df

E.g.


Filesystem     1K-blocks    Used Available Use% Mounted on
rootfs           3698504 3351472    146524  96% /
/dev/root        3698504 3351472    146524  96% /
devtmpfs          494800       0    494800   0% /dev
tmpfs              99820     240     99580   1% /run
tmpfs               5120       0      5120   0% /run/lock
tmpfs             199620       0    199620   0% /run/shm
/dev/mmcblk0p1     57288   19400     37888  34% /boot

The rootfs and /dev/root is the same thing, its just a debian thing the have them both appear as seperate

Enter this:

sudo fdisk /dev/mmcblk0

Then press 'p' to see the current partitions on the disk.  E.g.


Disk /dev/mmcblk0: 7860 MB, 7860125696 bytes
4 heads, 16 sectors/track, 239872 cylinders, total 15351808 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
Disk identifier: 0xa6202af7
        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          122880    15351807     7614464   83  Linux

Now delete the 2nd partition (it won't actually delete the data on it)

Press 'd' > Enter

Press '2' > Enter

Now re-create it:

Press 'n' > Enter

Press 'p' > Enter

Press '2' > Enter

Enter the First sector and the same value as the original /dev/mmcblk0p2 partition (122880 from the above example).

For the Last sector just press enter to use the maximum value.

Now press 'p' > Enter to see the new partition setup.

Finally press 'w' > Enter to write it

Now reboot:

sudo shutdown -r now

Once its back do the resize

sudo resize2fs /dev/mmcblk0p2

This may take a little while to complete…

Now enter the command

df

and hey presto, you've expanded to use all the space :-)


Filesystem     1K-blocks    Used Available Use% Mounted on
rootfs           7513804 3352360   3810208  47% /
/dev/root        7513804 3352360   3810208  47% /
devtmpfs          494800       0    494800   0% /dev
tmpfs              99820     240     99580   1% /run
tmpfs               5120       0      5120   0% /run/lock
tmpfs             199620       0    199620   0% /run/shm
/dev/mmcblk0p1     57288   19400     37888  34% /boot

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

  1. tHors

    1 month ago

    Worked fine! READ ALL OF IT IN BEFOR! Make a backup!

  2. Corwin

    3 years ago

    if you use cfdisk instead of fdisk, you don’t have to specify the starting point. Less to go wrong.

  3. Borat Sagdiyev

    7 years ago

    Nice one, killed my image also. Poor, copy and pasted guide. Get cancer you mug.

    1. Kauê Doretto

      3 years ago

      Should have backed up your stuff before messing around with partitions. Screwing things up following internet tutorials blindly is the Internet’s 101 lesson for dumb people.

  4. JustTheTip88

    7 years ago

    Enter the First sector and the same value as the original /dev/mmcblk0p2 partition (122880 from the above example).

    I get lost on that part. I enter the same number that’s on mine and it says invalid number… What am I doing wrong?

  5. Dal1980

    7 years ago

    This has killed my image. Use caution before doing this ppl

  6. Robert Haigh

    8 years ago

    Awesome, thanks. Fixed my issue with RetroPi not resizing

Comments

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