--- baselayout-1.13.0_alpha10/init.d/localmount 2006-12-19 17:03:18 +0100 +++ /etc/init.d/localmount 2007-01-01 23:57:41 +0100 @@ -55,12 +55,47 @@ fi fi + # Now that we have the filesystems mount in R/W mode, save the FreeBSD + # core file if present; this needs to be done before enabling swap, or + # the core will be lost for good + freebsd_savecore() { + [[ $(uname) != "FreeBSD" ]] && return 0 + + local dumpdir=${KERNEL_DUMP_DIR:-/var/crash} + if ! [[ -d "${dumpdir}" ]]; then + mkdir -p "${dumpdir}" + chmod 700 "${dumpdir}" + fi + + # Don't quote ${KERNEL_DUMP_DEVICE}, so that if it's unset, savecore + # will check on the partitions listed in fstab without errors in the + # output + savecore -C "${dumpdir}" ${KERNEL_DUMP_DEVICE} >/dev/null || return 0 + + local savecoreopts="${dumpdir} ${KERNEL_DUMP_DEVICE}" + [[ ${KERNEL_DUMP_COMPRESS} == "yes" ]] && savecoreopts="-z ${savecoreopts}" + + ebegin $"Saving kernel core dump" + savecore ${savecoreopts} >/dev/null + eend $? + } + + freebsd_savecore + # We do our swapping here instead of rc so we can get urandom started # before us for people that like an encrypted swap. ebegin $"Activating (possible) swap" swapon -a >/dev/null eend 0 # If swapon has nothing todo it errors, so always return 0 + # Now that the swap devices are enabled, FreeBSD users might request to + # enable kernel dumps during panic, so run dumpon if needed. + if [[ $(uname) == "FreeBSD" ]] && [[ -n "${KERNEL_DUMP_DEVICE}" ]]; then + ebegin $"Activating kernel core dump device." + dumpon "${KERNEL_DUMP_DEVICE}" + eend $? + fi + # Start dm-crypt mappings, if any start_addon dm-crypt