Hi Chriz
I'm not going to have time to do a full write up of this tonight, but if you're anything like me you'll want to get your overlay sorted, so here's the untidy version of the full write up I'll do on this once I have time and have tested fully. Apologies if I put in stuff you already know, but just including roughly what I'll put together as a full guide. I'm wondering if the steps I'll detail below work out whether I'll be able to get this added to the device info page for the mochabin. For info, and I'll properly credit the genius of the people who people who's posts I used at a later date, the posts that I used were:
resizing the overlay when it is ext4 and not f2fs - interestingly the first time I managed to increase my overall, the instructions in here worked a bit better. However, when I did a new sysupgrade using the current stable image (which is squashfs) the steps that required you to be working on an ext4 filesystem didn't work, and after some head scratching I found the reason was that the partition my loop0 file was on was f2fs.
gl-mv1000 increasing_the_root_filesystem - from this I just took a couple of lines that allowed me to easily increase the partition size where loop0 resides. (only point 2 actually, and I used the resize option instead of creating and formatting a new partition)
So here goes:
- Do a df -h to check on the current partitions/system file sizes:
root@OpenWrt:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 3.5M 3.5M 0 100% /rom
tmpfs 3.9G 1.1M 3.9G 0% /tmp
/dev/loop0 98.8M 61.5M 37.3M 62% /overlay
overlayfs:/overlay 98.8M 61.5M 37.3M 62% /
tmpfs 512.0K 0 512.0K 0% /dev
Then install the packages you'll need by copying an pasting the following lines of code
opkg update
opkg install losetup e2fsprogs resize2fs block-mount kmod-fs-f2fs f2fs-tools cfdisk kmod-fs-ext4 parted rsync
You might not need all of these, it depends if you're running on ext4 or f2fs, but they all seem fairly small anyway.
Then confirm where the loop0 file resides using the following command. My results shown as well:
root@OpenWrt:~# losetup
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
/dev/loop0 0 3604480 1 0 /mmcblk0p2 0 512
I'm guessing you'll also have your loop0 on mmcblk0p2. If it's different though take note you'll need to change that in the next step.
root@OpenWrt:~# cfdisk /dev/mmcblk0
You can then use the down arrow key to select the second partition and left arrow key to go to “Resize” >> press return. Then use left arrow key to move cursor to new size entry, and change to the size you want, as below. Then press return, select “write” and yes to confirm. Then quit.
I chose not to use the full free space available, but that’s because I’m clueless and I don’t know if some free space is needed for the tmpfs to use, which was showing at 3.9GB. So I just chose to make mmcblk0p2 10GB in total because I can’t see myself ever needing that much anyway. If anyone who actually knows what they’re doing wants to correct me about whether I could use the whole of the free space please do.
I then just copied spence’s instructions as follows:
LOOP="$(losetup -n -O NAME | sort | sed -n -e "1p")"
ROOT="$(losetup -n -O BACK-FILE ${LOOP} | sed -e "s|^|/dev|")"
OFFS="$(losetup -n -O OFFSET ${LOOP})"
I then wanted to check it had done something so ran the following command with results shown (again something I picked up off Spence)
root@OpenWrt:~# echo ${OFFS} ${LOOP} ${ROOT}
3604480 /dev/loop0 /dev/mmcblk0p2
The next 2 lines then went fine as well:
LOOP="$(losetup -f)"
losetup -o ${OFFS} ${LOOP} ${ROOT}
But this is where things got a bit weird. From Spence's instructions, the next steps worked fine when I first ran them. It must be because somehow I had formatted my mmcblk0p2 partition as ext4 (no idea how I'd done that, or if it was because of using a different build image initially. But anyways, this initially worked.
fsck.ext4 -f ${LOOP}
If that command works for you, it may ask you to create a lost and found, just click yes or select whatever default options there are. Then you can run the next lines. If however you get an error, then skip to the lines a bit further down which work for the f2fs filesystem.
Final lines of code if running on ext4:
mount ${LOOP} /mnt
root@R4S-wrt:~# umount ${LOOP}
root@R4S-wrt:~# resize2fs ${LOOP}
If it tells you to "Please run 'e2fsck -f /dev/loop0' first.", then do that, and repeat the resize2fs ${LOOP} command.
Once that's done you might be tempted to do a df -h again and find to your dismay that the size of loop0 hasn't changed. Just do a:
reboot
And try your df -h again.
Different lines of code if you got an error after fsck.ext4 -f ${LOOP}. In my case, it was because I was on f2fs instead. So the lines of code to do are:
fsck.f2fs -f ${LOOP} #and go for default options if given any
mount ${LOOP} /mnt
umount ${LOOP}
resize.f2fs ${LOOP}
reboot
C:\Users\happy>ssh root@192.168.1.1
root@192.168.21.1's password:
BusyBox v1.35.0 (2023-01-03 00:24:21 UTC) built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 22.03.3, r20028-43d71ad93e
-----------------------------------------------------
root@OpenWrt:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 3.5M 3.5M 0 100% /rom
tmpfs 3.9G 276.0K 3.9G 0% /tmp
/dev/loop0 10.0G 495.2M 9.5G 5% /overlay
overlayfs:/overlay 10.0G 495.2M 9.5G 5% /
tmpfs 512.0K 0 512.0K 0% /dev
root@OpenWrt:~#
One of the things I'm still scratching my head about it that doing this process seems to take up about 490M on the loop0 now, whereas before the resize only 61M was used? No idea why.
Hope that helps, and let me know if you have any suggestions for making my instructions clearer.
Ta
Happy