Flashing the latest reRouter CM4 1432 OpenWrt image from Seeed Studio creates a 2 GiB root filesystem

Hi,

I own a reRouter CM4 1432 mini router from Seeed Studio and flashed the latest OpenWrt image made available by Seeed Studio today. Even though the emmc storage of the device is 32 GiB, after flashing, the root filesystem was configured to be 2 GiB in size and that is too small and doesn’t make use of the rest of the storage.

How can I fix this to resize the partition to use up all the remaining space in the storage device?

Here is what I did:
opkg update && opkg install lsblk fdisk losetup resize2fs to install necessary utilities.
df -Th should show /dev/root is ext4. Make a mental note.
Now, resize the partition, and we will resize the filesystem after:
In the following steps, take note of the boot start sector for the second partition, as you will delete this partition, and recreate it at the same starting point, which if done correctly, will NOT wipe any data. Don’t use the default starting sector, re-use the boot start sector value for the second partition. you can use the default for the end, as it’s the rest of the drive.

root@OpenWrt:~# [[fdisk /dev/sda]] 

Welcome to fdisk (util-linux 2.37.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.


Command (m for help): [[p]]

Disk /dev/sda: 59.63 GiB, 64023257088 bytes, 125045424 sectors
Disk model: ADATA_IM2S3134N-
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc120d9f5

Device     Boot Start       End   Sectors  Size Id Type
/dev/sda1  *      512     33279     32768   16M 83 Linux
/dev/sda2       33792    246783    212992  104M 83 Linux

Command (m for help): [[d]]
Partition number (1,2, default 2): [[2]]

Partition 2 has been deleted.

Command (m for help): [[n]]
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): [[p]]
Partition number (2-4, default 2): [[2]]
First sector (33280-31277231, default 34816): [[33792]]
Last sector, +/-sectors or +/-size{K,M,G,T,P} 
    (33792-125045423, default 125045423): [[]]

Created a new partition 2 of type 'Linux' and of size 59.6 GiB.
Partition #2 contains a squashfs signature.

Do you want to remove the signature? [Y]es/[N]o: [[n]]

Command (m for help): [[w]]

The partition table has been altered.
Syncing disks.

root@OpenWrt:~#

Reboot.

now, resize the file system:

BOOT="$(sed -n -e "\|\s/boot\s.*$|{s///p;q}" /etc/mtab)"
PART="${BOOT##*[^0-9]}"
DISK="${BOOT%${PART}}"
ROOT="${DISK}$((PART+1))"
LOOP="$(losetup -f)"
losetup ${LOOP} ${ROOT}
resize2fs -f ${LOOP}

reboot again, and you should be done.

See this link for a narrative of these instructions.

1 Like

Question for you, When I use a usb-c <> usb-c cable to attempt to flash the eMMC disk, I get no lights, and rpiboot just waits.
what cable did you use? I had to move the CM4 to another device first and flash it there.

Thanks @AG6HQ for the helpful instructions in your reply. One thing that wasn’t clear to me was whether all of the steps can be done when booted into OpenWrt on teh router if some of the steps need to be done in the dev mode, with the device accessible as a storage mount on another computer?

Since some of the above operations modify the filesystem, I am guessing that they may not be done when the OS is booted into and the filesystem is in use. Can you confirm?

I just used a normal USB-C to USB-A cable that I had lying around and it worked. I am not sure what the issue in your case might be. Have you tried using a different cable, just to be sure?

The Dreaded “Bad Cable”! I found another cable, and it in fact worked.

1 Like

@AG6HQ, can you clarify?

I did this by SSHing into the openwrt OS, after it was booted.
We are modifying the /dev/sda2 partition & FS, not /dev/sda1, which is the boot partition, which is why I believe this approach works.
once the partition is modified, the FS can be modified on-the-fly and while still mounted, which is quite common for OSes to handle these days.

So flash the eMMC disk, initial boot the OS, and it will do it’s thing and create the small partition, and a minute or two after first boot, you can ssh into the machine and perform these tasks. easy peasy.

1 Like

Thank you @AG6HQ! That worked like a charm and my issue is now resolved. :heart: