From 03deaed9f3f5b0c0537eb65e8f1862f53bc21fec Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 15 Nov 2011 09:25:20 -0500 Subject: shutdown: add new hook This adds functionality to pivot to back to the initramfs on shutdown, thereby allowing the system to unmount the real root device. This will be necessary for anyone with /usr as a separate partition. --- Makefile | 2 +- hooks/shutdown | 7 +++++++ install/shutdown | 17 +++++++++++++++++ shutdown | 29 +++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 hooks/shutdown create mode 100644 install/shutdown create mode 100755 shutdown diff --git a/Makefile b/Makefile index 3e7966d..e1fe5aa 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ install: all chmod 755 ${DESTDIR}/usr/bin/lsinitcpio ${DESTDIR}/usr/bin/mkinitcpio install -m644 mkinitcpio.conf ${DESTDIR}/etc/mkinitcpio.conf - install -m755 -t ${DESTDIR}/lib/initcpio init + install -m755 -t ${DESTDIR}/lib/initcpio init shutdown install -m644 -t ${DESTDIR}/lib/initcpio init_functions functions install -m644 01-memdisk.rules ${DESTDIR}/lib/initcpio/udev/01-memdisk.rules diff --git a/hooks/shutdown b/hooks/shutdown new file mode 100644 index 0000000..7c5d9e8 --- /dev/null +++ b/hooks/shutdown @@ -0,0 +1,7 @@ +#!/usr/bin/ash + +run_hook() { + cp -ax / /run/initramfs +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/install/shutdown b/install/shutdown new file mode 100644 index 0000000..2c533b6 --- /dev/null +++ b/install/shutdown @@ -0,0 +1,17 @@ +#!/bin/bash + +build() { + BINARIES='cp findmnt' + SCRIPT='shutdown' + + add_file "/lib/initcpio/shutdown" "/shutdown" +} + +help() { + cat < 0; j--) { + print mounts[j] + } +} +' | while read -r mount; do + umount -l "$mount" +done + +case $1 in + reboot) + type kexec >/dev/null && kexec -e + reboot -f + ;; + poweroff|shutdown|halt) + "$1" -f + ;; + *) + poweroff -f + ;; +esac -- cgit v1.2.3-24-g4f1b