Rasberry PI2 file system resizing

Hi everyone

When I run sudo fdisk I see for patritions:
/dev/mmcblk0
/dev/mmcblk2

I then ran:

sudo fdisk /dev/mmcblk0
sudo fdisk /dev/mmcblk2

and then

sudo resize2fs /dev/mmcblk0p2

then wrote it and exited. Upon restart, it did not startup.

Can someone shed some light on what I did wrong?
Thank you -Ryan

Re-size file system
There are no utilities included for automatic file system re-sizing. However, it’s not hard to do manually. Once booted:

sudo fdisk /dev/mmcblk0
Delete the second partition (d, 2), then re-create it using the defaults (n, p, 2, enter, enter), then write and exit (w). Reboot the system, then:

sudo resize2fs /dev/mmcblk0p2

I’m not 100% what went wrong here but I can suggest using GParted, which is a graphical tool. It’s capable of resizing and expanding the file system visually and can output the commands used if you wanted to study them.

GParted can be installed from the repository:

sudo apt-get update
sudo apt-get install gparted

It might be useful if Ubuntu MATE for the Raspberry Pi included GParted and/or a script to conveniently expand the file system in future.

Thank you lah7

I’ll try that. I have the img file back on the micro sd card so once I get it back up, I will give gparted a try. Thank you again!

This is where you went wrong. There is no mmcblk2, you did not follow the instructions which were to delete the 2nd partition then recreate it using resize2fs (following reboot). If you can boot and post the output of sudo fdisk -l it may be recoverable, otherwise you will have to start with a new image.

Thank you Milliways.

However, what is (d,2) and (n, p, 2, enter, enter) mean?

Re-size file system
There are no utilities included for automatic file system re-sizing. However, it’s not hard to do manually. Once booted:

sudo fdisk /dev/mmcblk0
Delete the second partition (d, 2), then re-create it using the defaults (n, p, 2, enter, enter), then write and exit (w). Reboot the system, then:

sudo resize2fs /dev/mmcblk0p2

It means to press the keys in that order: d → 2 to delete, n → p → 2 → Enter ⏎ → Enter ⏎ to re-create. Of course, be careful what you are pressing is reflected on screen. I think pressing h will display what the commands are for that screen.

Ahhhhhh and the light bulb turns on! Thank you!

can someone give me the exact commands toinput as I am new to linux and the pi. I didn’t succeed in resizing the file system…thank you !

Re-size file system

sudo fdisk /dev/mmcblk0

Delete the second partition (d, 2), then re-create it using the defaults (n, p, 2, enter, enter), then write and exit (w). Reboot the system, then:

sudo resize2fs /dev/mmcblk0p2

I don’t understand how to input

Delete the second partition (d, 2), then re-create it using the defaults (n, p, 2, enter, enter), then write and exit (w).

run sudo fdisk /dev/mmcblk0

Then press the keys in order:
d 2 to delete,
n p 2 Enter Enter to re-create.

Verify the prompts to make sure what you are entering is sensible.

Reboot and enter:-

sudo resize2fs /dev/mmcblk0p2

1 Like

ok, thank you Milliways for the detailed explanations. It worked.

that is a much better explaination that should be on the main page. whats in bold should in my opinion be in an instruction window like the other 2. also to clarify 1. d (hit enter key etc) same goes for the others. the double Enter is to clarify don’t mess with anything. Totally get it now :slight_smile: and it worked

One question though, it seems to increase the space, but not the space the file systems are on :frowning: so it got full fast. Anyway way of deciding where to install something. Says I have very low space 44mb but I go to check it out and I have 11 gb left

Good news is that in future, Ubuntu MATE 16.04’s Welcome for the Raspberry Pi will offer a one-click button to resize the file system, saving the hassle of these one-time commands.

1 Like

Not sure what kind of “one-click button” shall resiz the FS automatically, however it might be worth consider an automated FS resize after the 1st boot / 1st setup run after flashing the image.

There’s a nice Python script that can do the job in the background as described with “rootfs-resize” and I got it running manually on Ubuntu MATE 16.10.

Just a soul needs to include this kind of described mechanism in the next image release.

When :ubuntu_mate: Welcome is running on the Raspberry Pi:


I think automatic resizing may be a good idea, especially if it's in Python, meaning it could be something Welcome actively prompts to do, but the current one-click operation still works.

I passed this towards @Wimpy anyway. I'm not sure on the current status of the Raspberry Pi release.

Wow, thank you for this pointer.

I’m so much used to do everything using the CLI and trying to automate things with Bash and Python scripting that I might have missed this little window completely.

Have about 30 RPi devices installed here in a local school, and need to automate and maintain them all remotely using SSH and other tools, otherwise the kids will jump on me when class is starting and something is not working :grinning:

Thanks!

1 Like