Expanding SD card size on Rpi3

I have recently installed OpenWRT on my raspberry pi and I wanted to install MQTT on the SD - I have found out that the size used on my SD is so small that I am not sure if I can even use it right now.

I want to expand the SD size to its full - 32GB.

root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               104816     26768     75920  26% /
tmpfs                   470660       948    469712   0% /tmp
/dev/mmcblk0p1           65390     17280     48110  26% /boot
tmpfs                      512         0       512   0% /dev

Looks like I have VERY small storage to work with. Why is that?
I have tried to resize the storage following a guide and I have not found any way to accomplish that at all. Even guides here is the forum where not the help I need.

When I run :

root@OpenWrt:~# losetup -a
root@OpenWrt:~#

I do NOT get anything at all - At first i was not even able to run the command losetup - I installed it.. NOT sure if I did it correctly - since it looks like it does NOT work at all.

opkg install losetup

I want to be able to use all the 32GB on My Pi since I want it also to be an MQTT broker.
This storage limitation prevents me from using the Pi the way I intended to use it :frowning:

This is my OS info

NAME="OpenWrt"
VERSION="21.02.1"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt 21.02.1"
VERSION_ID="21.02.1"
HOME_URL="https://openwrt.org/"
BUG_URL="https://bugs.openwrt.org/"
SUPPORT_URL="https://forum.openwrt.org/"
BUILD_ID="r16325-88151b8303"
OPENWRT_BOARD="bcm27xx/bcm2710"
OPENWRT_ARCH="aarch64_cortex-a53"
OPENWRT_TAINTS=""
OPENWRT_DEVICE_MANUFACTURER="OpenWrt"
OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/"
OPENWRT_DEVICE_PRODUCT="Generic"
OPENWRT_DEVICE_REVISION="v0"
OPENWRT_RELEASE="OpenWrt 21.02.1 r16325-88151b8303"

I would be happy if you can guide me on how to resize the Pi Storage to the max of 32GB.

Edit:
I have managed to use fdisk to get to the point that I need to resize the fs

root@OpenWrt:~# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0 29.7G  0 disk
├─mmcblk0p1 179:1    0   64M  0 part /boot
└─mmcblk0p2 179:2    0 29.7G  0 part /

But I can't run the resize2fs and NOT even install the package.
I am not sure what i should do now?

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               102.4M     26.4M     73.9M  26% /
tmpfs                   459.6M    948.0K    458.7M   0% /tmp
/dev/mmcblk0p1           63.9M     16.9M     47.0M  26% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

Thanks

That is because you're running the squashfs image, which is not simple to resize.

You could switch to the ext4 image and resize it, or create a third partition which is ext4 and mount it for data storage. The easiest way to do either of these is to mount the card on a desktop Linux and use the gparted program.

1 Like

Thanks @mk24

I was able to resize it using mount as Read only gor the root / and tune2fs for the /dev/mmcblk0p2
Then I ran fsck.ext4 to check file (as requested) and types "y" on all.
Reboot and then I was able to use the resize2fs on /dev/mmcblk0p2
I am sure that this is what you meant.

Thanks.

Hey @aryeduino ,

Would you mind posting the exact step-by-step instructions for how to expand the file system? Basically, adding to your original post and making the full process clearer?

Thanks in advance!

2 Likes

To share what worked for me on OpenWRT 22.03.2 with SquashFS.

1. Flash image to SD as normal with the firmware selector (I added packages to mine)
2. ssh into router
3. "opkg update && opkg install cfdisk resize2fs"
4. "cfdisk /dev/mmcblk0"
5. Create a NEW PRIMARY partition in the free space at the end. Delete this new partition. Select /dev/mmcblk0p2 and RESIZE it. The default entries will take the whole space.
6. Reboot
7. ssh into router
8. "resize2fs /dev/loop0"
9. Success!