]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
add pre-pivot-cleanup hook
authorDave Young <dyoung@redhat.com>
Thu, 19 Apr 2012 04:01:36 +0000 (12:01 +0800)
committerHarald Hoyer <harald@redhat.com>
Thu, 19 Apr 2012 09:59:45 +0000 (11:59 +0200)
Sometimes some hook script will need to be before the cleanup hook scripts
For example dhclient killing, nfs cleanup, etc. must not happen before kdump
because it will use their fuctionalities.

So here introduce a new hook pre-pivot-cleanup, all cleanup scripts will go there.
that means pre-pivot hook is splited to two hooks pre-pivot and pre-pivot-cleanup

Signed-off-by: Dave Young <dyoung@redhat.com>
README.modules
dracut-functions.sh
dracut.asc
dracut.cmdline.7.asc
modules.d/99base/init.sh

index 21461de345944c4d1c25ba9532b823fbacec608d..188d01196e09add8bb9049b17b67441439a92657 100644 (file)
@@ -103,6 +103,9 @@ init has the following hook points to inject scripts:
    a timeout.
 
 /lib/dracut/hooks/pre-pivot/*.sh
+   scripts to run before latter initramfs cleanups
+
+/lib/dracut/hooks/pre-pivot-cleanup/*.sh
    scripts to run before the real init is executed and the initramfs
    disappears
    All processes started before should be killed here.
index f5611dcc371980f1ab0c35602da11323e8567fe3..ccf3ba64adfafe8b07f82b2e0635146183871696 100755 (executable)
@@ -36,7 +36,7 @@ fi
 [[ $hookdirs ]] || {
     hookdirs="cmdline pre-udev pre-trigger netroot "
     hookdirs+="initqueue initqueue/settled initqueue/online initqueue/finished initqueue/timeout "
-    hookdirs+="pre-mount pre-pivot mount "
+    hookdirs+="pre-mount pre-pivot pre-pivot-cleanup mount "
     hookdirs+="emergency shutdown-emergency shutdown cleanup "
     export hookdirs
 }
index 1a0e3d2f13c2bfa87592e123a5966aebde4f0a31..9621db2af1763194d8787cd1d4545bcf2e39cdd1 100644 (file)
@@ -854,12 +854,17 @@ This hook is mainly to mount the real root device.
 
 === Hook: pre-pivot
 
+This hook is called before pre-pivot-cleanup hook, This is a good place for
+actions other than cleanups which need to be called before pivot.
+
+
+=== Hook: pre-pivot-cleanup
+
 This hook is the last hook and is called before init finally switches root to
 the real root device. This is a good place to clean up and kill processes not
 needed anymore.
 
 
-
 === Cleanup and switch_root
 
 Init kills all udev processes, cleans up the environment, sets up the arguments
index c77fee5714a29df6da856d2b70797c582af22963..76db6516d44226b4104a6c2ec7cdcc812a4120f8 100644 (file)
@@ -105,7 +105,7 @@ Debug
 **rd.break**::
     drop to a shell at the end
 
-**rd.break=**_{cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot}_::
+**rd.break=**_{cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot|pre-pivot-cleanup}_::
     drop to a shell on defined breakpoint
 
 **rd.udev.info**::
index 65bc88f0b42d018eae49757d4b23b6c1dce42363..88ec184616f8d7a7c29a1d29a62c8830aad4c884 100755 (executable)
@@ -224,10 +224,15 @@ done
     while read dev mp rest; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
 } | vinfo
 
-# pre pivot scripts are sourced just before we switch over to the new root.
+# pre pivot scripts are sourced just before we doing cleanup and switch over
+# to the new root.
 getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
 source_hook pre-pivot
 
+# pre pivot cleanup scripts are sourced just before we switch over to the new root.
+getarg 'rd.break=pre-pivot-cleanup' 'rdbreak=pre-pivot-cleanup' && emergency_shell -n pre-pivot-cleanup "Break pre-pivot-cleanup"
+source_hook pre-pivot-cleanup
+
 # By the time we get here, the root filesystem should be mounted.
 # Try to find init. 
 for i in "$(getarg real_init=)" "$(getarg init=)" $(getargs rd.distroinit=) /sbin/init; do