Skip to content

Commit c5024da

Browse files
committed
build: introduce check for initramfs size > 900Mb and warn/notice
- those will most likely fail to boot on 2Gb RAM machines - initramfs will by default use tmpfs (which defaults to 50% ram), not ramfs Signed-off-by: Ricardo Pardini <[email protected]>
1 parent ec275d4 commit c5024da

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bash/linuxkit.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ function linuxkit_build() {
9898
log info "Building Hook with kernel ${inventory_id} using linuxkit: ${lk_args[*]}"
9999
"${linuxkit_bin}" build "--format" "kernel+initrd" "${lk_args[@]}"
100100

101+
declare initramfs_path="${lk_output_dir}/hook-initrd.img"
102+
# initramfs_path is a gzipped file. obtain the uncompressed byte size, without decompressing it
103+
declare -i initramfs_size_bytes=0
104+
initramfs_size_bytes=$(gzip -l "${initramfs_path}" | tail -n 1 | awk '{print $2}')
105+
log info "Uncompressed initramfs size in bytes: ${initramfs_size_bytes}"
106+
# If the size is larger than 900mb, it is unlikely to boot on a 2gb RAM machine. Warn.
107+
if [[ "${initramfs_size_bytes}" -gt 943718400 ]]; then
108+
log warn "${inventory_id}: Uncompressed initramfs size (${initramfs_size_bytes} bytes) is larger than 900mb; it may not boot on a 2gb RAM machine."
109+
else
110+
log notice "${inventory_id}: Uncompressed initramfs size (${initramfs_size_bytes} bytes) is smaller than 900mb."
111+
fi
112+
101113
if [[ "${LK_RUN}" == "qemu" ]]; then
102114
linuxkit_run_qemu
103115
return 0

0 commit comments

Comments
 (0)