Skip to content

Commit 15cf9b0

Browse files
authored
Reduce image size for lazy installation packages (sonic-net#10775)
Why I did it The image size is too large, when there are multiple lazy packages and multiple platforms. It is not necessary to keep the lazy installation packages in multiple copies. For cisco image, the image size will reduce from 3.5G to 1.7G. How I did it Use symbol links to only keep one package for each of the lazy package. Make a new folder fsroot/platform/common Copy the lazy packages into the folder. When using a package in each of the platform, such as x86_64-grub, x86_64-8800_rp-r0, x86_64-8201_on-r0, etc, only make a symbol link to the package in the common folder.
1 parent 0e30ffe commit 15cf9b0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

build_debian.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -643,5 +643,5 @@ fi
643643
pushd $FILESYSTEM_ROOT && sudo tar czf $OLDPWD/$FILESYSTEM_DOCKERFS -C ${DOCKERFS_PATH}var/lib/docker .; popd
644644

645645
## Compress together with /boot, /var/lib/docker and $PLATFORM_DIR as an installer payload zip file
646-
pushd $FILESYSTEM_ROOT && sudo zip $OLDPWD/$ONIE_INSTALLER_PAYLOAD -r boot/ $PLATFORM_DIR/; popd
646+
pushd $FILESYSTEM_ROOT && sudo zip --symlinks $OLDPWD/$ONIE_INSTALLER_PAYLOAD -r boot/ $PLATFORM_DIR/; popd
647647
sudo zip -g -n .squashfs:.gz $ONIE_INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS $FILESYSTEM_DOCKERFS

files/build_templates/sonic_debian_extension.j2

+3-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,9 @@ sudo LANG=C chroot $FILESYSTEM_ROOT depmod -a {{kversion}}
610610
sudo dpkg --root=$FILESYSTEM_ROOT -i {{deb}} || sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f --download-only
611611

612612
sudo mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}
613-
sudo cp {{ deb }} $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/
613+
sudo mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/common
614+
sudo cp {{ deb }} $FILESYSTEM_ROOT/$PLATFORM_DIR/common/
615+
sudo ln -sf "../common/{{ debfilename }}" "$FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/{{ debfilename }}"
614616
for f in $(find $FILESYSTEM_ROOT/var/cache/apt/archives -name "*.deb"); do
615617
sudo mv $f $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/
616618
done

0 commit comments

Comments
 (0)