boot openwrt off a flash drive.
dd or zcat the ext4 combined image to the drive.
fdisk the drive
delete the 2nd partition, and recreate it immediately afterwards, with the new (max?) size.
save and exit
do a resize2fs on the partition
done
update grub.conf in /boot/grub on the drive (locted on the 1st partition) to read root=/dev/sda2 (or whatever the partition is called) instead of root=PART...
or simply edit grub config during reboot, then change it once you've booted openwrt.
Thanks again for your help! I think I will start again from scratch or do you think this is not neccessary even for a noob like me?
Oh, and 23.05.0 works on SG105W?
Ok, so installed the squashfs build of 23.05.0 from scratch and everything worked fine until I got to the resizing part. I got the following error message
root@OpenWrt:~# LOOP="$(losetup -n -O NAME | sort | sed -n -e "1p")"
root@OpenWrt:~# ROOT="$(losetup -n -O BACK-FILE ${LOOP} | sed -e "s|^|/dev|")"
root@OpenWrt:~# OFFS="$(losetup -n -O OFFSET ${LOOP})"
root@OpenWrt:~# LOOP="$(losetup -f)"
root@OpenWrt:~# losetup -o ${OFFS} ${LOOP} ${ROOT}
root@OpenWrt:~# fsck.f2fs -f ${LOOP}
Info: Force to fix corruption
Magic Mismatch, valid(0xf2f52010) - read(0x63f0)
Can't find a valid F2FS superblock at 0x0
Magic Mismatch, valid(0xf2f52010) - read(0x2005)
Can't find a valid F2FS superblock at 0x1
root@OpenWrt:~# mount ${LOOP} /mnt
root@OpenWrt:~# umount ${LOOP}
root@OpenWrt:~# resize.f2fs ${LOOP}
Magic Mismatch, valid(0xf2f52010) - read(0x63f0)
Can't find a valid F2FS superblock at 0x0
Magic Mismatch, valid(0xf2f52010) - read(0x2005)
Can't find a valid F2FS superblock at 0x1
If I reboot now, OpenWrt goes into a bootloop. The odd thing is that I can´t boot from a legacy USB stick then, only the EFI image works if I boot from USB.
I need to resize since I want to run Adguard and Tailscale on my box.
For now there´s only 5Ghz Wifi available which runs fine. But I also need 2.4 Ghz since I have a lot of devices in my network that only work on 2.4 Ghz.
Is there a way to have two Wifis, one with 5Ghz, the other with 2.4?
There is an even easier way to do the root partition resizing. See the wiki page https://openwrt.org/docs/guide-user/advanced/expand_root which contains a script file that will expand either ext4 or squashfs images. The best part about it is that it:
When I first tried it a few months ago, I tried it in conjunction with Attended Sysupgrade. And it looked like this combination resulted in a boot loop. Recently, I tried it again, and everything works as it should, you just need to let the system reboot enough times.
Here's what I think happens:
Attended Sysupgrade requests a build, downloads firmware, installs it and reboots the system (Reboot One)
Since this is now a first-boot situation, the resizer kicks into action, resizes the root partition, and reboots again (Reboot Two)
Then, the resizer resizes the root filesystem and reboots yet again (Reboot Three), just to be sure that the system can boot in its intended state
And now I am doubting my recollection. Did I actually have a boot loop in the earlier tries, or did I freak out after Reboot Two or Three and shut the test unit down to reinstall from scratch? We will never know...
@vgaetera thanks for the script. What's the reason for two files/reboots in there? On my XG-135 I use an earlier version of that script and do it all at once and then reboot after:
I don't know about two files, but I have a theory about two reboots. I've done enough manual resizings to notice that occasionally, resize2fs acts like the partition has not been resized and exits with a message, "Nothing to do". Rebooting fixes that. I don't know what the exact issue is, but it appears that in some cases, partition resizing becomes detectable only after reboot...
This said, I'd still love to hear from the author. Also, I would like to join you in expressing my gratitude to the author.
To tell the truth, a typical Linux setup can expand its root partition and filesystem online without rebooting, but OpenWrt requires some extra steps in general case.
Rebooting helps to avoid online fsck and allows to unify the resizing procedure for ext4 and squashfs images and their efi variants.
For some image types reboot can be skipped at the cost of running fsck online, but this may not work well for other image types, as some of my experiments ended with the soft-locked root filesystem no longer possible to resize.
BTW, there was indeed an issue with squashfs images generated by Attended Sysupgrade, but I managed to isolate and hopefully fixed it.