[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
howtos:slackware_admin:swapfile_hibernation [2012/12/01 13:31 (UTC)] – [Sources] fl0howtos:slackware_admin:swapfile_hibernation [2012/12/01 14:26 (UTC)] – [Sources] fl0
Line 32: Line 32:
    append="vt.default_utf8=1 resume=/dev/cryptslack/root resume_offset=1134591"    append="vt.default_utf8=1 resume=/dev/cryptslack/root resume_offset=1134591"
  
-    
 You need to patch the initrd to recognize the resume_offset parameter You need to patch the initrd to recognize the resume_offset parameter
 +<file patch init-swapfile.patch>
 +--- init.orig   2012-12-01 14:03:39.344538490 +0100                                                                                                            
 ++++ init        2012-12-01 14:01:12.526373970 +0100                                                                                                            
 +@@ -69,6 +69,7 @@                                                                                                                                              
 + LUKSDEV=$(cat /luksdev)                                                                                                                                       
 + LUKSKEY=$(cat /lukskey)                                                                                                                                       
 + RESUMEDEV=$(cat /resumedev)                                                                                                                                   
 ++RESOFFSET=$(cat /resoffset)                                                                                                                                   
 + WAIT=$(cat /wait-for-root)                                                                                                                                    
 + KEYMAP=$(cat /keymap)                                                                                                                                         
 + INIT=/sbin/init                                                                                                                                               
 +@@ -269,18 +270,35 @@
 +     umount -l /mountkey
 +     rmdir /mountkey 2>/dev/null
 +   fi
 +-  
 +-  # Resume state from swap
 +-  if [ "$RESUMEDEV" != "" ]; then
 +-    if ls -l $RESUMEDEV | grep -q "^l" ; then
 +-      #RESUMEDEV=$(ls -l $RESUMEDEV | awk '{ print $NF }')
 +-      RESUMEDEV=$(readlink -f $RESUMEDEV)
 +-    fi
 +-    echo "Trying to resume from $RESUMEDEV"
 +-    RESMAJMIN=$(ls -l $RESUMEDEV | tr , : | awk '{ print $5$6 }')
 +-    echo $RESMAJMIN > /sys/power/resume
 +-  fi
 +-
 +
 ++if [ "$RESUMEDEV" != "" ]; then
 ++       # be lvm aware
 ++        RESUMEDEV=$(readlink -f ${RESUMEDEV} | awk -F '/' '{ print $3 }')
 ++       if [ -r "/sys/class/block/${RESUMEDEV}/dev" ] ; then
 ++       # try sysfs 
 ++               read RESMAJMIN < "/sys/class/block/${RESUMEDEV}/dev"
 ++       elif [ -r "/proc/partitions" ] ; then
 ++       # otherwise run through /proc/partitions
 ++               while read m n b d jnk ; do
 ++                       if [ "$d" = "${RESUMEDEV}" ] ; then
 ++                               RESMAJMIN="$m:$n"
 ++                               break
 ++                       fi
 ++               done < "/proc/partitions"
 ++               fi
 ++       if [ -z "${RESMAJMIN}" ] ; then
 ++               # Device does not exist (not found in /proc/partitions)
 ++               exit 99
 ++       fi
 ++
 ++       if [ -n "${RESOFFSET}" ]; then
 ++                echo "Try resume from ${RESMAJMIN}:${RESOFFSET}"
 ++               echo "${RESMAJMIN}:${RESOFFSET}" > /sys/power/resume
 ++       else
 ++               echo "${RESMAJMIN}" > /sys/power/resume
 ++       fi
 ++fi
 +
 +</file>
  
   mkdir patched_initrd   mkdir patched_initrd
Line 45: Line 101:
   find . -print0 | cpio -ov -0 --format=newc | gzip -9 > /boot/initrd-swapfile.gz   find . -print0 | cpio -ov -0 --format=newc | gzip -9 > /boot/initrd-swapfile.gz
  
-<note>i recommend you to test this initrd first with another bootentry</note>+<note>i recommend to test this initrd first with another bootentry</note>
   image = /boot/vmlinuz   image = /boot/vmlinuz
   initrd = /boot/initrd-swapfile.gz   initrd = /boot/initrd-swapfile.gz
Line 60: Line 116:
    
 ====== Sources ====== ====== Sources ======
-Arch Linux Wiki: [[https://wiki.archlinux.org/index.php/Swap]]+* [[https://wiki.archlinux.org/index.php/Swap]] 
 + 
 +* [[https://answers.launchpad.net/ubuntu/+source/initramfs-tools/+question/193862]] 
  
 * Originally written by [[wiki:user:fl0]] * Originally written by [[wiki:user:fl0]]
 howtos:slackware_admin:swapfile_hibernation ()