Merge pull request #290 from devimc/topic/image/removeSystemdUnits

image-builder/boot time: remove unneeded systemd units and files
This commit is contained in:
James O. D. Hunt 2019-05-17 09:59:59 +01:00 committed by GitHub
commit a800a5dee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -7,4 +7,4 @@ From fedora:latest
RUN [ -n "$http_proxy" ] && sed -i '$ a proxy='$http_proxy /etc/dnf/dnf.conf ; true RUN [ -n "$http_proxy" ] && sed -i '$ a proxy='$http_proxy /etc/dnf/dnf.conf ; true
RUN dnf install -y qemu-img parted gdisk e2fsprogs gcc xfsprogs RUN dnf install -y qemu-img parted gdisk e2fsprogs gcc xfsprogs findutils

View File

@ -34,6 +34,31 @@ readonly dax_header_sz=2
# [2] - https://nvdimm.wiki.kernel.org/2mib_fs_dax # [2] - https://nvdimm.wiki.kernel.org/2mib_fs_dax
readonly dax_alignment=2 readonly dax_alignment=2
# The list of systemd units and files that are not needed in Kata Containers
readonly -a systemd_units=(
"systemd-coredump@"
"systemd-journald"
"systemd-journald-dev-log"
"systemd-journal-flush"
"systemd-random-seed"
"systemd-timesyncd"
"systemd-tmpfiles-setup"
"systemd-udevd"
"systemd-udevd-control"
"systemd-udevd-kernel"
"systemd-udev-trigger"
"systemd-update-utmp"
)
readonly -a systemd_files=(
"systemd-bless-boot-generator"
"systemd-fstab-generator"
"systemd-getty-generator"
"systemd-gpt-auto-generator"
"systemd-tmpfiles-cleanup.timer"
"tmp.mount"
)
# Set a default value # Set a default value
AGENT_INIT=${AGENT_INIT:-no} AGENT_INIT=${AGENT_INIT:-no}
@ -344,6 +369,19 @@ create_rootfs_image() {
sync sync
OK "rootfs copied" OK "rootfs copied"
info "Removing unneeded systemd services and sockets"
for u in "${systemd_units[@]}"; do
find "${mount_dir}" -type f \( \
-name "${u}.service" -o \
-name "${u}.socket" \) \
-exec rm -f {} \;
done
info "Removing unneeded systemd files"
for u in "${systemd_files[@]}"; do
find "${mount_dir}" -type f -name "${u}" -exec rm -f {} \;
done
info "Unmounting root partition" info "Unmounting root partition"
umount "${mount_dir}" umount "${mount_dir}"
OK "Root partition unmounted" OK "Root partition unmounted"