[PATCH 3/3] compress /run/initramfs/usr in initramfs cleanup

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

 



We don't actually need the contents of /run/initramfs/usr while inside
anaconda, so we can compress it and stick it in /boot, saving ~28MB RAM.

To be able to shut down properly, we'll need dracut-shutdown.service
(and its dependencies) in the runtime; there should be an associated
lorax patch that accomplishes this.
---
 data/systemd/anaconda-cleanup-initramfs         |   17 +++++++++++++++++
 data/systemd/anaconda-cleanup-initramfs.service |    1 +
 2 files changed, 18 insertions(+)

diff --git a/data/systemd/anaconda-cleanup-initramfs b/data/systemd/anaconda-cleanup-initramfs
index 66b6e07..f2bd274 100755
--- a/data/systemd/anaconda-cleanup-initramfs
+++ b/data/systemd/anaconda-cleanup-initramfs
@@ -16,3 +16,20 @@ systemd-notify --pid --status="Removing unneeded files..."
 # removing the ssl certs saves another easy ~1MB.
 rm -rf /run/initramfs/usr/lib/{firmware,modules} \
        /run/initramfs/etc/ssl
+
+# Try to compress the remaining initramfs contents.
+# 99% of the RAM used by initramfs is in usr/, so just compress/remove that.
+# (this also means we save etc/cmdline* and we don't have to move mounts)
+
+# check for cpio and pigz/gzip.
+# (xz would be ~4MB smaller but uses 100MB RAM (!). gzip uses ~2MB.)
+type -P cpio >/dev/null || exit 0
+gzip=$(type -P pigz || type -P gzip) || exit 0
+
+# systemd-notify --ready --> continue startup, do the rest in the background
+systemd-notify --ready --status="Compressing initramfs contents..."
+
+mkdir -p /boot
+initramfs=/boot/initramfs-$(uname -r).img
+find /run/initramfs/usr | cpio -co 2>/dev/null | $gzip -c > $initramfs
+rm -rf /run/initramfs/usr
diff --git a/data/systemd/anaconda-cleanup-initramfs.service b/data/systemd/anaconda-cleanup-initramfs.service
index 5bed880..1d10bfc 100644
--- a/data/systemd/anaconda-cleanup-initramfs.service
+++ b/data/systemd/anaconda-cleanup-initramfs.service
@@ -7,4 +7,5 @@ ConditionPathIsDirectory=/run/initramfs/usr/lib/modules
 Type=notify
 NotifyAccess=all
 RemainAfterExit=yes
+Nice=19
 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