[PATCH 2/3] Add anaconda-cleanup-initramfs.service

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds anaconda-cleanup-initramfs.service, so we can clean
unnecessary/redundant files out of /run/initramfs to save RAM.

The initial cleanup strategy is to remove kernel modules, firmware, and
the ssl certificate store, because the anaconda runtime has all these
things already. This saves about 40MB RAM.
---
 data/systemd/Makefile.am                        |   12 +++++++++++-
 data/systemd/anaconda-cleanup-initramfs         |   18 ++++++++++++++++++
 data/systemd/anaconda-cleanup-initramfs.service |   10 ++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100755 data/systemd/anaconda-cleanup-initramfs
 create mode 100644 data/systemd/anaconda-cleanup-initramfs.service

diff --git a/data/systemd/Makefile.am b/data/systemd/Makefile.am
index 108d7e5..8579ece 100644
--- a/data/systemd/Makefile.am
+++ b/data/systemd/Makefile.am
@@ -19,6 +19,16 @@
 
 systemddir = /lib/systemd/system
 generatordir = /lib/systemd/system-generators
-dist_systemd_DATA = anaconda-shell@.service anaconda.target anaconda@.service instperf.service anaconda-sshd.service
+
+dist_systemd_DATA = anaconda@.service \
+		    anaconda.target \
+		    anaconda-shell@.service \
+		    instperf.service \
+		    anaconda-sshd.service \
+		    anaconda-cleanup-initramfs.service
+
 dist_generator_SCRIPTS = anaconda-generator
+
+dist_sbin_SCRIPTS = anaconda-cleanup-initramfs
+
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/data/systemd/anaconda-cleanup-initramfs b/data/systemd/anaconda-cleanup-initramfs
new file mode 100755
index 0000000..66b6e07
--- /dev/null
+++ b/data/systemd/anaconda-cleanup-initramfs
@@ -0,0 +1,18 @@
+#!/bin/bash
+# anaconda-cleanup-initramfs - clean up initramfs to save RAM.
+#
+# Normal systems just throw away the initramfs after boot, since they have a
+# copy of it in /boot/initramfs-$(uname -r).img that they can unpack and use
+# to shut down the system cleanly. (See dracut-shutdown.service.)
+#
+# We have to keep initramfs because we don't have it laying around in /boot,
+# and we might want to read some files out of it (e.g. /etc/cmdline*)
+#
+# There are still redundant/unneeded files, though, and we can save RAM by
+# cleaning those up.
+
+systemd-notify --pid --status="Removing unneeded files..."
+# the runtime has all the firmware/modules we need.
+# removing the ssl certs saves another easy ~1MB.
+rm -rf /run/initramfs/usr/lib/{firmware,modules} \
+       /run/initramfs/etc/ssl
diff --git a/data/systemd/anaconda-cleanup-initramfs.service b/data/systemd/anaconda-cleanup-initramfs.service
new file mode 100644
index 0000000..5bed880
--- /dev/null
+++ b/data/systemd/anaconda-cleanup-initramfs.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Clean Up Initramfs
+Before=anaconda@.service
+ConditionPathIsDirectory=/run/initramfs/usr/lib/modules
+
+[Service]
+Type=notify
+NotifyAccess=all
+RemainAfterExit=yes
+ExecStart=/usr/sbin/anaconda-cleanup-initramfs
-- 
1.7.10.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux