Expanding partition size (squashfs and ext4) and misc SG105W questions

Ok, so expanding worked until extendig the F2FS overlay. Here´s the output of my SSH session.

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}
losetup: failed to parse offset: '/dev/loop0': Invalid argument
root@OpenWrt:~# fsck.f2fs -f ${LOOP}
Info: Force to fix corruption
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 0 (0 MB)
Magic Mismatch, valid(0xf2f52010) - read(0x0)
        Can't find a valid F2FS superblock at 0x0

I had that error before and ignoring it led to installing it from scratch. Any help is welcome :slight_smile:

I assume this is a squashfs (which image did you use?) ?

1 Like

No, but I had the same error with squashfs. This is EXT4.
generic-ext4-combined.img.gz

the losetup shouldn't be needed with ext4.

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.

might consider using the latest and greatest instead
https://archive.openwrt.org/releases/23.05.0/targets/x86/64/

1 Like

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?

I would, just to make sure.

x86 is the most future proof of all openwrt platforms :wink:

2 Likes

Ok, perfect! Last question (for now): should I go with squashfs or EXT4? I think squashfs is the more safe way for me since there´s this guide.

I've always used ext4, because it's easier to resize :wink:

2 Likes

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.

ext4 FTW :slight_smile:

1 Like

After installing this for another 3 or 4 times I finally managed to get this working.

Thank you guys for your patience helping a noob in need.

I found this link really helpful to understand the resizing on EXT4 [HOWTO] Resizing root partition on x86 (March 2023 edition)

Thanks again and best regards!
Jan

Ok, this is really my last question for today :slight_smile:

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?

Thanks again!

on the same radio ?
don't think so ...

1 Like

I thought the SG105W was capable of 2.4 and 5 GHz? Does it only have one radio?

Oh... it´s just a one band radio... dang

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:

  • Preserve the scripts through firmware upgrade.
  • Automatically run after firmware upgrade.

So no need to repeat when upgrading firmware!

5 Likes

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. :smile: 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:

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

PS. If you want to turn those two uci-defaults script into an easily installable package, let me know.

1 Like

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.

3 Likes

So I didn't imagine the boot loop, then? It did happen? That's a relief; I was wondering if I was losing my mind... :crazy_face:

One way or another, thank you for a great tool!

1 Like