Help needed: where has my flash memory gone? (FB 4040 )

I must have misconfigured my FB 4040 somehow, and I can't find the reason. (Which is normal in most cases: one does not easily find their own mistakes!)

I'd appreciate any help with this problem:

The FB 4040 is supposed to have 32 MB of internal flash memory, but the system overview tells me there's only 15 MB of memory available:

root@fb4040:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                15.3M     15.3M         0 100% /rom
tmpfs                   121.2M      1.2M    120.0M   1% /tmp
/dev/mtdblock14          10.3M      9.9M    352.0K  97% /overlay
overlayfs:/overlay       10.3M      9.9M    352.0K  97% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/mtdblock15           1.0M    196.0K    828.0K  19% /mnt/mtdblock15
/dev/sdb1                14.1G     13.8M     13.4G   0% /mnt/usb

root@fb4040:~# cat /etc/config/fstab

config global
        option anon_swap '0'
        option auto_swap '1'
        option auto_mount '1'
        option delay_root '5'
        option anon_mount '1'
        option check_fs '1'

config mount
        option uuid '1234567890...'
        option enabled '1'
        option enabled_fsck '1'
        option target '/mnt/usb'

The "overlay" parts irritates me a lot. Many months ago I tried to use an SSD to expand the flash memory via overlayfs, but I decided against it and reversed all the settings later - at least that is I think I did...

I upgraded the system to OpenWRT 22.03.x a few weeks ago, and the now attached USB flash drive (/dev/sdb) is not supposed to expand the internal memory, it is meant only as an external drive, nothing more. Still, to me it looks that half the internal memory is missing, and LUCI tells me, that 9.91MB out of a total of 10.15MB is actually being used, and I can't install any more packages.

So where has all the internal flash memory of 32MB gone? Did I do something wrong or am I misinterpreting something?

Many thanks in advance!

that's the flash chip size, not the free space ?

as for what you've installed, we don't know ...

1 Like

~28 MB usable flash, https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-fritzbox-4040.dts;h=ec1112ee2bc58e82233c7d5f35a8a18d44c4c434;hb=HEAD#l231
~7 MB should be taken up by the default OpenWrt (23.05.0 release-), a little padding aside, so better count ~8 MB.

/dev/root would roughly be the image size (kernel+rootfs, so the aforementioned 8 MB), but if you installed additional stuff via imagebuilder or asu, 15.3 MB isn't that unlikely.
This leaves you with 10.3 MB for the overlay, which you have almost filled up (9.9 MB), bar 352 KB remaining free space.

What you have installed is something only you can now, with the information provided.

Is it possible that you create an image with image builder with packages e.g. samba4 (I know that is huge :slight_smile: ) but then you decide to upgrade this package (I know not recommended) the upgrade will then be on the overlay so you are consuming the overlay with an already compiled package?

How do I get this information?

According to the hardware description, this device is supposed to be using 32 MB of internal flash memory, and this 50% difference was/is confusing me. But if I understand this correctly now, these 32 MB are split into half, one half is used for the system itself, the downloaded OpenWRT firmware, and the other half is used for installing additional packages and for updated packages, hence the use of an overlay fs.

Am I right or am I still misunderstanding it?

I think @slh description is spot on.

32MB total flash space, ~8MB (would be) used by standard image, but you added some extra stuff (don't ask us what), then some more extra stuff outside the stuff added to the image :wink:

you can always see the packages you've installed in the software sub menu in the webui.

note, if you try to uninstall packages that came with the image, you'll actually reduce the available flash space, those can't be removed, you'll need a new image.

Yes, I see your point there. But the reason I got confused is, that "df" only reports half the total size of flash memory (=hard drive space), and not the amount the device is supposed to be equipped with.

Let me compare this to my Linux box: if I install a 250 GB hard drive, and I install the basic system plus some additional software, "df" would still tell me that the size of the built in disk is 250 GB. It would not tell me the size of the disk minus all the installed system and software. But in OpenWRT, "df" does just that, and I do not quite understand why the total size of file system "/" is less than half the physical flash memory. Compared to my Linux box, this would mean that the hard drive is split into two partitions, one of which is used for the basic system, and the other one is used for additional software, like office software, a browser or video software.

Is this comparison correct so far?

If it is right, then it would mean that the basic software in this case, the basic OpenWRT firmware, takes the whole first partition of ~15 MB, which "df" shows as "/dev/root", while "/dev/mtdblock14" would then be the second partition, which is mounted as an overlay file system, to provide a possibility to upgrade system packages.

Am I right?

Well, in typical devices there are lots of "mtd partitions" although a normal flash does not really have a proper partition table (unlike your example of your x86 Linux box hard drive). So, I wouldn't just say first and second. There is also bootloader, bootloader env, wifi calibration data partition etc.

See below an example from my router. Lots of partitions (mtd areas), and the main ubi mtd partition actually contains several ubi subpartitions (kernel, r/o rootfs, and r/w overlay rootfs_data). "df" only shows the r/o rootfs and r/w overlay.

root@router5:~# dmesg | grep nand
[    0.748642] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xaa
[    0.749190] nand: Micron MT29F2G08ABBGAH4
[    0.755799] nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 128
[    0.974249] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xaa
[    0.989202] nand: Micron MT29F2G08ABBGAH4
[    0.995564] nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 128
[    0.999838] 25 qcomsmem partitions found on MTD device qcom_nand.0
[    1.006952] Creating 25 MTD partitions on "qcom_nand.0":


root@router5:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "0:sbl1"
mtd1: 00100000 00020000 "0:mibib"
mtd2: 00080000 00020000 "0:bootconfig"
mtd3: 00080000 00020000 "0:bootconfig1"
mtd4: 00300000 00020000 "0:qsee"
mtd5: 00300000 00020000 "0:qsee_1"
mtd6: 00080000 00020000 "0:devcfg"
mtd7: 00080000 00020000 "0:devcfg_1"
mtd8: 00080000 00020000 "0:apdp"
mtd9: 00080000 00020000 "0:apdp_1"
mtd10: 00080000 00020000 "0:rpm"
mtd11: 00080000 00020000 "0:rpm_1"
mtd12: 00080000 00020000 "0:cdt"
mtd13: 00080000 00020000 "0:cdt_1"
mtd14: 00080000 00020000 "0:appsblenv"
mtd15: 00100000 00020000 "0:appsbl"
mtd16: 00100000 00020000 "0:appsbl_1"
mtd17: 00080000 00020000 "0:art"
mtd18: 06100000 00020000 "rootfs"
mtd19: 00900000 00020000 "0:wififw"
mtd20: 06100000 00020000 "rootfs_1"
mtd21: 00900000 00020000 "0:wififw_1"
mtd22: 01600000 00020000 "ubifs"
mtd23: 00080000 00020000 "0:ethphyfw"
mtd24: 00280000 00020000 "certificate"


root@router5:~# ubinfo -a
UBI version:                    1
Count of UBI devices:           1
UBI control device major/minor: 10:126
Present UBI devices:            ubi0

ubi0
Volumes count:                           3
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     776 (98533376 bytes, 93.9 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       0
Count of reserved physical eraseblocks:  40
Current maximum erase counter value:     57
Minimum input/output unit size:          2048 bytes
Character device major/minor:            246:0
Present volumes:                         0, 1, 2

Volume ID:   0 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        40 LEBs (5079040 bytes, 4.8 MiB)
State:       OK
Name:        kernel
Character device major/minor: 246:1
-----------------------------------
Volume ID:   1 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        122 LEBs (15491072 bytes, 14.7 MiB)
State:       OK
Name:        rootfs
Character device major/minor: 246:2
-----------------------------------
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        570 LEBs (72376320 bytes, 69.0 MiB)
State:       OK
Name:        rootfs_data


root@router5:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                14.8M     14.8M         0 100% /rom
tmpfs                   434.0M      3.9M    430.2M   1% /tmp
/dev/ubi0_2              62.0M      1.4M     57.4M   2% /overlay
overlayfs:/overlay       62.0M      1.4M     57.4M   2% /
tmpfs                   512.0K         0    512.0K   0% /dev