WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Hibernate troubleshooting  (Read 9369 times)

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Hibernate troubleshooting
« on: January 16, 2009, 07:30:36 PM »
I hope that Juanito will come and help with this one, too ...

Got s2ram working great. Now working on s2disk. I think I'm close - system goes down fine, but doesn't find the resume image on reboot.

I've basically just followed the howto from the suspend-0.8 source. I've created a new initrd containing the resume code, and I've joined that into tinycore.gz using cpio (process at the bottom of the page). So now I've got a new initrd called tinycore_with_resume.gz, and it boots up fine as a replacement initrd.

I've changed grub to boot tinycore_with_resume.gz off of my USB drive (sda1).

s2disk goes down fine - I use:
Code: [Select]
sudo mkswap /dev/hda5
sudo swapon /dev/hda5
sudo s2disk

No luck getting the resume image to boot, however. Can't get the new initrd to recognize it at all - there are no boot codes or anything even suggesting that it tried to find the resume image ...

I'll keep working at it. Any short advice? TIA :)


To make the new initrd (dirty, but effective):
Code: [Select]
#!/bin/sh
#tinycore.gz + resume-initrd = tinycore_with_resume.gz
#dentonlt.com - January 2009

#verbose:
set -x

#place to put the resume initrd
mkdir resume

#mount the resume-initrd:
sudo mount resume-initrd resume -o loop

#unzip tinycore:
cp tinycore.gz tinycorecopy.gz
gunzip tinycorecopy.gz

#make a directory for the old tinycore image:
mkdir tiny_old

#cpio it
cd tiny_old
sudo cpio -id < ../tinycorecopy

#now combine the two:
#copy only on this file system, recurse
cd ../resume
sudo cp -vRpx * ../tiny_old

#make a new initrd
cd ..
touch tinycore_with_resume
cd tiny_old
sudo find . | sudo cpio --create --format=newc > ../tinycore_with_resume

#zip up the new initrd
cd ..
gzip tinycore_with_resume

#done done =)

#cleanup:
#remove directories
sudo rm -rf tiny_old
sudo umount ./resume
rmdir resume
rm tinycorecopy
« Last Edit: January 16, 2009, 08:14:34 PM by dentonlt »

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: Hibernate troubleshooting
« Reply #1 on: January 16, 2009, 09:40:18 PM »

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Hibernate troubleshooting
« Reply #2 on: January 16, 2009, 10:17:27 PM »
hats said:
Quote
Does the resume= boot option apply? http://forum.tinycorelinux.net/index.php?topic=418.msg2823#msg2823

After adding the resume arg to my kernel line, TC didn't recognize my extension directory argument (tce=sda1/tiny/tce ...), and hibernate didn't seem to care it was there. I rebooted twice each time, to make sure that both s2disk and resume would have a chance to work with the code. I tried each of:

Code: [Select]
resume=/dev/hda5
resume=dev/hda5
resume=hda5

Here's my standard GRUB entry:

Code: [Select]
title TinyCore Linux
root (hd0,0)
kernel /tiny/bzImage tce=sda1/tiny/tce
initrd /tiny/tinycore_with_resume.gz

The BootPrompt-HowTo (http://tldp.org/HOWTO/BootPrompt-HOWTO.html) says resume= is supposed to identify a particular file, not just a device ... but that's an aging doc (2003), and I'm inclined to believe anyone who has found that boot code useful. Definitely worth trying, but no good for me.

Still trying other stuff.
« Last Edit: January 17, 2009, 01:43:05 AM by dentonlt »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Re: Hibernate troubleshooting
« Reply #3 on: January 17, 2009, 02:36:38 AM »
I hope that Juanito will come and help with this one, too ...

Sorry, but I boot tc from usb on a laptop with an ntfs hd, so I cannot test the resume from disk..

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Hibernate troubleshooting
« Reply #4 on: January 17, 2009, 03:14:01 AM »
Juanito - rats.

Have now gotten a very non-useful resume out of the system. There is some problem with how I joined the resume initrd into the existing tinycore.gz. Help still welcome as available ...

I booted as normal with:
Code: [Select]
title Tiny Core Linux
root (hd0,0)
kernel /tiny/bzImage tce=sda1/tiny/tce
initrd /tiny/tinycore.gz

Then saved a hibernate image:
Code: [Select]
#!/bin/sh

filetool.sh backup
sudo mkswap /dev/hda5
sudo swapon /dev/hda5
sudo s2disk

Then I rebooted, used GRUB to switch to the plain resume-initrd image as output by the suspend-0.8 installer script:
Code: [Select]
title Tiny Core Resume Test
root (hd0,0)
kernel /tiny/bzImage resume=/dev/hda5
initrd /tiny/resume-initrd_0.1

The kernel didn't find my suspend device in suspend.conf (dunno why?) so it prompted me. I gave it /dev/hda5, and it resumed great.

I'll review how I joined the initrd images and try to fix things up.

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: Hibernate troubleshooting
« Reply #5 on: January 17, 2009, 02:24:49 PM »
The link in my previous post suggests to boot with the resume= parameter (before suspend) as well.

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Hibernate troubleshooting
« Reply #6 on: January 19, 2009, 05:56:26 AM »
Yep - tried that. (I wasn't too clear above.)

Side-problem: When I use resume=, the kernel ignores my tce= arg. Any idea why using resume= would bash the tce= argument?

I'll have to look at the code ...

EDIT: (Jan 22 09)

I read the resume= handling code, and posted that finding at http://forum.tinycorelinux.net/index.php?topic=499.0.
I'm still working on the hibernate problem ... gradually improving. Help/ideas still welcome.
« Last Edit: February 06, 2009, 07:45:53 AM by dentonlt »

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Hibernate troubleshooting
« Reply #7 on: February 07, 2009, 03:31:38 AM »
After much research, I'm up and running. I'll gradually edit this to make it a thorough guide, then I'll copy it to the wiki. Damn, that took awhile ... but I sure learned a lot doing it. There's little risk as long as you keep an extra copy of your backup zip (mydata.tgz) and a spare, working iso or GRUB entry.

Here's what I learned:

Down sides:
  • resuming takes almost as long as reboot ... or maybe that's a compliment to the stock boot time!
  • no luck yet with compression. s2disk works fine, but resume can't find the image.

Summary follows, though this has only been tested by me (1.1rc2, 1.1rc3; Evo N410c laptop). Here's what works for me:

Rebuilding uswsusp
1. Get the source code from http://suspend.sourceforge.net/download.shtml
2. Get suspend.tce, and install/load that (you need the libx86 and liblazy libraries).
3. configure, make, make install. See the wiki about building extensions. The instructions below assume you built suspend-0.8 and installed it using DESTDIR=/tmp/package.

Unzip tinycore.gz (from the iso) and patch it
See the wiki about remastering. You'll need to know about cpio, tar, and advdef
1. Unpack your tinycore.gz (initrd). If you use a CD/ISO, you'll have to mount it and pull out tinycore.gz.
To unpack it, do something like:
Code: [Select]
cp /path/to/tinycore.gz /tmp/tinycore.gz
cd /tmp
mkdir extract
cd extract
sudo zcat /tmp/tinycore.gz | sudo cpio -i -H newc -d

2. Change/update /etc/tc-config. I have to run mkswap when a swap size isn't found. Based on tc-config from 1.1rc2, I had to:
Code: [Select]
--- /tmp/extract/etc/init.d/tc-config Sat Feb  7 19:26:57 2009
+++ /etc/init.d/tc-config Sat Feb  7 19:03:56 2009
@@ -388,12 +395,13 @@
   rm -f /etc/sysconfig/tc.resume 2>/dev/null
   RESUME=`basename $RESUME`
   SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
-  [ -z "$SWAP_SIZE" ] && /sbin/swapon /dev/"$RESUME" &&  SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
-  [ -z "$SWAP_SIZE" ] && exit 1
-  MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal/{print $2}')
+  [ -z "$SWAP_SIZE" ] && /sbin/mkswap /dev/"$RESUME" && /sbin/swapon /dev/"$RESUME" &&  SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
+  if [ -n "$SWAP_SIZE" ]; then
+ MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal/{print $2}')
   if [ $SWAP_SIZE -gt $MEM_SIZE ]; then
     grep -q disk /sys/power/state &&  echo "disk" > /etc/sysconfig/tc.resume
   fi 
+  fi
 fi
 
 if [ -n "$SECURE" ]; then

3. install the resume binary. You built it as part of the suspend-0.8 package (above). Should be something like:
Code: [Select]
cp /tmp/package/usr/local/sbin/suspend/resume/resume /tmp/extract/resume

4. install the snapshot device. Something like:
Code: [Select]
sudo mknod /tmp/extract/dev/snapshot c 10 231

5. The /etc/suspend.conf file (from the suspend-0.8 package you built) tells the s2disk and resume tools where to store your hibernate image. You need to edit that file, then install it to /etc/suspend.conf. In particular, edit the "resume device =" line. I recommend setting "image size = 0" as that minimizes the hibernate image. Takes more time going down, but seems to save a bit coming up. After you edit that, copy it to /tmp/extract/etc/:
Code: [Select]
cp /tmp/package/usr/etc/suspend.conf /tmp/extract/etc/suspend.conf

6. change /etc/inittab by adding on ::sysinit:/resume before ::sysinit:/init

7. pack up /tmp/extract into a new initrd. Again, see the wiki about remastering for details. Something like:
Code: [Select]
sudo find | sudo cpio -o -H newc | gzip -2 > "/tmp/tinycore_with_hibernate.gz"

8.Copy your patched initrd (tinycore_with_hibernate.gz) to your TC boot directory (wherever that is ...), or make a new ISO if you're doing that. Again, review the remastering howto at the wiki.

edit GRUB menu.lst
1. back up your old menu.lst (to menu.lst.old ... perhaps)
2. Add a stanza for your new tinycore_with_hibernate.gz initrd
3. Add kernel arg resume=/dev/[your swap drive]
4. save your new menu.lst

Test it out
1. reboot. If needed select your new initrd from the GRUB menu.
2. if you didn't already, you need to load pci-utils, suspend
3. check to see that your changes made it. You should have /etc/suspend.conf, /resume, your /etc/inittab should have changes, and your /etc/init.d/tc-config should be updated ...
4. cross your fingers and run sudo s2disk!

If it goes down fine ... restart your computer and see if resume picks up your image. If not, I suggest wrapping /resume in a script that calls resume then sh (/bin/sh is available at that time). Check to see if resume runs, if your /etc/suspend.conf files reads right, etc ...

Personally, I have:
  • a small wrapper for the resume binary (so my inittab calls that wrapper - it tells me when it looks for a resume image but doesn't find it
  • a short hibernate script/wrapper (it runs some pre-hibernate scripts, then calls s2disk, then runs post-resume scripts after coming back online)

To Do:
  • Fix the compression thing (it doesn't work)
  • Unload tcz extensions before hibernate, then reload on resume (script it)

Hope this helps! Good luck =D
« Last Edit: February 08, 2009, 05:11:54 AM by dentonlt »

Offline tobiaus

  • Suspended
  • Hero Member
  • *****
  • Posts: 599
Re: Hibernate troubleshooting
« Reply #8 on: February 12, 2009, 12:52:17 PM »
To Do:
  • Fix the compression thing (it doesn't work)

does it help to put sudo before gzip?[/list]

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Hibernate troubleshooting
« Reply #9 on: February 13, 2009, 01:45:07 AM »
Tobias: I wasn't too clear there. gzip is great  - no problem using that.

I have trouble restoring a compressed hibernate image. Compression is [optionally] built into the uswsusp. For me, s2disk does fine making a compressed image and shutting down the system. The resume binary doesn't recognize the compressed image on reboot, though.

Test timings

I'm running TC on a HP/Compaq Evo N410c laptop (1 gigahertz PIII, 512MB RAM, off the internal hard drive). For me, hibernate/restore occur roughly as fast as normal startup/shutdown times.
Con: increased risk on resume
Pro: ability to keep all my programs running from previous session

I usually don't need to keep my programs running ... so there's no real point to using it. If you're considering it, though, there's basically no boot/resume overhead on my own system.

Timings (me and a simple stopwatch ... obviously not high tech):

Running base+norestore, +pci-utils and suspend extensions:
 raw boot: 30 sec
 hibernate: 14 sec (30mb image)
 restore boot: 30 sec
 normal shutdown: 14 sec

Running a few tces, plus restoring backup:
 raw boot: 33 sec
 hibernate: 30 sec (150mb image)
 restore boot: 40 sec
 normal backup & shutdown: 17 sec

Running my normal list of tces (minefield, beaver, conky, etc), only conky running at time of hibernate:
 raw boot: 42 sec
 hibernate: 30 sec (160mb image)
 restore boot: 44 sec
 normal backup & shutdown: 30 sec (12 mb backup file)

Running my normal list of tces, minefield and epdfview running w/ content at time of hibernate:
 hibernate: 33 sec (170mb image0
 restore boot: 42 sec

Suspend times:
 suspend: 2 sec
 resume: 5 sec
« Last Edit: February 13, 2009, 03:47:28 AM by dentonlt »