ILD

内核编译zImage过大问题
作者:Yuan Jianpeng 邮箱:yuanjp89@163.com
发布时间:2022-5-12 站点:Inside Linux Development

发现是开启了gzip压缩,没有开启xz压缩导致。gzip压缩,zImage是5M多。开启xz, zImage是3M多。

在另外一个机型上,zImage是2兆多。


将两个机型都打开debug info。这样好比较.o的大小

Compile the kernel with debug info

configname: CONFIG_DEBUG_INFO

Linux Kernel Configuration

└─> Kernel hacking

└─> Compile-time checks and compiler options

└─> Compile the kernel with debug info


进入linux build目录。统计各个目录的.o的大小:



ipq5018 32位内核:

$ for d in */ ; do echo -ne "$d\t"; find $d -name "*.o" -exec du -ch {} + | grep total; done         

                                                                                            
arch/   5.7M    total
block/  1.9M    total
certs/  32K     total
crypto/ 2.8M    total
drivers/        19M     total
fs/     21M     total
include/        init/   252K    total
ipc/    416K    total
kernel/ 13M     total
lib/    4.4M    total
mm/     5.2M    total
net/    34M     total
scripts/        700K    total
security/       540K    total
sound/  source/ usr/    4.0K    total


在ipq4018内核

arch/   4.4M    total
block/  2.0M    total
certs/  4.0K    total
crypto/ 1.9M    total
drivers/        19M     total
firmware/       4.0K    total
fs/     7.9M    total
include/        init/   332K    total
ipc/    452K    total
kernel/ 8.5M    total
lib/    3.4M    total
mm/     4.4M    total
net/    25M     total
scripts/        640K    total
security/       84K     total
sound/  4.0K    total
source/ usr/    8.0K    total
virt/   8.0K    total

发现fs显著大很多。原来是很多选项是默认的。没有优化。关闭没用的fs之后,fs的达标变成8.8M。zImage的大小变成2.8M。其它选项类似。


Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.