Page 1 of 1

Reclaiming flash space

Posted: Fri Sep 08, 2017 11:02 pm
by sampo
What are all the flash partitions for?

cat /proc/mtd
dev: size erasesize name
mtd0: 00030000 00010000 "u-boot" # 192 KB
mtd1: 00010000 00010000 "u-boot-env" # 64 KB
mtd2: 00010000 00010000 "factory" # 64 KB
mtd3: 007b0000 00010000 "firmware" # 7.8 MB
mtd4: 00117dae 00010000 "kernel" # 1.1 MB
mtd5: 00698252 00010000 "rootfs" # 6.7 MB
mtd6: 00120000 00010000 "rootfs_data" # 1.1 MB

I can understand the bootloader and its setting, the factory settings,
kernel, and rootfs related partitions, but what is this "firmware" that
seems to eat up nearly half the space on the flash?

Where I come from, a computer needs a bootloader to boot a kernel and
rootfs to hold the user land. I do not understand what the "firmware"
could possibly be needed for.

Can I reclaim the "firmware" partition and format it as a filesystem?

Are there any other ways to make more space for user programs? I do not
want to use SD card or USB flash. I recon 16MB of built-in flash should
be plenty enough to run a Linux computer.


Re: Reclaiming flash space

Posted: Sat Sep 09, 2017 1:31 am
by Vonger
firmware is where we store the Linux system(openwrt), so you can not reclaim it, you can check the source code, the partition define in VOCORE2.dts

Re: Reclaiming flash space

Posted: Sat Sep 09, 2017 9:52 am
by sampo
I checked target/linux/ramips/dts/VOCORE2.dts but that did not really answer my question.

If Linux is on mtd3 "firmware", then what is the function of mtd5 "rootfs"?

If I run mount I get:

rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mtdblock6 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)

I only see /dev/mtdblock6 mounter directly. Presumably rootfs somehow connects to mtd5, but I can not fathom where the
mtd3 "firmware" Linux filesystem is mounted?


Re: Reclaiming flash space

Posted: Wed Sep 13, 2017 6:36 pm
by sampo
Apparently the explanation to the mystery is that mtd6 (rootfs_data) is inside mtd5 (rootfs), which is inside mtd3 (firmware), i.e. the devices
are nested, not linearly after one another. Thus what appears to be 16 MB flash is in reality just 8 MB flash.

All this is explaned in