From 336ef68d0d5eae781b688197690e54bbf8988515 Mon Sep 17 00:00:00 2001 From: Sonic Build Admin Date: Tue, 11 Mar 2025 23:44:57 +0000 Subject: [PATCH] Use pzstd to compress the Docker in SWI slim images #### Why I did it Same with https://github.com/sonic-net/sonic-buildimage/pull/21824 Enabled the docker inram feature for slim image. It would extract the docker image to ram during the boot, so it would take extra times during boot. ##### Work item tracking - Microsoft ADO **(number only)**: 31323281 #### How I did it Use pzstd which is more efficient tool to compress and decompress the docker file to reduce the boot time. Currently, we do not modify the "FILESYSTEM_DOCKERFS=dockerfs.tar.gz" in onie-image.conf, so for slim image, we still use dockerfs.tar.gz as file name but actually with zstd compressed. We tried to find out a way to adjust the file name in onie-image.conf, but it seems not easy to do that. So we use the file cmd to determine the compressing type in union-mount.j2, then use the related cmd to extract the docker file. Plan to support zstd for all types of images in the future to unify the docker file image . #### How to verify it Boot swi slim image and normal image, boot mellanox bin image, all boot successfully. #### Which release branch to backport (provide reason below if selected) - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [ ] 202205 - [ ] 202211 - [ ] 202305 #### Tested branch (Please provide the tested image version) - [ ] - [ ] #### Description for the changelog #### Link to config_db schema for YANG module changes #### A picture of a cute animal (not mandatory but encouraged) --- build_debian.sh | 12 +++++++++++- files/dsc/install_debian.j2 | 4 ++++ files/initramfs-tools/file | 18 ++++++++++++++++++ files/initramfs-tools/pzstd | 16 ++++++++++++++++ files/initramfs-tools/union-mount.j2 | 12 +++++++++--- 5 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 files/initramfs-tools/file create mode 100644 files/initramfs-tools/pzstd diff --git a/build_debian.sh b/build_debian.sh index 7fe04902fb2..764fef95520 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -391,6 +391,12 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in zstd \ nvme-cli +sudo cp files/initramfs-tools/pzstd $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/pzstd +sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/pzstd + +sudo cp files/initramfs-tools/file $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/file +sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/file + # Have systemd create the auditd log directory sudo mkdir -p ${FILESYSTEM_ROOT}/etc/systemd/system/auditd.service.d sudo tee ${FILESYSTEM_ROOT}/etc/systemd/system/auditd.service.d/log-directory.conf >/dev/null <