#!/bin/sh -exv sync; cd / # Stop all supervised services. sync; svclean-shutdown /service # Save the entropy pool. sync; dd if=/package/misc/spf/linux-data/entropy-dev \ of=/package/misc/spf/linux-data/entropy-pool bs=512 count=1 # Remount the /etc filesystem read-write, and save the hwclock data. sync; fsmount pkgs remount,rw sync; hwclock --systohc --utc # Remove all swap devices. swapfile_=; rest_= unset swapfile_ rest_ while read swapfile_ rest_; do case "$swapfile_" in /*) sync; minswapoff "$swapfile_" ;; esac < /dev/null done < /proc/swaps # Build a list of disk filesystems, except for the root (for me, that's pkgs). dev_=; mntpt_=; type_=; unset dev_ mntpt_ type_ set -- x; shift while read dev_ mntpt_ type_ rest_; do case "$type_" in rootfs|tmpfs|proc|devpts) continue;; esac case "$mntpt_" in /fs/pkgs/mount) continue;; esac set -- "$mntpt_" ${1+"$@"} done < /etc/mtab # Unmount those filesystems. for mntpt_ in ${1+"$@"}; do sync; minumount "$mntpt_" || { sleep 1; minumount "$mntpt_"; } done # Remount the last filesystem read-only. # (This would actually be good enough for all of them.) sync; fsmount pkgs remount,ro