Resize root partition on Raspberry Pi 4


I purchased a Raspberry Pi 4 and followed the instructions to get OpenWRT running on it and it does pretty well. I also purchased a 64 GB sd card so that I'd have plenty of space. Of course, OpenWRT only uses a small part of this so I went ahead and looked for information on how to resize the partition. And it turns out the available information I found is quite dated, but I tried it anyway. Here's what I did. On OpenWRT with a terminal:

  • fdisk /dev/mmcblk0
  • delete partition /dev/mmcblk0p2
  • create it again, making sure the start sector is the same as before
  • don't delete the squashfs signature
  • write changes
  • reboot

Now OpenWRT boots fine. I'm using it right now. The final step is to actually resize the file system but that's where I'm stuck:

root@OpenWrt:~# resize2fs /dev/mmcblk0p2 
resize2fs 1.44.5 (15-Dec-2018)
resize2fs: Resource busy while trying to open /dev/mmcblk0p2
Couldn't find valid filesystem superblock.
root@OpenWrt:~# e2fsck -f /dev/mmcblk0p2
e2fsck 1.44.5 (15-Dec-2018)
/dev/mmcblk0p2 is in use.
e2fsck: Cannot continue, aborting.
root@OpenWrt:~# resize.f2fs /dev/mmcblk0p2 
	Error: In use by the system!

I also tried to do the resize2fs stuff on my Fedora system but it still fails:

[jerther@localhost ~]$ sudo resize.f2fs /dev/mmcblk0p2 
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 124895232 (60984 MB)
	Can't find a valid F2FS superblock at 0x0
	Invalid SB CRC offset: 1640914489
	Can't find a valid F2FS superblock at 0x1
[jerther@localhost ~]$ sudo resize2fs /dev/mmcblk0p2 
resize2fs 1.45.3 (14-Jul-2019)
resize2fs: Bad magic number in super-block while trying to open /dev/mmcblk0p2
Couldn't find valid filesystem superblock.

I made sure the new partition started at the same location. In fact, here's a comparison:


Device         Boot  Start    End Sectors  Size Id Type
/dev/mmcblk0p1 *      8192 139263  131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456 360447  212992  104M 83 Linux


Device         Boot  Start       End   Sectors  Size Id Type
/dev/mmcblk0p1 *      8192    139263    131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456 125042687 124895232 59.6G 83 Linux

And of course, no real change to the space available:

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 3.5M      3.5M         0 100% /rom
tmpfs                   931.7M    280.0K    931.4M   0% /tmp
/dev/loop0               98.7M     86.0M     12.7M  87% /overlay
overlayfs:/overlay       98.7M     86.0M     12.7M  87% /
/dev/mmcblk0p1           63.9M     15.7M     48.1M  25% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

So I'm really lost here. I've looked everywhere Google could lead me. Any clue?

your on the right track... and you def cannot fix the fs from within the runningOS... unless you drop to a tmp_root... / well it might be possible from failsafe also... ( you didn't mention this )

plenty of guides... you might have more luck searching for "virtualbox resize squashfs openwrt"...

The only useful link I could find is this one:

Which looked promising but...

Make the data partition larger (squashfs) (research only/not working)

At that point I gave up... My appology to those who get here from Google... I ended up making a backup of my config, download and install the EXT4 variant of OpenWRT, then resize the partition with GParted. In like 30 minutes I was back to where I left, but with all the space I wanted.

I believe EXT4 is less optimized for SD cards and might prematurely wear it but unless it's gone in less than a year even at low stress, a 20$ sd card is not worth my time that much :wink:

Thanks for the quick support though.

1 Like

My idea is to compile OpenWRT with specific options. The question is how to change them...

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.