How to strip down my Yocto Linux?

江枫思渺然 提交于 2019-12-23 03:42:34

问题


I would like to strip down my Yocto Linux before put in it to flash. Unneeded software, man pages, POCO sample codes and other documentation just waste resource, especially on the i.MX28 EVK with only 128MB flash.

My local.conf file looks following:

$ gedit conf/local.conf &
...
IMAGE_INSTALL_append = " poco nginx canutils vsftpd curl fcgi spawn-fcgi net-snmp util-linux ubiattach-klibc ubimkvol-klibc ubiformat-klibc minicom net-tools zeroconf avahi-autoipd mtd-utils u-boot-fw-utils ethtool"
...

I bitbake the image "core-image-base".

I was wondering, is there a way that I can delete all of the Unneeded files?

Can somebody help me howto strip down my Yocto Linux?


回答1:


When you look into the recipe for core-image-base and the included core-image class (core-image-base.bb & core-image.bbclass) you will notice that there is only packagegroup-core-boot and packagegroup-base-extended in that image.

The description for those:

By default we install packagegroup-core-boot and packagegroup-base-extended packages; this gives us working (console only) rootfs.

This lets assume that it's not supposed to be removed and that so you can't remove much software/files on the 'Yocto-way'. What you can do is writing patches which are removing files manually or take a look in how to build a tiny system with Yocto (Link to Development Manual).

You can activate this distribution by changing the DISTRO Variable in your local.conf:

DISTRO = "poky-tiny"



回答2:


This is an example of a minimal console image: recipes-core/images/core-image-small.bb

DESCRIPTION = "Minimal console image."
IMAGE_INSTALL= "\
base-files \
base-passwd \
busybox \
sysvinit \
initscripts \
${ROOTFS_PKGMANAGE_BOOTSTRAP} \
${CORE_IMAGE_EXTRA_INSTALL} \
"
IMAGE_LINGUAS = " "
LICENSE = "MIT"
inherit core-image
IMAGE_ROOTFS_SIZE ?= "8192"

This recipe produces an image of about 6.4MB. If you use poky-tiny by add DISTRO = "poky-tiny" to your conf/local.conf the image will be around 4MB.

To build this, you will need to add INSANCE_SKIP_glibc-locale = "installed-vs-shipped"

You could also use PACKAGE_CLASSES ?= package_ipk package manager as it is the lightest and remove package-management feature from your production root file system altogether.

If you choose to have packagegroup-core-boot in your image, you could use BusyBox's mdev device manager instead of udev by specifying in your conf/local.conf

VIRTUAL-RUNTIME_dev_manager = "mdev"

If you are running root filesystem on a block device, use ext2 instead of ext3 or ext4 without the journal

Configure BusyBox with only the essential applets by providing your own configuration file in bbappend.

Review the glibc configuration, which can be changed via the DISTRO_FEATURES_LIBC distribution configuration variable. You can find the example in the poky-tiny distribution.

Consider switching to a ligher C library. Use uclibc or musl instead of the standard glibc http://www.etalabs.net/compare_libcs.html

to use musl, in local.conf

TCLIBC = "musl"

add meta-musl to conf/bblayers.conf



来源:https://stackoverflow.com/questions/45457102/how-to-strip-down-my-yocto-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!