Out of space - my ideas

Discuss the technical details of Gargoyle and ongoing development

Moderator: Moderators

Post Reply
lpm11
Posts: 15
Joined: Sat Jan 05, 2013 8:07 am

Out of space - my ideas

Post by lpm11 »

Hi,

I will write my ideas about how to cope with small flash size.

1.
There is a parameter for squashfs called blocksize.
If you increase it (from 256k to 512k or 1024k), filesystem will take less space (few %) but boot time (and access time to noncached files) will increase.

It could be helpful, where there is no other way to reduce used space for filesystem - for example on 4MB-flash routers.

Replace
CONFIG_TARGET_SQUASHFS_BLOCK_SIZE=256
with
CONFIG_TARGET_SQUASHFS_BLOCK_SIZE=1024
in target/(...)/config file.

2.
I also think, that CONFIG_PACKAGE_wireless-tools=y is not used anymore - am I right?

3.
Settings for kernel could be tweaked,

Replace:
CONFIG_KERNEL_KALLSYMS=y
CONFIG_KERNEL_DEBUG_KERNEL=y
CONFIG_KERNEL_DEBUG_INFO=y
# CONFIG_STRIP_KERNEL_EXPORTS is not set
with:
# CONFIG_KERNEL_KALLSYMS is not set
# CONFIG_KERNEL_DEBUG_KERNEL is not set
# CONFIG_KERNEL_DEBUG_INFO is not set
CONFIG_STRIP_KERNEL_EXPORTS=y

It should be done only on production releases (not beta), as all kernel crashes/warns will not include symbols - crash dumps would be undebuggable.

CONFIG_STRIP_KERNEL_EXPORTS is worth to mention:
It could (probably will) make impossible to load OpenWRT modules for hardware not included in Gargoyle build. But it is that way now (OpenWRT has other kernel version).

4.
And there is similar setting for userspace - CONFIG_USE_MKLIBS. If you enable it, you will be not able to run (probable most of) the OpenWRT software (packages from their official repos); and only the build packages could be installed (so you will get only Gargoyle repo usable).

You could save lot of space.. that's the way Tomato firmwares could include OpenVPN on 4MB-builds.

Replace
# CONFIG_USE_MKLIBS is not set
with
CONFIG_USE_MKLIBS=y

5.
For VPN builds, you can disable cyassl and let everything use OpenSSL.

---
I am sure that 1, 2, 5, of my points can be safely enabled.
You can also use point 3 for production builds (1.10 etc.)

Lantis
Moderator
Posts: 6735
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: Out of space - my ideas

Post by Lantis »

lpm11 wrote:Hi,

I will write my ideas about how to cope with small flash size.

1.
There is a parameter for squashfs called blocksize.
If you increase it (from 256k to 512k or 1024k), filesystem will take less space (few %) but boot time (and access time to noncached files) will increase.

It could be helpful, where there is no other way to reduce used space for filesystem - for example on 4MB-flash routers.

Replace
CONFIG_TARGET_SQUASHFS_BLOCK_SIZE=256
with
CONFIG_TARGET_SQUASHFS_BLOCK_SIZE=1024
in target/(...)/config file.

2.
I also think, that CONFIG_PACKAGE_wireless-tools=y is not used anymore - am I right?

3.
Settings for kernel could be tweaked,

Replace:
CONFIG_KERNEL_KALLSYMS=y
CONFIG_KERNEL_DEBUG_KERNEL=y
CONFIG_KERNEL_DEBUG_INFO=y
# CONFIG_STRIP_KERNEL_EXPORTS is not set
with:
# CONFIG_KERNEL_KALLSYMS is not set
# CONFIG_KERNEL_DEBUG_KERNEL is not set
# CONFIG_KERNEL_DEBUG_INFO is not set
CONFIG_STRIP_KERNEL_EXPORTS=y

It should be done only on production releases (not beta), as all kernel crashes/warns will not include symbols - crash dumps would be undebuggable.

CONFIG_STRIP_KERNEL_EXPORTS is worth to mention:
It could (probably will) make impossible to load OpenWRT modules for hardware not included in Gargoyle build. But it is that way now (OpenWRT has other kernel version).

4.
And there is similar setting for userspace - CONFIG_USE_MKLIBS. If you enable it, you will be not able to run (probable most of) the OpenWRT software (packages from their official repos); and only the build packages could be installed (so you will get only Gargoyle repo usable).

You could save lot of space.. that's the way Tomato firmwares could include OpenVPN on 4MB-builds.

Replace
# CONFIG_USE_MKLIBS is not set
with
CONFIG_USE_MKLIBS=y

5.
For VPN builds, you can disable cyassl and let everything use OpenSSL.

---
I am sure that 1, 2, 5, of my points can be safely enabled.
You can also use point 3 for production builds (1.10 etc.)
1.
Are you sure about this? That seems backwards logic. My understanding of block sizing is that the larger the block size, the worse space usage gets.
E.g. I want to store 1kb in a 1024kb block, I need to use the entire block. Which is wasteful. Decreasing block size decreases waste.
Is this not the case?

2.
Yes, and it has been removed from most (all?) configs.

3.
Interesting suggestion. It does make debugging harder/impossible as you mentioned.
Even in a release build these are useful. It's an option though.

5.
VPN builds aren't out of space (yet), so I don't see this option being useful (yet lol).


These are still good suggestions!
Do you have a build comparison to show the difference in sizes? That would be useful too!
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

lpm11
Posts: 15
Joined: Sat Jan 05, 2013 8:07 am

Re: Out of space - my ideas

Post by lpm11 »

1.

No.

It is not physical flash block size (and padding) - it is about how much portion of data is compressed at once.
If you know 7-Zip and LZMA, think about block size as dictionary size - this is not exact, but similar analogy.

More data produce greater dictionary for LZMA, so data could be more compressed. But to access even 1kB file, whole squashfs block must be decompressed. I have no idea if system caches all decompressed data.

Theory is theory, in practice you can compare it here: http://www.squashfs-lzma.org/

Also think that sometimes even 1kB makes a diffrence, because of flash padding (binary images are padded to 64k). Example: if you have padding set to 64kB (default); it means 3584kB will take 56 blocks, and 3585kB image will take 57 blocks - it is 3648kB.

2.
Not really:
https://github.com/ericpaulbishop/gargo ... -tools%3Dy

----
I will build images and compare.

Lantis
Moderator
Posts: 6735
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: Out of space - my ideas

Post by Lantis »

Ok, thanks for explaining #1.

As far as #2, only ar71xx/default really has massive size issues. But you are correct that we don't rely on it anymore (except for madwifi cases)
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

m45t3r
Posts: 4
Joined: Thu Jan 08, 2015 6:44 pm

Re: Out of space - my ideas

Post by m45t3r »

I had a similar idea (didn't see this post before), and did a test if it would work here: https://github.com/ericpaulbishop/gargoyle/issues/524

So yeah, you can build a Gargoyle image removing debugging info, stripping kernel (I did not strip the libraries), re-include miniupnpd and add some plugins still fit it in a 4MB router, with an /overlay size of 512KB (Gargoyle 1.8.1 has an /overlay of 320KB).

I think a new target, like the suggested 4mb-nousb or something would be interesting to have in Gargoyle. Or maybe just a default target less "bloated", however possibly incompatible with OpenWRT itself (Gargoyle plugins would still be compatible if they're build with the same settings).

Post Reply