--- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -78,6 +78,7 @@ echo " --evms Include EVMS support" echo " --> 'emerge evms' in the host operating system" echo " first" + echo " --suspend Include Suspend2 support" echo " --lvm Include LVM support" echo " --mdadm Include MDADM/MDMON support" echo " --mdadm-config= Use file as mdadm.conf in initramfs" @@ -234,6 +235,10 @@ echo print_warning 1 "Please use --evms, as --evms2 is deprecated." ;; + --suspend) + CMD_SUSPEND=1 + print_info 2 "CMD_SUSPEND: ${CMD_SUSPEND}" + ;; --lvm) CMD_LVM=1 print_info 2 "CMD_LVM: ${CMD_LVM}" --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -107,6 +107,7 @@ set_config_with_override 1 SYMLINK CMD_SYMLINK set_config_with_override 2 INSTALL_MOD_PATH CMD_INSTALL_MOD_PATH set_config_with_override 1 OLDCONFIG CMD_OLDCONFIG + set_config_with_override 1 SUSPEND CMD_SUSPEND set_config_with_override 1 LVM CMD_LVM set_config_with_override 1 EVMS CMD_EVMS set_config_with_override 1 DMRAID CMD_DMRAID --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -117,24 +117,24 @@ rm -rf "${TEMP}/initramfs-unionfs-fuse-temp" > /dev/null } -#append_suspend(){ -# if [ -d "${TEMP}/initramfs-suspend-temp" ]; -# then -# rm -r "${TEMP}/initramfs-suspend-temp/" -# fi -# print_info 1 'SUSPEND: Adding support (compiling binaries)...' -# compile_suspend -# mkdir -p "${TEMP}/initramfs-suspend-temp/" -# /bin/tar -jxpf "${SUSPEND_BINCACHE}" -C "${TEMP}/initramfs-suspend-temp" || -# gen_die "Could not extract suspend binary cache!" -# mkdir -p "${TEMP}/initramfs-suspend-temp/etc" -# cp -f /etc/suspend.conf "${TEMP}/initramfs-suspend-temp/etc" || -# gen_die 'Could not copy /etc/suspend.conf' -# cd "${TEMP}/initramfs-suspend-temp/" -# find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \ -# || gen_die "compressing suspend cpio" -# rm -r "${TEMP}/initramfs-suspend-temp/" -#} +append_suspend(){ + if [ -d "${TEMP}/initramfs-suspend-temp" ]; + then + rm -r "${TEMP}/initramfs-suspend-temp/" + fi + print_info 1 ' Copying /etc/suspend.conf...' + mkdir -p "${TEMP}/initramfs-suspend-temp/etc" + cp -f /etc/suspend.conf "${TEMP}/initramfs-suspend-temp/etc" || + gen_die 'Could not copy /etc/suspend.conf' + mkdir "${TEMP}/initramfs-suspend-temp/bin" + print_info 1 ' Copying /usr/lib/suspend/resume...' + cp -f /usr/lib/suspend/resume "${TEMP}/initramfs-suspend-temp/bin" || + gen_die 'Could not copy /usr/lib/suspend/resume' + cd "${TEMP}/initramfs-suspend-temp/" + find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \ + || gen_die "compressing suspend cpio" + rm -r "${TEMP}/initramfs-suspend-temp/" +} append_multipath(){ if [ -d "${TEMP}/initramfs-multipath-temp" ] @@ -674,6 +674,7 @@ append_data 'auxilary' "${BUSYBOX}" append_data 'busybox' "${BUSYBOX}" append_data 'lvm' "${LVM}" + append_data 'suspend' "${SUSPEND}" append_data 'dmraid' "${DMRAID}" append_data 'iscsi' "${ISCSI}" append_data 'evms' "${EVMS}" --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -1020,7 +1020,17 @@ swsusp_resume() { # determine swap resume partition local device=$(ls -lL "${REAL_RESUME}" | sed 's/\ */ /g' | cut -d \ -f 5-6 | sed 's/,\ */:/') - [ -f /sys/power/resume ] && echo "${device}" > /sys/power/resume + if [ -f /sys/power/resume ]; then + which resume > /dev/null 2>&1 || return + local args + local features="$(resume --version | grep FEATURES)" + [ -n "${REAL_RESUME}" ] && args="${args} --resume_device=\"${REAL_RESUME}\"" + if ! grep suspend_noui /proc/cmdline > /dev/null 2>&1; then + echo "${features}" | grep "fbsplash" > /dev/null && grep "splash=" /proc/cmdline > /dev/null && args="${args} --parameter=\"splash=y\"" + fi + [ -c /dev/snapshot ] || mknod /dev/snapshot c 10 231 + eval resume ${args} -f /etc/suspend.conf + fi } tuxonice_resume() {