OpenWRT final image size

Hi!

I don't know much about OpenWRT and its build system and the possible options, someone built this image at my job, he left, no documentation or anything, now that I must upgrade OpenWRT its the last point I'd like to address before releasing it if possible.

Was wondering about the size of the OpenWRT image I build. We have an old 18.05 image here that is compressed to 22MB, gunzip it, it is 35MB.
Now I updated OpenWRT to 23.05, its 40MB compressed (I added some packages), but gunzip it and its 16GB, how comes?
Anything I can do to reduce its size?

depends on what the image contains, doesn't it ?
but everything have grown over the last 5 years.

When flashed to a SSD and run on a PC Engines apu2, df returns 290MB used on 14.6G

df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                24.3M     24.3M         0 100% /rom
tmpfs                     1.9G      2.2M      1.9G   0% /tmp
/dev/loop0               14.6G    290.9M     14.3G   2% /overlay
overlayfs:/overlay       14.6G    290.9M     14.3G   2% /
/dev/sda1                15.7M      6.8M      8.6M  44% /boot
/dev/sda1                15.7M      6.8M      8.6M  44% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

ubus call system board
opkg list-installed

In general kmod packages need to be in /overlay , shared libraries and resident services preferably, but rest you can drop in an usb drive.

ubus
{
	"kernel": "6.6.54",
	"hostname": "router-undef",
	"system": "AMD GX-412TC SOC",
	"model": "PC Engines apu2",
	"board_name": "pc-engines-apu2",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "SNAPSHOT",
		"revision": "r27715-5281033831",
		"target": "x86/64",
		"description": "OpenWrt SNAPSHOT r27715-5281033831"
	}
}
opkg
ath10k-board-qca988x - 20240909-r1
ath10k-firmware-qca988x - 20240909-r1
base-files - 1625~5281033831
bash - 5.2.32-r1
beep - 1.4.12-r6
block-mount - 2024.07.14~408c2cc4-r1
blockd - 2024.07.14~408c2cc4-r1
bnx2-firmware - 20240909-r1
busybox - 1.36.1-r2
ca-bundle - 20240203-r1
cgi-io - 2022.08.10~901b0f04-r21
collectd - 5.12.0-r53
collectd-mod-cpu - 5.12.0-r53
collectd-mod-interface - 5.12.0-r53
collectd-mod-iwinfo - 5.12.0-r53
collectd-mod-load - 5.12.0-r53
collectd-mod-memory - 5.12.0-r53
collectd-mod-network - 5.12.0-r53
collectd-mod-rrdtool - 5.12.0-r53
coreutils - 9.3-r1
coreutils-nohup - 9.3-r1
coreutils-stty - 9.3-r1
curl - 8.10.1-r1
dbus - 1.14.10-r1
dmidecode - 3.5-r1
dnsmasq - 2.90-r3
dropbear - 2024.85-r1
e2fsprogs - 1.47.0-r2
etherwake - 1.09-r5
firewall4 - 2024.05.21~4c01d1eb-r1
flashrom - 1.3.0-r2
fstools - 2024.07.14~408c2cc4-r1
fstrim - 2.40.2-r1
fwtool - 2019.11.12~8f7fe925-r1
getrandom - 2024.04.26~85f10530-r1
glib2 - 2.82.0-r1
grub2 - 2.12-r1
grub2-bios-setup - 2.12-r1
grub2-efi - 2.12-r1
hostapd-common - 2024.09.15~5ace39b0-r1
htop - 3.3.0-r2
ip-tiny - 6.11.0-r1
ip6tables-nft - 1.8.8-r2
ipset - 7.21-r1
iptables-mod-conntrack-extra - 1.8.8-r2
iptables-mod-ipopt - 1.8.8-r2
iptables-nft - 1.8.8-r2
irqbalance - 1.9.4-r1
iw - 6.9-r1
iwinfo - 2024.10.01~714e4199-r1
jansson4 - 2.14-r3
jq - 1.7.1-r1
jshn - 2024.03.29~eb9bcb64-r1
jsonfilter - 2024.01.23~594cfa86-r1
kernel - 6.6.54~d2ace56458d79ac4205269175df50679-r1
kmod-amazon-ena - 6.6.54-r1
kmod-amd-xgbe - 6.6.54-r1
kmod-asn1-decoder - 6.6.54-r1
kmod-ath - 6.6.54.6.11.2-r1
kmod-ath10k - 6.6.54.6.11.2-r1
kmod-bnx2 - 6.6.54-r1
kmod-button-hotplug - 6.6.54-r3
kmod-cfg80211 - 6.6.54.6.11.2-r1
kmod-crypto-aead - 6.6.54-r1
kmod-crypto-authenc - 6.6.54-r1
kmod-crypto-ccm - 6.6.54-r1
kmod-crypto-cmac - 6.6.54-r1
kmod-crypto-crc32c - 6.6.54-r1
kmod-crypto-ctr - 6.6.54-r1
kmod-crypto-gcm - 6.6.54-r1
kmod-crypto-geniv - 6.6.54-r1
kmod-crypto-gf128 - 6.6.54-r1
kmod-crypto-ghash - 6.6.54-r1
kmod-crypto-hash - 6.6.54-r1
kmod-crypto-hmac - 6.6.54-r1
kmod-crypto-hw-ccp - 6.6.54-r1
kmod-crypto-manager - 6.6.54-r1
kmod-crypto-null - 6.6.54-r1
kmod-crypto-rng - 6.6.54-r1
kmod-crypto-rsa - 6.6.54-r1
kmod-crypto-seqiv - 6.6.54-r1
kmod-crypto-sha1 - 6.6.54-r1
kmod-crypto-sha256 - 6.6.54-r1
kmod-crypto-sha3 - 6.6.54-r1
kmod-crypto-sha512 - 6.6.54-r1
kmod-cryptodev - 6.6.54.1.13-r1
kmod-dwmac-intel - 6.6.54-r1
kmod-e1000 - 6.6.54-r1
kmod-e1000e - 6.6.54-r1
kmod-forcedeth - 6.6.54-r1
kmod-fs-autofs4 - 6.6.54-r1
kmod-fs-vfat - 6.6.54-r1
kmod-gpio-amd-fch - 6.6.54-r1
kmod-gpio-button-hotplug - 6.6.54-r5
kmod-gpio-nct5104d - 6.6.54-r1
kmod-hwmon-core - 6.6.54-r1
kmod-i2c-algo-bit - 6.6.54-r1
kmod-i2c-core - 6.6.54-r1
kmod-igb - 6.6.54-r1
kmod-igc - 6.6.54-r1
kmod-input-core - 6.6.54-r1
kmod-ip6tables - 6.6.54-r1
kmod-ipt-conntrack - 6.6.54-r1
kmod-ipt-conntrack-extra - 6.6.54-r1
kmod-ipt-core - 6.6.54-r1
kmod-ipt-ipopt - 6.6.54-r1
kmod-ipt-ipset - 6.6.54-r1
kmod-ixgbe - 6.6.54-r1
kmod-leds-gpio - 6.6.54-r1
kmod-lib-crc-ccitt - 6.6.54-r1
kmod-lib-crc32c - 6.6.54-r1
kmod-libphy - 6.6.54-r1
kmod-mac80211 - 6.6.54.6.11.2-r1
kmod-mdio - 6.6.54-r1
kmod-mdio-devres - 6.6.54-r1
kmod-mii - 6.6.54-r1
kmod-nf-conncount - 6.6.54-r1
kmod-nf-conntrack - 6.6.54-r1
kmod-nf-conntrack6 - 6.6.54-r1
kmod-nf-flow - 6.6.54-r1
kmod-nf-ipt - 6.6.54-r1
kmod-nf-ipt6 - 6.6.54-r1
kmod-nf-log - 6.6.54-r1
kmod-nf-log6 - 6.6.54-r1
kmod-nf-nat - 6.6.54-r1
kmod-nf-reject - 6.6.54-r1
kmod-nf-reject6 - 6.6.54-r1
kmod-nfnetlink - 6.6.54-r1
kmod-nft-compat - 6.6.54-r1
kmod-nft-core - 6.6.54-r1
kmod-nft-fib - 6.6.54-r1
kmod-nft-nat - 6.6.54-r1
kmod-nft-offload - 6.6.54-r1
kmod-nls-base - 6.6.54-r1
kmod-nls-cp437 - 6.6.54-r1
kmod-nls-iso8859-1 - 6.6.54-r1
kmod-nls-utf8 - 6.6.54-r1
kmod-pcengines-apuv2 - 6.6.54-r1
kmod-pcs-xpcs - 6.6.54-r1
kmod-pcspkr - 6.6.54-r1
kmod-phy-realtek - 6.6.54-r1
kmod-phylink - 6.6.54-r1
kmod-ppp - 6.6.54-r1
kmod-pppoe - 6.6.54-r1
kmod-pppox - 6.6.54-r1
kmod-pps - 6.6.54-r1
kmod-ptp - 6.6.54-r1
kmod-r8169 - 6.6.54-r1
kmod-random-core - 6.6.54-r1
kmod-sched-core - 6.6.54-r1
kmod-slhc - 6.6.54-r1
kmod-sound-core - 6.6.54-r1
kmod-sp5100-tco - 6.6.54-r1
kmod-stmmac-core - 6.6.54-r1
kmod-tg3 - 6.6.54-r1
kmod-tun - 6.6.54-r1
kmod-usb-core - 6.6.54-r1
kmod-usb-ehci - 6.6.54-r1
kmod-usb-net - 6.6.54-r1
kmod-usb-net-cdc-ether - 6.6.54-r1
kmod-usb-net-cdc-mbim - 6.6.54-r1
kmod-usb-net-cdc-ncm - 6.6.54-r1
kmod-usb-net-qmi-wwan - 6.6.54-r1
kmod-usb-ohci - 6.6.54-r1
kmod-usb-serial - 6.6.54-r1
kmod-usb-serial-option - 6.6.54-r1
kmod-usb-serial-wwan - 6.6.54-r1
kmod-usb-wdm - 6.6.54-r1
kmod-usb-xhci-hcd - 6.6.54-r1
kmod-usb2 - 6.6.54-r1
kmod-usb3 - 6.6.54-r1
libatomic1 - 13.3.0-r4
libattr - 2.5.2-r3
libblkid1 - 2.40.2-r1
libblobmsg-json20240329 - 2024.03.29~eb9bcb64-r1
libbpf1 - 1.4.5-r1
libbz2-1.0 - 1.0.8-r1
libc - 1.2.5-r4
libcap-ng - 0.8.4-r1
libcomerr0 - 1.47.0-r2
libcurl4 - 8.10.1-r1
libdbus - 1.14.10-r1
libe2p2 - 1.47.0-r2
libelf1 - 0.191-r1
libevent2-core7 - 2.1.12-r2
libexpat - 2.6.3-r1
libext2fs2 - 1.47.0-r2
libf2fs6 - 1.16.0-r3
libffi - 3.4.6-r1
libftdi1 - 1.5-r2
libgcc1 - 13.3.0-r4
libgdbm - 1.23-r1
libgmp10 - 6.3.0-r1
libgnutls - 3.8.5-r1
libipset13 - 7.21-r1
libiptext-nft0 - 1.8.8-r2
libiptext0 - 1.8.8-r2
libiptext6-0 - 1.8.8-r2
libiwinfo-data - 2024.10.01~714e4199-r1
libiwinfo20230701 - 2024.10.01~714e4199-r1
libjson-c5 - 0.18-r1
libjson-script20240329 - 2024.03.29~eb9bcb64-r1
libkmod - 32-r1
libltdl7 - 2.4.7-r1
liblua5.1.5 - 5.1.5-r11
liblucihttp-lua - 2023.03.15~9b5b683f-r1
liblucihttp-ucode - 2023.03.15~9b5b683f-r1
liblucihttp0 - 2023.03.15~9b5b683f-r1
liblz4-1 - 1.10.0-r1
liblzma - 5.6.2-r2
liblzo2 - 2.10-r4
libmbedtls21 - 3.6.1-r1
libmbim - 1.30.0-r2
libmnl0 - 1.0.5-r1
libmount1 - 2.40.2-r1
libncurses6 - 6.4-r2
libnettle8 - 3.9.1-r1
libnftnl11 - 1.2.6-r1
libnghttp2-14 - 1.63.0-r1
libnl-tiny1 - 2023.12.05~965c4bf4-r1
libopenssl3 - 3.0.15-r1
libpcap1 - 1.10.5-r1
libpci - 3.12.0-r2
libpcre2 - 10.42-r1
libpq - 15.6-r1
libpthread - 1.2.5-r4
libpython3-3.11 - 3.11.7-r2
libqmi - 1.34.0-r2
libqrtr-glib - 1.2.2-r3
libreadline8 - 8.2-r2
librrd1 - 1.0.50-r6
librt - 1.2.5-r4
libsensors5 - 3.6.0-r1
libsmartcols1 - 2.40.2-r1
libsqlite3-0 - 3460100-r1
libss2 - 1.47.0-r2
libsysfs2 - 2.1.0-r4
libubox20240329 - 2024.03.29~eb9bcb64-r1
libubus-lua - 2023.11.28~f84eb599-r1
libubus20231128 - 2023.11.28~f84eb599-r1
libuci20130104 - 2023.08.10~5781664d-r1
libuclient20201210 - 2024.04.19~e8780fa7-r1
libucode20230711 - 2024.07.22~b610860d-r3
libudebug - 2023.12.06~6d3f51f9
libusb-1.0-0 - 1.0.27-r1
libustream-mbedtls20201210 - 2024.07.28~99bd3d2b-r1
libuuid1 - 2.40.2-r1
libxtables12 - 1.8.8-r2
lm-sensors - 3.6.0-r1
logd - 2024.04.26~85f10530-r1
lua - 5.1.5-r11
luci - 24.285.49534~84e24c0
luci-app-firewall - 24.285.49534~84e24c0
luci-app-openvpn - 24.285.49534~84e24c0
luci-app-opkg - 24.285.49534~84e24c0
luci-app-statistics - 24.285.49534~84e24c0
luci-base - 24.285.49534~84e24c0
luci-compat - 24.285.49534~84e24c0
luci-lib-base - 24.285.49534~84e24c0
luci-lib-ip - 24.285.49534~84e24c0
luci-lib-jsonc - 24.285.49534~84e24c0
luci-lib-nixio - 24.285.49534~84e24c0
luci-light - 24.285.49534~84e24c0
luci-lua-runtime - 24.285.49534~84e24c0
luci-mod-admin-full - 24.285.49534~84e24c0
luci-mod-network - 24.285.49534~84e24c0
luci-mod-status - 24.285.49534~84e24c0
luci-mod-system - 24.285.49534~84e24c0
luci-proto-ipv6 - 24.285.49534~84e24c0
luci-proto-modemmanager - 24.285.49534~84e24c0
luci-proto-ppp - 24.285.49534~84e24c0
luci-ssl - 24.285.49534~84e24c0
luci-theme-bootstrap - 24.285.49534~84e24c0
mkf2fs - 1.16.0-r3
modemmanager - 1.22.0-r18
mtd - 26
nano - 8.2-r1
netifd - 2024.09.21~24f9a93a-r1
nftables-json - 1.0.9-r1
odhcp6c - 2023.05.12~bcd28363-r20
odhcpd-ipv6only - 2024.05.08~a2988231-r1
openssh-sftp-server - 9.9_p1-r1
openvpn-openssl - 2.6.12-r1
openwrt-keyring - 2022.03.25~62471e69-r2
opkg - 2022.02.24~d038e5b6-r2
partx-utils - 2.40.2-r1
pciids - 0.387-r1
pciutils - 3.12.0-r2
picocom - 3.1-r5
ppp - 2.4.9_git20210104-r6
ppp-mod-pppoe - 2.4.9_git20210104-r6
procd - 2024.07.07~f230c117-r1
procd-seccomp - 2024.07.07~f230c117-r1
procd-ujail - 2024.07.07~f230c117-r1
px5g-mbedtls - 11
python3 - 3.11.7-r2
python3-asyncio - 3.11.7-r2
python3-base - 3.11.7-r2
python3-cgi - 3.11.7-r2
python3-cgitb - 3.11.7-r2
python3-codecs - 3.11.7-r2
python3-ctypes - 3.11.7-r2
python3-dbm - 3.11.7-r2
python3-decimal - 3.11.7-r2
python3-distutils - 3.11.7-r2
python3-email - 3.11.7-r2
python3-light - 3.11.7-r2
python3-logging - 3.11.7-r2
python3-lzma - 3.11.7-r2
python3-multiprocessing - 3.11.7-r2
python3-ncurses - 3.11.7-r2
python3-openssl - 3.11.7-r2
python3-pydoc - 3.11.7-r2
python3-readline - 3.11.7-r2
python3-sqlite3 - 3.11.7-r2
python3-uci - 0.10.0-r1
python3-unittest - 3.11.7-r2
python3-urllib - 3.11.7-r2
python3-uuid - 3.11.7-r2
python3-xml - 3.11.7-r2
r8169-firmware - 20240909-r1
rpcd - 2024.09.17~9f4b86e7-r1
rpcd-mod-file - 2024.09.17~9f4b86e7-r1
rpcd-mod-iwinfo - 2024.09.17~9f4b86e7-r1
rpcd-mod-luci - 20240305-r1
rpcd-mod-rpcsys - 2024.09.17~9f4b86e7-r1
rpcd-mod-rrdns - 20170710
rpcd-mod-ucode - 2024.09.17~9f4b86e7-r1
rrdtool1 - 1.0.50-r6
screen - 4.9.1-r2
shadow-common - 4.8.1-r3
shadow-groupadd - 4.8.1-r3
shadow-groupdel - 4.8.1-r3
shadow-groupmod - 4.8.1-r3
shadow-useradd - 4.8.1-r3
shadow-userdel - 4.8.1-r3
shadow-usermod - 4.8.1-r3
socat - 1.8.0.0-r2
sudo - 1.9.15_p5-r1
sysfsutils - 2.1.0-r4
tc-bpf - 6.11.0-r1
tcpdump - 4.99.5-r1
terminfo - 6.4-r2
tmux - 3.5a-r1
ubox - 2024.04.26~85f10530-r1
ubus - 2023.11.28~f84eb599-r1
ubusd - 2023.11.28~f84eb599-r1
uci - 2023.08.10~5781664d-r1
uclient-fetch - 2024.04.19~e8780fa7-r1
ucode - 2024.07.22~b610860d-r3
ucode-mod-fs - 2024.07.22~b610860d-r3
ucode-mod-html - 1
ucode-mod-lua - 1
ucode-mod-math - 2024.07.22~b610860d-r3
ucode-mod-nl80211 - 2024.07.22~b610860d-r3
ucode-mod-rtnl - 2024.07.22~b610860d-r3
ucode-mod-ubus - 2024.07.22~b610860d-r3
ucode-mod-uci - 2024.07.22~b610860d-r3
ucode-mod-uloop - 2024.07.22~b610860d-r3
uhttpd - 2023.06.25~34a8a74d-r4
uhttpd-mod-ubus - 2023.06.25~34a8a74d-r4
umbim - 2022.08.13~146bc77c-r25
uqmi - 2024.08.25~28b48a10-r2
urandom-seed - 3
urngd - 2023.11.01~44365eb1-r1
usb-modeswitch - 2022.02.24~3c8595a4-r1
usign - 2020.05.23~f1f65026-r1
vim - 9.0-r1
wifi-scripts - 1.0-r1
wireless-regdb - 2024.07.04-r1
wpad - 2024.09.15~5ace39b0-r1
wwan - 2019.04.29-r6
xtables-nft - 1.8.8-r2
zlib - 1.3.1-r1

there was a thread recently where someone compared recent versions, and some lib (?) made the image grow a lot.
I'm out the door, and can't find it atm, but it could be related.

but if you have 14GB disk, I don't really see the problem.

Its not really a problem, its more a question I'm asking because the OpenWRT 18.05 image size is 22MB and when I gunzip it its 40MB big, but when doing the same thing on OpenWRT 23.05, the image size is 40MB but when I gunzip it its 16GB.

I believe it has something to do with the CONFIG_TARGET_ROOTFS_PARTSIZE=15000 configuration.
I believe it also affects the image creation, OpenWRT build phase is using dd with a block size of 16GB:

0+1 records in
1+0 records out
15728640000 bytes (16 GB, 15 GiB) copied, 35.0909 s, 448 MB/s

So I need 16GB of free RAM to build this image, I find it weird?

You have

  • python
  • collectd
  • shadow & coreutils replacing busybox applets
  • openvpn

if you do not use those get them each out for 1-2mb reclaimed.

Could simply be bad gunzip params...?

1 Like

We are using python, shadow, coreutils and openvpn for our iot stuff. collectd is not included in our "release" image. But thanks for the heads up. I'm not too concerned about how much space it takes on the router but more about the image size once uncompressed.

What do you mean bad gunzip params? I am using the image openwrt-x86-64-generic-squashfs-rootfs.img.gz, gunzip only uncompress files, it will not change the original file size.

ls -lh
total 15G
-rw-r--r-- 1 buildbot buildbot 15G oct.  14 17:18 openwrt.img
-rw-r--r-- 1 buildbot buildbot 46M oct.  14 17:18 openwrt.img.gz

If I run the Android sparse image tool img2simg on openwrt.img, its even tinier than the compressed file:

-rw-rw-r-- 1 buildbot buildbot 32M oct.  15 08:58 openwrt.sparse.img

the increase in size seems about right, it you follow the size increases of openwrt (and the linux kernel) ... definitley not alarming.

this is related to the size if the entire image including reserved free space ...meaning you have 15gb+ of free space reserved for memory and less than 40mb are openwrt. You can adjust this if you have something else to do with the abundance of free space. However, nothing you have provided comes as unusual or alarming

Ok, any reason on why this changed compared to OpenWRT 18.05?
My sysupgrade now takes over 400 seconds where it only takes 80 seconds on the old image.

18.05 is ancient in terms of openwrt . Everything has gotten bigger since then. 18.05 supported 4mb devices ... beyond very basic config, 4mb dvices can no longer be supported. If i recall, 8mb devices can no longer be supported ..and 16mb is barely enough for a decent openwrt setup with luci and all. Not sure about the extra flash time. That would take some looking into, but I am pretty certain it has to do with build configuration, nothing with openwrt

Thank you for your answer.

I have a 16GB SSD on my router, so making very tiny images is not really my goal, my issue is that the image built with OpenWRT 18.05 is 22MB compressed and only 35MB uncompressed. With still the partition size set to 15000.

This is my old image:

-rw-rw-r-- 1 buildbot buildbot  35M Oct 14 15:37 openwrt-2021-03-10-11-00-12.img
-rw-rw-r-- 1 buildbot buildbot  22M Oct 14 15:37 openwrt-2021-03-10-11-00-12.img.gz

losetup loop999 openwrt-2021-03-10-11-00-12.img

fdisk /dev/loop999

Disk /dev/loop999: 34.98 MiB, 36683264 bytes, 71647 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2d20a05d

Device         Boot Start      End  Sectors  Size Id Type
/dev/loop999p1 *      512    33279    32768   16M 83 Linux
/dev/loop999p2      33792 30753791 30720000 14.6G 83 Linux

The new image:

-rw-r--r-- 1 buildbot   buildbot   15G oct.  15 13:13 openwrt.img
-rw-r--r-- 1 buildbot   buildbot   46M oct.  15 13:13 openwrt.img.gz

losetup loop999 openwrt.img

fdisk /dev/loop999

Disk /dev/loop999: 14.66 GiB, 15745941504 bytes, 30753792 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x05bd2c8b

Device         Boot Start      End  Sectors  Size Id Type
/dev/loop999p1 *      512    33279    32768   16M 83 Linux
/dev/loop999p2      33792 30753791 30720000 14.6G 83 Linux

If its an issue with my build system or build options, I'm open to any suggestion. It's more of an optimization issue more than an usability. If the image cannot be shrunk like the old image, then too bad for me, we'll have to wait longer when flashing the upgrade.

I believe sysupgrade is significantly longer because it needs to uncompress the image, and the new one is 15GB instead of 30MB.

I made a script that analyses the empty blocks, trim the image to the size of empty blocks + some extra zeroed blocks, the new image is 59MB big and flash only took a few seconds. Guess I don't have anything better for now.

I commented this function in include/image.mk:

define Image/pad-to
        @echo "TESTING THIS MARKER $(1) $(2)"
        # dd if=$(1) of=$(1).new bs=$(2) conv=sync
        # mv $(1).new $(1)
endef

That way, I don't have my not enought memory error I sometimes happen to have, because that thing just write 1 big block of data, unfortunatly, it writes 1 block with a size of the whole image:
dd if=/workdir/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-rootfs.img.gz of=/workdir/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-rootfs.img.gz.new bs=15728640000 conv=sync

Maybe I should open an issue for that, I believe it is not expected to required your whole ram to just pad an image.

Do you need this root partition size anymore? You specify the size, but don’t like the result? It’s confusing. Image building changed a lot in 6 years, of course.

Padding commit for x86:

2 Likes

Do I need it? Honestly, I'd say no, but I'm not able to decide to reduce it at my job currently.

I/We were just really surprised by the impact on the size of the final image when we upgraded to the latest OpenWRT.

Thanks for that. Would you happen to know how OpenWRT decides the offset of the overlayfs in the ROOT partition?

losetup
NAME       SIZELIMIT   OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
/dev/loop0         0 25296896         1  0 /sda2       0     512

The 25296896 value. I'm computing my own image size with this formulae:

start_of_sda2 (in sectors) = 33792
offset_of_overlayfs (in bytes) = 25296896

Smallest possible image size = 33792 + (25296896 / 512) = 83200 sectors of 512 bytes.
dd if=openwrt.img of=small_openwrt.img bs=512 count=83200

Thats my smallest image size. Then I need to zero a bit more so the old overlayfs headers is cleaned.

Currently, that a pure proof-of-concept. I might just end up writing the whole 15GB image, its easier that way, but way longer.