]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
shutdown on demand
authorHarald Hoyer <harald@redhat.com>
Fri, 10 Feb 2012 10:14:42 +0000 (11:14 +0100)
committerHarald Hoyer <harald@redhat.com>
Mon, 13 Feb 2012 06:08:08 +0000 (07:08 +0100)
Do not save and restore the initramfs, but instead, just unpack the
default initramfs for shutdown on shutdown.

19 files changed:
Makefile
dracut-backup.service [deleted file]
dracut-initramfs-backup.sh [deleted file]
dracut-initramfs-restore.sh [new file with mode: 0644]
dracut-shutdown.service [moved from dracut-restore.service with 78% similarity]
dracut.conf.d/fedora.conf.example
dracut.spec
modules.d/90crypt/cryptroot-ask.sh
modules.d/90dmraid/dmraid.sh
modules.d/90dmsquash-live/dmsquash-live-root
modules.d/90lvm/lvm_scan.sh
modules.d/90mdraid/mdraid-cleanup.sh
modules.d/90multipath/multipathd.sh
modules.d/95fcoe/fcoe-up
modules.d/95iscsi/iscsiroot
modules.d/95nbd/nbdroot
modules.d/95nfs/nfsroot
modules.d/98usrmount/mount-usr.sh
modules.d/99base/dracut-lib.sh

index 09e87c8e7f76e6ecd107cea9c71c746ae7601113..99279ac7380a65003a867c8ac7da3575c30495ce 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -40,7 +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
+       install -m 0755 dracut-initramfs-restore.sh $(DESTDIR)$(pkglibdir)/dracut-initramfs-restore
        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
@@ -50,12 +50,9 @@ install: doc
        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; \
+               install -m 0644 dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir); \
                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; \
+               ln -s ../dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants/dracut-shutdown.service; \
        fi
 
 clean:
diff --git a/dracut-backup.service b/dracut-backup.service
deleted file mode 100644 (file)
index 69110eb..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#  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
deleted file mode 100644 (file)
index 7320d40..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/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-initramfs-restore.sh b/dracut-initramfs-restore.sh
new file mode 100644 (file)
index 0000000..26b698b
--- /dev/null
@@ -0,0 +1,10 @@
+#!/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
+IMG="/boot/initramfs-$(uname -r).img"
+[ -f .need_shutdown -a -f "$IMG" ] || exit 1
+zcat "$IMG"  | cpio -id >/dev/null 2>&1
+rm .need_shutdown
similarity index 78%
rename from dracut-restore.service
rename to dracut-shutdown.service
index 3a07efe3da84b148710c33ed36e45a97a8309832..4f06e350dde95209d7dd064d9e40b866fafc566a 100644 (file)
@@ -10,9 +10,9 @@ Description=Restore /run/initramfs
 After=getty@tty1.service prefdm.service
 Before=reboot.service
 DefaultDependencies=no
-ConditionPathExists=/run/initramfs/.backuped
+ConditionPathExists=/run/initramfs/.need_shutdown
 
 [Service]
-ExecStart=/usr/lib/dracut/dracut-initramfs-backup restore
+ExecStart=/usr/lib/dracut/dracut-initramfs-restore
 Type=oneshot
-RemainAfterExit=yes
\ No newline at end of file
+RemainAfterExit=yes
index 45063c66a1bedd9c297aaba30f9c8cefec920f0b..adfecc89f4f536a731b7af03ebef5f3c9ab05e65 100644 (file)
@@ -5,6 +5,5 @@ i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-F
 add_dracutmodules+=" rpmversion "
 omit_dracutmodules+=" dash "
 stdloglvl=3
-prefix=/run/initramfs
 realinitpath="/usr/lib/systemd/systemd"
 install_items+=" vi /etc/virc ps grep cat rm openvt "
index 6efd5538350cb38ba9f8ec8d92e978eb02e76a40..304f1f363ac959dffa29fe5a13b00f0dc2a30893 100644 (file)
@@ -223,7 +223,7 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{dracutlibdir}/modules.d
 %{dracutlibdir}/dracut-functions
 %{dracutlibdir}/dracut-logger
-%{dracutlibdir}/dracut-initramfs-backup
+%{dracutlibdir}/dracut-initramfs-restore
 %config(noreplace) /etc/dracut.conf
 %if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} > 6
 %config /etc/dracut.conf.d/01-dist.conf
index 6a95dc226967b2515f105cdfc66b747111201378..aba1331cf7522933813a4172f6a5f79288e715a2 100755 (executable)
@@ -117,6 +117,7 @@ unset device luksname luksfile
 # mark device as asked
 >> /tmp/cryptroot-asked-$2
 
+need_shutdown
 udevsettle
 
 exit 0
index feff5166b236081dc0c397a2e4981ffc188a2966..574dc3b33e368de549df1b18f57a7d47af1ba03e 100755 (executable)
@@ -40,3 +40,4 @@ else
     done
 fi
 
+need_shutdown
index d9fcc43efaf05d2ccf09481de649e011538b3ebb..e3606cf7416ff0ad346366f437c521272588cf78 100755 (executable)
@@ -206,4 +206,6 @@ fi
 ln -s /dev/mapper/live-rw /dev/root
 printf '/bin/mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh
 
+need_shutdown
+
 exit 0
index 3c0094e5ea7076d543b67725fc7f29eab9dd0157..104565f0a5229f80caad75b4667a3923db7a3dfd 100755 (executable)
@@ -126,3 +126,5 @@ if [ "$lvmwritten" ]; then
     rm -f /etc/lvm/lvm.conf
 fi
 unset lvmwritten
+
+need_shutdown
index 3ffa2d3b9fadb3c54a07ff0fa2a3f5c240d14c68..2e8a389dea801b6eedf5cb3c14a1cf7500b25efb 100755 (executable)
@@ -13,11 +13,11 @@ for md in /dev/md[0-9_]*; do
         containers="$containers $md"
         continue
     fi
-    mdadm -S "$md" >/dev/null 2>&1
+    mdadm -S "$md" >/dev/null 2>&1 || need_shutdown
 done
 
 for md in $containers; do
-    mdadm -S "$md" >/dev/null 2>&1
+    mdadm -S "$md" >/dev/null 2>&1 || need_shutdown
 done
 
 unset containers udevinfo
index 4d8935f646660f8933dde1966fe02bf1f0b0df6d..6d6eb990711ed1647f5582f39ce439e72ded4ab9 100755 (executable)
@@ -5,6 +5,7 @@
 if [ -e /etc/multipath.conf ]; then
     modprobe dm-multipath
     multipathd -B || multipathd
+    need_shutdown
 else
     rm /etc/udev/rules.d/??-multipath.rules 2>/dev/null
 fi
index 5c5bdb5d82ab685e04d23d81027d1fd908d9aa78..1e1bcf5c22043537181dd56dde04a527dcd3a75c 100755 (executable)
@@ -46,3 +46,5 @@ elif [ "$netdriver" = "bnx2x" ]; then
 else
     echo -n "$netif" > /sys/module/fcoe/parameters/create
 fi
+
+need_shutdown
index e7bac74705b70576454e9463cb8441c74ebd41e8..d8f7c8fc274323abc4d752ef3b1d05b4b1cadc34 100755 (executable)
@@ -205,6 +205,8 @@ else
     handle_netroot $iroot
 fi
 
+need_shutdown
+
 # now we have a root filesystem somewhere in /dev/sda*
 # let the normal block handler handle root=
 exit 0
index 1fb2140e1b9a4803771fd2025305c313e32e6469..e20b4e45e4f11a2fc4f1775f992fc0ca1e5e6f82 100755 (executable)
@@ -107,4 +107,5 @@ fi
 # NBD doesn't emit uevents when it gets connected, so kick it
 echo change > /sys/block/nbd0/uevent
 udevadm settle
+need_shutdown
 exit 0
index 2103e24ab026ce5c81fd215ae238f8cd803eb34c..764971b10b28522da5cc2f74c1297a5778758e6a 100755 (executable)
@@ -106,4 +106,4 @@ echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/
 # force udevsettle to break
 > $hookdir/initqueue/work
 
-
+need_shutdown
index 5139c7a0b0aecaf2d2d37da1f55a66e35b0fbf6c..999862400df68da7b1dbf979749ade5ec7b7e6cc 100755 (executable)
@@ -11,6 +11,16 @@ mount_usr()
     # check, if we have to mount the /usr filesystem
     while read _dev _mp _fs _opts _rest; do
         if [ "$_mp" = "/usr" ]; then
+            case "$_dev" in
+                LABEL=*)
+                    _dev="$(echo $_dev | sed 's,/,\\x2f,g')"
+                    _dev="/dev/disk/by-label/${_dev#LABEL=}"
+                   ;;
+                UUID=*)
+                    _dev="${_dev#block:}"
+                    _dev="/dev/disk/by-uuid/${_dev#UUID=}"
+                    ;;
+            esac
             echo "$_dev ${NEWROOT}${_mp} $_fs ${_opts} $_rest"
             _usr_found="1"
             break
index 4897a3dffb1f4a8a322ef1fe33b06e4dccaf2b50..6b70adfe3936f5db248ca11981c032e683a4641a 100755 (executable)
@@ -738,3 +738,7 @@ killproc() {
         fi
     done
 }
+
+need_shutdown() {
+    >/run/initramfs/.need_shutdown
+}