From 77c7b4d5b90aff113d54de88723cbb06eb04d64a Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Feb 10 2012 09:01:59 +0000 Subject: forgot latest patch file --- diff --git a/0007-Backup-and-restore-run-initramfs-via-systemd-service.patch b/0007-Backup-and-restore-run-initramfs-via-systemd-service.patch new file mode 100644 index 0000000..5892264 --- /dev/null +++ b/0007-Backup-and-restore-run-initramfs-via-systemd-service.patch @@ -0,0 +1,180 @@ +From 39fdc4101ac9c04a2b8365567739da8573f12431 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Fri, 10 Feb 2012 09:37:18 +0100 +Subject: [PATCH] Backup and restore /run/initramfs via systemd services + +This saves the space /run/initramfs is taking for the shutdown +--- + Makefile | 16 ++++++++++++++-- + dracut-backup.service | 15 +++++++++++++++ + dracut-initramfs-backup.sh | 22 ++++++++++++++++++++++ + dracut-restore.service | 18 ++++++++++++++++++ + dracut.spec | 12 +++++++++++- + 5 files changed, 80 insertions(+), 3 deletions(-) + create mode 100644 dracut-backup.service + create mode 100644 dracut-initramfs-backup.sh + create mode 100644 dracut-restore.service + +diff --git a/Makefile b/Makefile +index 8d7b7d6..09e87c8 100644 +--- a/Makefile ++++ b/Makefile +@@ -40,6 +40,7 @@ install: doc + mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d + install -m 0755 dracut-functions $(DESTDIR)$(pkglibdir)/dracut-functions + install -m 0755 dracut-logger $(DESTDIR)$(pkglibdir)/dracut-logger ++ install -m 0755 dracut-initramfs-backup.sh $(DESTDIR)$(pkglibdir)/dracut-initramfs-backup + cp -arx modules.d $(DESTDIR)$(pkglibdir) + install -m 0644 dracut.8 $(DESTDIR)$(mandir)/man8/dracut.8 + install -m 0644 dracut-catimages.8 $(DESTDIR)$(mandir)/man8/dracut-catimages.8 +@@ -47,6 +48,15 @@ install: doc + install -m 0644 dracut.conf.5 $(DESTDIR)$(mandir)/man5/dracut.conf.5 + install -m 0644 dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.cmdline.7 + ln -s dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7 ++ if [ -n "$(systemdsystemunitdir)" ]; then \ ++ mkdir -p $(DESTDIR)$(systemdsystemunitdir); \ ++ install -m 0644 dracut-backup.service $(DESTDIR)$(systemdsystemunitdir); \ ++ install -m 0644 dracut-restore.service $(DESTDIR)$(systemdsystemunitdir); \ ++ mkdir -p $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants; \ ++ mkdir -p $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants; \ ++ ln -s ../dracut-backup.service $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants/dracut-backup.service; \ ++ ln -s ../dracut-restore.service $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants/dracut-restore.service; \ ++ fi + + clean: + $(RM) *~ +@@ -77,12 +87,14 @@ rpm: dracut-$(VERSION).tar.bz2 + ( mv "$$rpmbuild"/noarch/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm ) + + syncheck: +- @ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \ ++ @ret=0;for i in dracut-initramfs-backup.sh dracut-logger \ ++ modules.d/99base/init modules.d/*/*.sh; do \ + [ "$${i##*/}" = "module-setup.sh" ] && continue; \ + [ "$${i##*/}" = "caps.sh" ] && continue; \ + dash -n "$$i" ; ret=$$(($$ret+$$?)); \ + done;exit $$ret +- @ret=0;for i in dracut modules.d/02caps/caps.sh modules.d/*/module-setup.sh; do \ ++ @ret=0;for i in mkinitrd-dracut.sh dracut modules.d/02caps/caps.sh \ ++ modules.d/*/module-setup.sh; do \ + bash -n "$$i" ; ret=$$(($$ret+$$?)); \ + done;exit $$ret + +diff --git a/dracut-backup.service b/dracut-backup.service +new file mode 100644 +index 0000000..69110eb +--- /dev/null ++++ b/dracut-backup.service +@@ -0,0 +1,15 @@ ++# This file is part of systemd. ++# ++# systemd is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++ ++[Unit] ++Description=Save /run/initramfs ++ConditionPathExists=/run/initramfs ++ ++[Service] ++ExecStart=/usr/lib/dracut/dracut-initramfs-backup backup ++Type=oneshot ++RemainAfterExit=yes +diff --git a/dracut-initramfs-backup.sh b/dracut-initramfs-backup.sh +new file mode 100644 +index 0000000..7320d40 +--- /dev/null ++++ b/dracut-initramfs-backup.sh +@@ -0,0 +1,22 @@ ++#!/bin/sh ++# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- ++# ex: ts=8 sw=4 sts=4 et filetype=sh ++ ++set -e ++cd /run/initramfs ++ ++if [ "x$1" = "xbackup" ]; then ++ compress="gzip" ++ command -v pigz > /dev/null 2>&1 && compress="pigz" ++ find . |cpio -H newc -o --quiet \ ++ | pigz > /var/lib/initramfs/_run_initramfs-backup.cpio.gz ++ mv -f /var/lib/initramfs/_run_initramfs-backup.cpio.gz \ ++ /var/lib/initramfs/run_initramfs-backup.cpio.gz ++ rm -fr etc bin lib lib64 sbin shutdown tmp usr var ++ > .backuped ++elif [ "x$1" = "xrestore" ]; then ++ [ -f .backuped -a -f /var/lib/initramfs/run_initramfs-backup.cpio.gz ] || exit 1 ++ zcat /var/lib/initramfs/run_initramfs-backup.cpio.gz | cpio -id >/dev/null 2>&1 ++ rm .backuped ++ rm -f /var/lib/initramfs/run_initramfs-backup.cpio.gz ++fi +diff --git a/dracut-restore.service b/dracut-restore.service +new file mode 100644 +index 0000000..3a07efe +--- /dev/null ++++ b/dracut-restore.service +@@ -0,0 +1,18 @@ ++# This file is part of systemd. ++# ++# systemd is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++ ++[Unit] ++Description=Restore /run/initramfs ++After=getty@tty1.service prefdm.service ++Before=reboot.service ++DefaultDependencies=no ++ConditionPathExists=/run/initramfs/.backuped ++ ++[Service] ++ExecStart=/usr/lib/dracut/dracut-initramfs-backup restore ++Type=oneshot ++RemainAfterExit=yes +\ No newline at end of file +diff --git a/dracut.spec b/dracut.spec +index 1b0b76b..17a62b2 100644 +--- a/dracut.spec ++++ b/dracut.spec +@@ -27,6 +27,7 @@ Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar + + BuildArch: noarch + BuildRequires: dash bash git ++ + %if 0%{?fedora} || 0%{?rhel} > 6 + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + %endif +@@ -51,6 +52,10 @@ Obsoletes: nash <= 6.0.93 + Obsoletes: libbdevid-python <= 6.0.93 + %endif + ++%if 0%{?fedora} > 16 || 0%{?rhel} > 6 ++BuildRequires: systemd-units ++%endif ++ + %if 0%{?suse_version} > 9999 + Obsoletes: mkinitrd < 2.6.1 + Provides: mkinitrd = 2.6.1 +@@ -161,7 +166,8 @@ rm -rf $RPM_BUILD_ROOT + make install DESTDIR=$RPM_BUILD_ROOT \ + libdir=%{_prefix}/lib \ + bindir=%{_bindir} \ +- sysconfdir=/etc mandir=%{_mandir} ++ sysconfdir=/etc mandir=%{_mandir} \ ++ systemdsystemunitdir=%{_unitdir} + + echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/10rpmversion/dracut-version + +@@ -266,6 +272,10 @@ rm -rf $RPM_BUILD_ROOT + %config(noreplace) /etc/logrotate.d/dracut_log + %attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log + %dir %{_sharedstatedir}/initramfs ++%if 0%{?fedora} > 16 || 0%{?rhel} > 6 ++%{_unitdir}/*.service ++%{_unitdir}/*/*.service ++%endif + + %files network + %defattr(-,root,root,0755)