diff options
author | Dave Reisner <dreisner@archlinux.org> | 2011-11-15 15:25:20 +0100 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2012-01-05 21:14:25 +0100 |
commit | 03deaed9f3f5b0c0537eb65e8f1862f53bc21fec (patch) | |
tree | a7ae64df327b4f1351ede76d0efd6e9a9bdf7053 | |
parent | bd4f7d6ee8f8527625b9f240a7e5b68b2d1f87bb (diff) | |
download | mkinitcpio-03deaed9f3f5b0c0537eb65e8f1862f53bc21fec.tar.gz mkinitcpio-03deaed9f3f5b0c0537eb65e8f1862f53bc21fec.tar.xz |
shutdown: add new hook0.8.1
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.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | hooks/shutdown | 7 | ||||
-rw-r--r-- | install/shutdown | 17 | ||||
-rwxr-xr-x | shutdown | 29 |
4 files changed, 54 insertions, 1 deletions
@@ -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 <<HELPEOF +This hook copies the contents of the initramfs into /run/initramfs for reuse +on shutdown. This is needed when you have /usr mounted on a separate partition. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/shutdown b/shutdown new file mode 100755 index 0000000..100f505 --- /dev/null +++ b/shutdown @@ -0,0 +1,29 @@ +#!/usr/bin/ash + +findmnt -Rruno TARGET /oldroot | awk ' +BEGIN { i = 0 } +! /^\/(proc|dev|sys)/ { + i++ + mounts[i] = $0 +} +END { + for (j = i; j > 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 |