Skip to content

Commit

Permalink
image-builder: remove unneeded systemd units and files
Browse files Browse the repository at this point in the history
Remove systemd units and files that are not needed in Kata Containers.
Removing this files we can improve the boot time.

fixes kata-containers#289

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes committed May 16, 2019
1 parent 4a2fa68 commit 875e593
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion image-builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ From fedora:latest

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
28 changes: 28 additions & 0 deletions image-builder/image_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ readonly dax_header_sz=2
# [2] - https://nvdimm.wiki.kernel.org/2mib_fs_dax
readonly dax_alignment=2

# The list of systemd units and files that are not needed in Kata Containers
readonly -a systemd_units=(
"systemd-journald"
"systemd-journal-flush"
"systemd-journald-dev-log"
"systemd-udevd"
"systemd-udev-trigger"
"systemd-udevd-kernel"
"systemd-udevd-control"
"systemd-timesyncd"
"systemd-update-utmp"
"systemd-tmpfiles-setup"
"systemd-tmpfiles-cleanup"
"tmp"
"systemd-random-seed"
"systemd-coredump@"
"systemd-random-seed"
"systemd-fstab-generator"
"systemd-gpt-auto-generator"
"systemd-getty-generator"
"systemd-bless-boot-generator"
)

# Set a default value
AGENT_INIT=${AGENT_INIT:-no}

Expand Down Expand Up @@ -344,6 +367,11 @@ create_rootfs_image() {
sync
OK "rootfs copied"

info "Removing unneeded systemd units"
for u in "${systemd_units[@]}"; do
find "${mount_dir}" -type f \( -name "${u}.service" -o -name "${u}.socket" -o -name "${u}.mount" -o -name "${u}.timer" -o -name "${u}" \) -exec rm -f {} \;
done

info "Unmounting root partition"
umount "${mount_dir}"
OK "Root partition unmounted"
Expand Down

0 comments on commit 875e593

Please sign in to comment.