View previous topic :: View next topic |
Author |
Message |
klz n00b
Joined: 07 Jun 2011 Posts: 42
|
Posted: Sat Jun 01, 2013 1:38 pm Post subject: HOWTO Hibernation with custom initrd, luks and swapfile |
|
|
Hello,
It took me a while to figure out how to succesfully thaw (hibernate) from a swapfile on an encrypted root partition with a custom initramfs; i couldnt find a complete set of instructions anywhere.
The hard part was finding the instructions how to change the init file for the initramfs (i dont use genkernel).
This website was the key for me.
We need to get the Major:Minor of the blockdevice the swapfile resides on, and then echo this to /sys/power/resume
Here is the relevant part of my /usr/src/initramfs/init
Code: | #msg 'Getting the resume partition from kernel commandline options..'
for x in `cat /proc/cmdline`
do
case ${x} in
resume=*) RESUMEDEV=${x#resume=} ;;
*) continue ;;
esac
done
# Getting "dm-0" (the file the resumeparition links to, for me this is /dev/dm-0, and then stripping it of /dev/)
RESUMEDEV=$(readlink -f ${RESUMEDEV} | awk -F '/' '{ print $3 }')
#msg 'Getting Major/Minor number of resume device'
RESMAJMIN=$(cat /sys/class/block/${RESUMEDEV}/dev)
|
And then just before switchting root: Code: | msg "Echo-ing $RESMAJMIN to /sys/power/resume (so we can thaw-hibernate)"
echo $RESMAJMIN > /sys/power/resume
|
My kernel line in grub: Code: | kernel /boot/kernel-3.9.4-rev3 cryptdevice=/dev/sda5:root resume=/dev/mapper/root resume_offset=3115008
|
To get the resume_offset look at the link i posted above.
Hopefully this helps somebody
Last edited by klz on Mon Jun 03, 2013 4:33 pm; edited 1 time in total |
|
Back to top |
|
|
SlashBeast Retired Dev
Joined: 23 May 2006 Posts: 2922
|
Posted: Sun Jun 02, 2013 7:34 am Post subject: |
|
|
Isn't the resume offset used only by kernel? I am pretty sure you don't have to parse it in script at all. I am almost 100% sure that I used swapfile and didn't needed to echo it.
also nice way to get the major:minor, I use stat %T %t and printf to convert it to decimal and not sure if I had reason to do it as-is.
anyway, why you parse the offset, you do echo it somewhere? I used tuxonice, uswsusp and swsusp for a long time, always with encrypted devices and quite often with swap files with no problems. |
|
Back to top |
|
|
klz n00b
Joined: 07 Jun 2011 Posts: 42
|
Posted: Mon Jun 03, 2013 4:32 pm Post subject: |
|
|
Hehe yeah resume offset is indeed not needed in initrd, thats why the lines are commented out...
maybe i shouldve just deleted those lines (?)
actually i will delete this
Code: | # We dont seem to need to resume offset in ramfs/initrd having it on the kernel-cmdline is enough
# resume_offset=*) RESOFFSET=${x#resume_offset=} ;; |
from the first post |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|