--- grub-mkconfig.orig 2012-01-21 23:08:55.000000000 +0100 +++ grub-mkconfig 2012-01-21 23:10:00.000000000 +0100 @@ -32,6 +32,7 @@ datarootdir=${prefix}/share datadir=${datarootdir} pkgdatadir=${datadir}/`echo grub | sed "${transform}"` grub_cfg="" +resume_hook=1 grub_mkconfig_dir=${sysconfdir}/grub.d self=`basename $0` @@ -52,6 +53,7 @@ Generate a grub config file -o, --output=FILE output generated config to FILE [default=stdout] -h, --help print this message and exit -v, --version print the version information and exit + -s, --skip-resume disable resume hook setup Report bugs to . EOF @@ -86,6 +88,9 @@ do --output=*) grub_cfg=`echo "$option" | sed 's/--output=//'` ;; + -s | --skip-resume) + resume_hook=0 + ;; -*) echo "Unrecognized option \`$option'" 1>&2 usage @@ -295,6 +300,18 @@ for i in ${grub_mkconfig_dir}/* ; do esac done +if [ "${resume_hook}" == 1 ]; then + echo "Setup resume hook" >&2 + SWAP=`swapon -a | cat /proc/swaps | grep /dev | cut -d" " -f1` + if [ -z "${SWAP}" ]; then + echo "No swap partition found. Create one to enable hibernation..." >&2 + else + echo "Adding swap partition $SWAP" >&2 + SWAPUUID=`blkid $SWAP -s UUID -o value` + sed -i -e "s~root=/dev/~resume=/dev/disk/by-uuid/${SWAPUUID} root=/dev/~g" ${grub_cfg}.new + fi +fi + if test "x${grub_cfg}" != "x" ; then if ! ${grub_script_check} ${grub_cfg}.new; then echo "Syntax errors are detected in generated GRUB config file." >&2