#!/bin/sh # Put this script in /etc/mkinitrd/scripts/ and regenerate your initrd (by # "mkinitrd -o /boot/initrd.img-`uname -r`" or reinstall your kernel package. # as the script will be executed by "run-parts", you will have to follow some rules: # - the name may not contain special characters (e.g. a dot!) # - the script has to be executable (chmod +x ...) # - check "man run-parts" for details ... # Figure out the right /proc directory # (depends on the current version of suspend2) PROC_DIR=/proc/software_suspend [ -d "$PROC_DIR" ] || PROC_DIR=/sys/power/suspend2 # Figure out swap device from the first device listed in /proc/swaps swap_device=`awk 'BEGIN{getline;getline;print$1}' < /proc/swaps` swap_type=`awk 'BEGIN{getline;getline;print$2}' < /proc/swaps` if [ "x$swap_type" = "xpartition" ] ; then # use the device identifier instead the the device name (/dev/hda1 -> 0301) # otherwise you would have to create the device inside of the initrd resume2=`perl -e "@a=stat '$swap_device';printf 'swap:%04x', \\$a[6]"` else echo "Unable to determine swap device! You will need to set resume2= on your" echo "kernel command-line manually." fi [ -n "$resume2" ] && resume2="echo $resume2 > $PROC_DIR/resume2" # Modify linuxrc script mv $INITRDDIR/linuxrc $INITRDDIR/linuxrc.real cat < $INITRDDIR/linuxrc #!/bin/sh export PATH=/sbin:/bin mount -t proc proc /proc . /loadmodules $resume2 echo > $PROC_DIR/do_resume umount /proc . ./linuxrc.real EOT chmod 777 $INITRDDIR/linuxrc