sonic-buildimage/files/initramfs-tools
Samuel Angebault feb8671601
[202205] Implement zram compression for docker in RAM (#15137)
* [Arista] Fix boot0 code for docker_inram

Enable docker_inram for all systems with 4GB or less of flash.
This is mandatory to allow these systems to store 2 SONiC images.

This change also fixes the missing docker_inram attribute when
installing a new image from SONiC.
Because the SWI image can ship with additional kernel parameters within
such as `sonic_fips=` this lead to a conflict.
To prevent the conflict, the extra kernel parameters from the SWI are
now stored in the file `kernel-cmdline-append` which isn't used anywhere.

* Add optional zram compression for docker_inram

Some devices running SONiC have a small storage device (2G and 4G mainly)
The SONiC image growth over time has made it impossible to install
2 images on a single device.
Some mitigations have been implemented in the past for some devices but
there is a need to do more.

One such mitigation is `docker_inram` which creates a `tmpfs` and
extracts `dockerfs.tar.gz` in it.
This all happens in the SONiC initramfs and by ensuring the installation
process does not extract `dockerfs.tar.gz` on the flash but keep the file as is.

This mitigation does a tradeoff by using more RAM to reduce the disk footprint.
It however creates new issues for devices with 4G of system memory since
the extracted `dockerfs.tar.gz` nears the 1.6G.
Considering debian upgrades (with dual base images) and the continuous
stream of features this is only going to get bigger.

This change introduces an alternative to the `tmpfs` by allowing a system
to extract the `dockerfs.tar.gz` inside a `zram` device thus bringing
compression in play at the detriment of performance.

Introduce 2 new optional kernel parameters to be consumed by SONiC initramfs.
 - `docker_inram_size` which represent the max physical size of the
   `zram` or `tmpfs` volume (defaults to DOCKER_RAMFS_SIZE)
 - `docker_inram_algo` which is the method to use to extract the
   `dockerfs.tar.gz` (defaults to `tmpfs`)
   other values are considered to be compression algorithm for `zram`
   (e.g `zstd`, `zlo-rle`, `lz4`)

Refactored the logic to mount the docker fs in the SONiC initramfs under
the `union-mount` script.
Moved the code into a function to make it cleaner and separated the
inram volume creation and docker extraction.

On Arista platform with a flash smaller or equal to 4GB set
`docker_inram_algo` to `zstd` which produces the best compression ratio
at the detriment of a slower write performance and a similar read
performance to other `zram` compression algorithms.
2023-06-02 08:36:18 -07:00
..
arista-convertfs.j2 [202205][Arista] Add initial support for 720DT-48S (#10656) (#11860) 2022-08-30 12:39:26 +08:00
arista-hook [kdump] Fix OOM events in crashkernel (#6447) 2021-02-02 01:55:09 -08:00
arista-net [Arista] Fix arista-net initramfs hook (#10624) 2022-04-20 10:03:05 -07:00
fsck-rootfs [baseimage]: Run fsck filesystem check support prior mounting filesystem (#4431) 2020-04-30 00:33:20 -07:00
mke2fs Run tune2fs during initramfs instead of image install (#10536) 2022-04-12 16:24:13 -07:00
modules [202205] Implement zram compression for docker in RAM (#15137) 2023-06-02 08:36:18 -07:00
modules.arm [platform][marvell] Arm 32-bit Arch support changes (#5749) 2020-12-03 12:38:50 -08:00
resize-rootfs Reduce SONiC migration partition from 8G to 1G. (#1343) 2018-02-07 22:07:01 +08:00
setfacl [aboot]: Add setfacl in the initramfs (#1185) 2017-11-24 17:30:11 -08:00
ssd-upgrade [initramfs]: SSD firmware upgrade in initramfs (#10748) 2022-05-12 08:11:02 -07:00
uboot-utils [initramfs] Updated required tools for initramfs (#3734) 2020-01-15 08:25:01 -08:00
udev.patch [baseimage]: build root filesystem via overlay fs instead of aufs 2018-08-11 09:07:59 +00:00
union-fsck New release v1.0.0 2016-03-08 11:42:20 -08:00
union-mount.j2 [202205] Implement zram compression for docker in RAM (#15137) 2023-06-02 08:36:18 -07:00
varlog Image disk space reduction (#10172) 2022-03-15 18:12:49 -07:00