mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-02 00:02:01 +00:00
image: custom guest rootfs image file size alignment
The Guest rootfs image file size is aligned up to 128M boundary,
since commmit 2b0d5b2
. This change allows users to use a custom
alignment value - e.g., to align up to 2M, users will be able to
specify IMAGE_SIZE_ALIGNMENT_MB=2 for image_builder.sh.
Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
parent
c575048aa7
commit
65385a5bf9
@ -12,6 +12,7 @@ set -o pipefail
|
||||
|
||||
DOCKER_RUNTIME=${DOCKER_RUNTIME:-runc}
|
||||
MEASURED_ROOTFS=${MEASURED_ROOTFS:-no}
|
||||
IMAGE_SIZE_ALIGNMENT_MB=${IMAGE_SIZE_ALIGNMENT_MB:-128}
|
||||
|
||||
#For cross build
|
||||
CROSS_BUILD=${CROSS_BUILD:-false}
|
||||
@ -54,9 +55,6 @@ AGENT_INIT=${AGENT_INIT:-no}
|
||||
SELINUX=${SELINUX:-no}
|
||||
SELINUXFS="/sys/fs/selinux"
|
||||
|
||||
# Align image to 128M
|
||||
readonly mem_boundary_mb=128
|
||||
|
||||
# shellcheck source=../scripts/lib.sh
|
||||
source "${lib_file}"
|
||||
|
||||
@ -178,6 +176,7 @@ build_with_container() {
|
||||
--env TARGET_ARCH="${TARGET_ARCH}" \
|
||||
--env USER="$(id -u)" \
|
||||
--env GROUP="$(id -g)" \
|
||||
--env IMAGE_SIZE_ALIGNMENT_MB="${IMAGE_SIZE_ALIGNMENT_MB}" \
|
||||
-v /dev:/dev \
|
||||
-v "${script_dir}":"/osbuilder" \
|
||||
-v "${script_dir}/../scripts":"/scripts" \
|
||||
@ -308,9 +307,9 @@ calculate_img_size() {
|
||||
img_size="$((img_size + root_free_space_mb))"
|
||||
fi
|
||||
|
||||
remaining="$((img_size % mem_boundary_mb))"
|
||||
remaining="$((img_size % ${IMAGE_SIZE_ALIGNMENT_MB}))"
|
||||
if [ "${remaining}" != "0" ]; then
|
||||
img_size=$((img_size + mem_boundary_mb - remaining))
|
||||
img_size=$((img_size + ${IMAGE_SIZE_ALIGNMENT_MB} - remaining))
|
||||
fi
|
||||
|
||||
echo "${img_size}"
|
||||
|
@ -112,6 +112,7 @@ REPO_URL_X86_64="${REPO_URL_X86_64:-}"
|
||||
REPO_COMPONENTS="${REPO_COMPONENTS:-}"
|
||||
AGENT_POLICY="${AGENT_POLICY:-yes}"
|
||||
RUNTIME_CHOICE="${RUNTIME_CHOICE:-both}"
|
||||
IMAGE_SIZE_ALIGNMENT_MB=${IMAGE_SIZE_ALIGNMENT_MB:-}
|
||||
|
||||
docker run \
|
||||
-v $HOME/.docker:/root/.docker \
|
||||
|
Loading…
Reference in New Issue
Block a user