Use lz4 compression for kernel and initramfs

Boots faster but adds ~5mb to kernel+initrd bundle
This commit is contained in:
Bruce Leidl 2018-03-21 09:38:49 -04:00
parent b34e434917
commit 95652721fc
3 changed files with 24 additions and 15 deletions

View File

@ -91,8 +91,6 @@ PACKAGE_INSTALL = "\
" "
SYSTEMD_DEFAULT_TARGET = "initrd.target" SYSTEMD_DEFAULT_TARGET = "initrd.target"
#IMAGE_FEATURES = ""
#IMAGE_FEATURES_append = " empty-root-password"
export IMAGE_BASENAME = "citadel-initramfs-image" export IMAGE_BASENAME = "citadel-initramfs-image"
IMAGE_LINGUAS = "" IMAGE_LINGUAS = ""
@ -100,6 +98,7 @@ LICENSE = "MIT"
INITRAMFS_MAXSIZE = "512000" INITRAMFS_MAXSIZE = "512000"
INITRAMFS_FSTYPES = "cpio.lz4"
IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}" IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
inherit core-image inherit core-image

View File

@ -28,6 +28,21 @@ do_deploy_append() {
ln -sf bzImage-initramfs${KERNEL_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/bzImage ln -sf bzImage-initramfs${KERNEL_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/bzImage
} }
#
# Replaces function with same name in kernel.bbclass since that implementation
# doesn't pass destination argument to lz4 in which case the decompressed output
# just disappears into thin air it seems.
#
copy_initramfs() {
echo "copy_initramfs override"
mkdir -p ${B}/usr
rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.cpio.lz4 ${B}/usr/.
lz4 -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio.lz4 ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
ls -al ${B}/usr
echo "Finished copy of initramfs into ./usr"
}
# Don't install kernel into images, see kernel.bbclass # Don't install kernel into images, see kernel.bbclass
RDEPENDS_${KERNEL_PACKAGE_NAME}-base = "" RDEPENDS_${KERNEL_PACKAGE_NAME}-base = ""
@ -37,7 +52,7 @@ RDEPENDS_${KERNEL_PACKAGE_NAME}-base = ""
# #
# coreutils for /usr/bin/seq which pax size overflow gcc plugin uses # coreutils for /usr/bin/seq which pax size overflow gcc plugin uses
DEPENDS += "openssl-native coreutils-native" DEPENDS += "openssl-native coreutils-native lz4-native"
HOST_EXTRACFLAGS += "-I${STAGING_INCDIR_NATIVE}" HOST_EXTRACFLAGS += "-I${STAGING_INCDIR_NATIVE}"
COMPATIBLE_MACHINE = "(intel-corei7-64)" COMPATIBLE_MACHINE = "(intel-corei7-64)"

View File

@ -65,9 +65,9 @@ CONFIG_HAVE_KERNEL_LZ4=y
# CONFIG_KERNEL_GZIP is not set # CONFIG_KERNEL_GZIP is not set
# CONFIG_KERNEL_BZIP2 is not set # CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set # CONFIG_KERNEL_LZMA is not set
CONFIG_KERNEL_XZ=y # CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set # CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set CONFIG_KERNEL_LZ4=y
CONFIG_DEFAULT_HOSTNAME="(none)" CONFIG_DEFAULT_HOSTNAME="(none)"
CONFIG_SWAP=y CONFIG_SWAP=y
CONFIG_SYSVIPC=y CONFIG_SYSVIPC=y
@ -188,11 +188,11 @@ CONFIG_SCHED_AUTOGROUP=y
CONFIG_RELAY=y CONFIG_RELAY=y
CONFIG_BLK_DEV_INITRD=y CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="" CONFIG_INITRAMFS_SOURCE=""
CONFIG_RD_GZIP=y # CONFIG_RD_GZIP is not set
CONFIG_RD_BZIP2=y # CONFIG_RD_BZIP2 is not set
CONFIG_RD_LZMA=y # CONFIG_RD_LZMA is not set
CONFIG_RD_XZ=y # CONFIG_RD_XZ is not set
CONFIG_RD_LZO=y # CONFIG_RD_LZO is not set
CONFIG_RD_LZ4=y CONFIG_RD_LZ4=y
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@ -5361,11 +5361,6 @@ CONFIG_XZ_DEC_ARMTHUMB=y
CONFIG_XZ_DEC_SPARC=y CONFIG_XZ_DEC_SPARC=y
CONFIG_XZ_DEC_BCJ=y CONFIG_XZ_DEC_BCJ=y
# CONFIG_XZ_DEC_TEST is not set # CONFIG_XZ_DEC_TEST is not set
CONFIG_DECOMPRESS_GZIP=y
CONFIG_DECOMPRESS_BZIP2=y
CONFIG_DECOMPRESS_LZMA=y
CONFIG_DECOMPRESS_XZ=y
CONFIG_DECOMPRESS_LZO=y
CONFIG_DECOMPRESS_LZ4=y CONFIG_DECOMPRESS_LZ4=y
CONFIG_GENERIC_ALLOCATOR=y CONFIG_GENERIC_ALLOCATOR=y
CONFIG_REED_SOLOMON=y CONFIG_REED_SOLOMON=y