Skip to content

Commit

Permalink
Merge pull request #302 from microsoft/danmihai1/systemd-delete
Browse files Browse the repository at this point in the history
rootfs: delete more systemd files
  • Loading branch information
ms-mahuber authored Feb 5, 2025
2 parents c57a2d1 + 6b55a48 commit 08aceb8
Showing 1 changed file with 49 additions and 4 deletions.
53 changes: 49 additions & 4 deletions tools/osbuilder/rootfs-builder/rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,62 @@ TARGET_OS=${TARGET_OS:-linux}

# The list of systemd units and files that are not needed in Kata Containers
readonly -a systemd_units=(
"blk-availability"
"sys-fs-fuse-connections"
"sys-kernel-config"
"systemd-ask-password-console"
"systemd-ask-password-wall"
"systemd-boot-update"
"systemd-coredump@"
"systemd-journal-catalog-update"
"systemd-journal-flush"
"systemd-journald"
"systemd-journald@"
"systemd-journald-audit"
"systemd-journald-dev-log"
"systemd-journal-flush"
"systemd-logind"
"systemd-network-generator"
"systemd-pcrfs@"
"systemd-pcrfs-root"
"systemd-pcrlock-firmware-code"
"systemd-pcrlock-firmware-config"
"systemd-pcrlock-file-system"
"systemd-pcrlock-machine-id"
"systemd-pcrlock-make-policy"
"systemd-pcrlock-secureboot-authority"
"systemd-pcrlock-secureboot-policy"
"systemd-pcrmachine"
"systemd-pcrphase"
"systemd-pcrphase-initrd"
"systemd-pcrphase-sysinit"
"systemd-pcrextend"
"systemd-pcrextend@"
"systemd-pstore"
"systemd-random-seed"
"systemd-sysupdate"
"systemd-sysupdate-reboot"
"systemd-timesyncd"
"systemd-tmpfiles-clean"
"systemd-tmpfiles-setup"
"systemd-tmpfiles-setup-dev"
"systemd-tmpfiles-setup-dev-early"
"systemd-tpm2-setup"
"systemd-tpm2-setup-early"
"systemd-update-utmp"
"systemd-update-utmp-runlevel"
"systemd-vconsole-setup"
)

readonly -a systemd_files=(
"blkdeactivate"
"journalctl"
"systemd-bless-boot-generator"
"systemd-fstab-generator"
"systemd-getty-generator"
"systemd-gpt-auto-generator"
"systemd-tmpfiles-cleanup.timer"
"systemd-pcrlock"
"systemd-tmpfiles"
"systemd-tty-ask-password-agent"
)

handle_error() {
Expand Down Expand Up @@ -745,11 +785,16 @@ detect_host_distro()

delete_unnecessary_files()
{
info "Removing unneeded systemd services and sockets"
info "Removing unneeded systemd unit files"
for u in "${systemd_units[@]}"; do
find "${ROOTFS_DIR}" \
\( -type f -o -type l \) \
\( -name "${u}.service" -o -name "${u}.socket" \) \
\( -name "${u}" -o \
-name "${u}.mount" -o \
-name "${u}.path" -o \
-name "${u}.service" -o \
-name "${u}.socket" -o \
-name "${u}.timer" \) \
-exec echo "deleting {}" \; \
-exec rm -f {} \;
done
Expand Down

0 comments on commit 08aceb8

Please sign in to comment.