# Unable to resume from disk (and from ram, too).

## erikderzweite

Hello,

I have following problem when I try to suspend my laptop to disk: suspending works, but resuming not. If I try hibernate script, I get the following error: suspend: could not stat the resume device file

echo "disk" > /sys/power/state or s2disk suspend fine. But if I try to resume, I'll simply start over. My swap partition is also screwed afterwards — swapon /dev/hda6 returns Illegal argument. In dmesg I see: unable to find swap-space signature

The machine is an Acer Travelmate 243L with intel chipset, intel video and intel-p4-mobile CPU using gentoo-sources-2.6.22-r9 (I'll post my lspci, dmesg and .config if needed).

Upd. The suspend to disk is working with suspend2-sources-2.6.22-r2 and hibernate.

This problem may be related to another one - I am unable to resume from ram although the hardware is capable of doing so - Mandriva LiveCD 2008 resumes from echo "mem" > /sys/power/state just fine. Gentoo LiveCD does not. On my current Gentoo installation neither echo "mem" > /sys/power/state nor s2ram -f nor hibernate-ram work. I've tried to play with different setting in hibernate-script (vbetool etc.), tried to disable X, unplug all peripherals or unload some modules - useless. Are there any generic tips about resuming? How exactly do I debug the whole issue? There was something about using the system clock but I've never figured it out.

----------

## eitan1989

I haven't tried most of that stuff, but I'm getting the same problem when I use s2disk - it runs fine, but then I turn the computer back on and it boots cold like it had been shutdown, and it has that same line in dmesg about the swap-space signature.

----------

## acidlog

Hello,

i get the same problem with s2disk. i use 2.6.24 gentoo-sources. dmesg says: unable to find swap-space signature 

when i use s2ram i dont have problems but with the s2disk always my swap partition is destroyed.

is there any solution to the problem?

thanks

----------

## erikderzweite

Well, I gave up using s2disk (my BIOS isn't supported anyway) and started using tuxonice-sources.

----------

## Chewi

I've traditionally always used tuxonice/suspend2 but I found that uswsusp actually worked very well on my new machine so I thought I'd give it a shot. It's faster and doesn't require me to unload a bunch of stuff. It's not very well documented but because s2disk operates in userspace, it requires an initrd or initramfs. It can be made to work without one but apparently it's very dangerous. Creating an initramfs tends to be a bit of a mystery for Gentoo users because they're not used as standard like on some other distributions. When they are used, they're usually created automatically by something like genkernel or splash_geninitramfs. splash_geninitramfs can overlay some additional files and I use splash anyway so I used that for creating mine. This is what you do. Create a file structure like the following...

```
bin

bin/busybox (copy the STATIC version from /bin)

bin/resume (copy this from /usr/lib/suspend)

dev

dev/snapshot (copy this from /dev)

etc

etc/suspend.conf (copy this from /etc)

init
```

Both your copies of suspend.conf should look something like this.

```
snapshot device = /dev/snapshot

resume device = /dev/sda7
```

init is a simple script I cooked up. It's where the magic happens.

```
#!/bin/busybox ash

local X ROOT RUNLEVEL

# Preliminary stuff.

mkdir -p /proc /sys /mnt

mount -t proc proc /proc

mount -t sysfs sysfs /sys

mdev -s

# Try to resume. This never returns if it succeeds.

resume

# Parse the command line for relevant options.

for X in `cat /proc/cmdline`

do

        case "$X" in

                root=*) ROOT=${X#root=} ;;

                [0-6Ss]) RUNLEVEL=${X} ;;

        esac

done

# Mount and switch root.

mount -o ro ${ROOT} /mnt

umount -f /sys  || umount -l /sys

umount -f /proc || umount -l /proc

exec switch_root /mnt /sbin/init ${RUNLEVEL}
```

Make sure that init, busybox and resume are all executable. Then do something like this...

```
splash_geninitramfs -o /path/to/structure --no8bpp -r 1280x1024 -g /boot/fbsplash livecd-2007.0
```

If you're using splash then you'll already have a line like "initrd /boot/fbsplash" in grub.conf so you shouldn't need to change that. If you're not using splash, the procedure is similar, you just need to generate the initramfs image by hand.

----------

## Chewi

I should add that you don't need a resume= line in your kernel parameters. Despite what it says in menuconfig, as far as I can tell, it isn't used by uswsusp. It gets the device from /etc/suspend.conf instead.

It's also worth noting that none of this conflicts with uvesafb even though that uses an initramfs as well. This is the case when the image is built into the kernel, at least. I'm not sure exactly how multiple initramfs images work with each other but it works for me somehow!

----------

## Chewi

Heh knew someone would ask. The magic incantation needed to make an image if you're not using splash is as follows. I nabbed it from splash_geninitramfs.

```
cd /path/to/structure && find . | cpio --quiet -o -H newc | gzip -9 >../image
```

----------

## bbroeksema

Err. No luck for me. I tried to do it with the last command you gave but i get a kernel panic:

```
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
```

I exactly followed the above instructions:

```
ls -R ~/work/initramfs/

/root/work/initramfs/:

bin  dev  etc  init

/root/work/initramfs/bin:

busybox  resume

/root/work/initramfs/dev:

snapshot

/root/work/initramfs/etc:

suspend.conf
```

```
cat work/initramfs/init

#!/bin/busybox ash

local X ROOT RUNLEVEL

# Preliminary stuff.

mkdir -p /proc /sys /mnt

mount -t proc proc /proc

mount -t sysfs sysfs /sys

mdev -s

# Try to resume. This never returns if it succeeds.

resume

# Parse the command line for relevant options.

for X in `cat /proc/cmdline`

do

  case "$X" in

    root=*) ROOT=${X#root=} ;;

    [0-6Ss]) RUNLEVEL=${X} ;;

  esac

done

# Mount and switch root.

mount -o ro ${ROOT} /mnt

umount -f /sys  || umount -l /sys

umount -f /proc || umount -l /proc

exec switch_root /mnt /sbin/init ${RUNLEVEL}
```

```
ls -la work/initramfs/init

-rwxr-xr-x 1 root root 541 2008-03-21 14:15 work/initramfs/init
```

And this is what I have in my /boot/grub.conf

```
title=Gentoo Linux 2.6.24-gentoo-r3

root (hd0,4)

kernel /boot/kernel-2.6.24-gentoo-r3 root=/dev/hda6 video=uvesafb:1024x768-24,mtrr:3,ywrap

initrd /boot/image
```

I've also put the image online at: http://bertjan.broeksemaatjes.nl/node/7. Any idea what I'm doing wrong?

----------

## Chewi

As I suspected, the busybox binary you used isn't static. I actually thought that emerging busybox without the static USE flag enabled installed both a dynamic AND a static version. I've just found that this is not the case. It's very confusing because it still installs a symlink called /bin/busybox.static that points to the dynamic version. A dynamic version of busybox isn't very useful unless you're building an embedded system. In short, you need to enable the static USE flag for busybox by adding "sys-apps/busybox static" to /etc/portage/package.use. Whatever you do, don't enable the static USE flag globally.

----------

## bbroeksema

Almost there. Using a static busybox seems to help indeed. However now i do see that it's loading the image but after that it still does a normal boot. Resulting in a messed up and not mounted swap partition. I don't know what information would be usefull now. So the resume command seems to load correctly the image but then still bails out for some reason.

----------

## Chewi

Hmm. Did you fix your swap partition from the last time it broke? If you want to try and diagnose the problem, comment out everything in the script from resume downwards. Make sure you have some other way of booting, maybe make two GRUB entries unless you know how to edit GRUB on the fly. You'll be dumped to a busybox shell with access to some basic commands. Try running resume and see what happens.

----------

## bbroeksema

I tried to comment out everything from resume but then the system won't even boot. I get a kernelpanic which says:

```
Kernel panic - not syncing: Attempted to kill init
```

init:

```
#!/bin/busybox ash

local X ROOT RUNLEVEL

# Preliminary stuff.

mkdir -p /proc /sys /mnt

mount -t proc proc /proc

mount -t sysfs sysfs /sys

mdev -s

# Try to resume. This never returns if it succeeds.

#resume

# Parse the command line for relevant options.

#for X in `cat /proc/cmdline`

#do

#  case "$X" in

#    root=*) ROOT=${X#root=} ;;

#    [0-6Ss]) RUNLEVEL=${X} ;;

#  esac

#done

# Mount and switch root.

#mount -o ro ${ROOT} /mnt

#umount -f /sys  || umount -l /sys

#umount -f /proc || umount -l /proc

#exec switch_root /mnt /sbin/init ${RUNLEVEL}
```

----------

## Chewi

Oh sorry, that was bad advice, didn't fully think that through. For some reason, I got it into my head that it would drop you to a shell after finishing the script. You can add "exec ash" to the end though and that should work.

----------

## bbroeksema

doh, i've could come up myself with that :S.

bbroeksema tries again.

----------

## bbroeksema

Okay, finally found some time to try it out. This are the messages when I boot and try resume from the ash shell. It also contains some error message I get before entering any command.

```
ash: can't access tty; job control turned off

/ # Clocksource tsc unstable (delta = -284889390 ns)

/ # resume

Loading image data pages (34595 pages)... 100% done

wrote 135.1 MB in 3.9 seconds (34.9 MB/s)

read 135.1 MB in 2.9 seconds (46.6 MB/s)

total image i/o 270.3 MB in 6.8 seconds (39.9 MB/s)

resume: Image successfully loaded

resume: Could not freeze processes

/ #
```

And then it does just plain nothing. Even when i type resume again it does nothing.

----------

## Chewi

Hmm. Don't think I can help you there. Presumably you have the right option enabled in the kernel. Maybe try a newer kernel.

Regarding the clock source, you should enable the HPET timer option in the kernel, unless your machine is really old.

----------

## bbroeksema

Hmm too bad. And there doesn't seem to be anyone else overhere who got this working. Btw i have HPET timer enabled in the kernel and latest stable kernel:

```
calvin linux # uname -r

2.6.24-gentoo-r3
```

I have the presumtion that resume isn't able to freeze the processes because the job controll is turned of. Googling a bit on busybox and job control I get these results:

http://www.busybox.net/lists/busybox/2004-September/012511.html

I guess i have to run busybox in another console or something. If you've hints about that please let me know.

----------

## Chewi

I think you can disregard that job control message. I have console=tty1 in my kernel parameters because of splash, I don't know if that makes a difference there.

You might want to ensure that /dev/snapshot in your image really is a character device node.

```
root@symphony # ls -l /dev/snapshot

crw-rw---- 1 root root 10, 231 2008-03-21 11:32 /dev/snapshot
```

----------

## bbroeksema

chewi: Could you post your /etc/suspend.conf?

I have this:

```
calvin linux # cat ~/work/initramfs/etc/suspend.conf

#snapshot device = /dev/snapshot

resume device = /dev/hda1

#image size = 350000000

#suspend loglevel = 2

#compute checksum = y

#compress = y

#encrypt = y

#early writeout = y

#splash = y
```

/dev/snapshot is a character device when i'm normally booted. But when I'm in busybox it's not a character device:

```
-rw-r----- 1 root root 10, 231 2008-03-21 11:32 /dev/snapshot
```

----------

## Chewi

Mine is just...

```
snapshot device = /dev/snapshot

resume device = /dev/sda7
```

The broken character device is almost certainly the problem. I'm not sure how that happened. I checked the manual image creation method to check that doesn't break it. It doesn't. If you try to copy it with regular cp and no options, it fails with "no data available". You should copy it with "cp -a" but if you didn't do that then how DID you copy it?  :Confused: 

EDIT: Hmm I just noticed that even though the "no data available" message appears, a file still gets created. Maybe that's what happened.

----------

## bbroeksema

Weeeehooooooo thank you so much Chewi! = :Smile: 

It was indeed the snapshot which was not a character device. It's working like a charm right now. 

This post was from a resumed session   :Very Happy: 

----------

## Chewi

Hey glad it works.  :Very Happy:  Sorry, my original explanation should probably have been a bit more detailed.

----------

## bbroeksema

*sigh* still the same problem as with the tuxonice sources. The first time resume worked okay. But a second try gave me a X which keeps restarting or something leaving me with a totaly unusable system. I guess it has something todo with the i915 module.

----------

## Chewi

There are various options you can play with, both on s2disk itself and the hibernation scripts. Have a look at /etc/hibernate/common.conf in particular.

----------

## bbroeksema

Not using DRI seems to solve the problem..... so it seems that the choice is between graphical performance or being able to suspend. Taken the fact that it's a laptop and I've another nice pc I'll do it without DRI for now. However I keep finding it strange that it did work with suspend2 and DRI. However I'm going off topic  :Smile: 

----------

## Punchcutter

I found this thread because I'm having the exact problem described above.  I see that OP has switched to tuxonice.  Looking at the web site for tuxonice, it looks like it has a lot more features than the other (uswsusp), and is (perhaps?) more actively developed.  Should I just switch over to tuxonice? It makes me a tad uncomfortable to use a different set of kernel sources than gentoo-sources, but if that's what it takes to get this to work.  OP, did it start to Just Work(tm) for you when you switched?

I'd be happy to hear thoughts.

Thanks,

Dave

----------

## techiem2

I'm having the corrupted swap partition/not-resuming problem on my laptop using tuxonice-sources 2.6.25-r4.

When I run the hibernate script, it hibernates fine (at least so the log says), but when I turn the machine back on it boots normally but has a broken swap partition.

When I manually call the hibernate (echo disk > /sys/power/state), it does the same thing but actually shows the tuxoniceui as it suspends (whereas when I run hibernate it doesn't show).

Edit:

When I run hibernate -n, the messages in the log all appear to be successful (fake suspend and resume all successful), so it seems like it's not even trying to resume on boot.

----------

## Chewi

There seems to be some big misunderstandings about the key differences between tuxonice and uswsusp.

tuxonice is a purely software solution in that it writes the image to the hard drive and it is the kernel's job to resume from that image. uswsusp, on the other hand, relies heavily on the BIOS and ACPI, especially when suspending to RAM, which tuxonice cannot do. If you haven't seen it, suspending (and resuming) to RAM is blazingly fast. I use it when I'm leaving the machine for about 20-60 mins.

Because BIOS implementations have traditionally been very buggy, you are much more likely to have success with tuxonice. However, it seems that the BIOSes on newer machines are getting better now so uswsusp is well worth a try. The corrupt swap / not resuming problem is not related to uswsusp's reliablity. It's just a bitch to set up because it works in userspace! I believe this to be a good thing because it makes the kernel side of things much simpler - anything that can be done in userspace should be done in userspace. I imagine distros will make it easier to setup once it becomes more popular but if you keep trying now, you may well find that it works for you.

----------

## Gef

 *techiem2 wrote:*   

> I'm having the corrupted swap partition/not-resuming problem on my laptop using tuxonice-sources 2.6.25-r4.

 

I have exactly the same issue on my machine.

More detailled report :

- A first 2.6.24-tuxonice-r8 kernel was compiled with sys-kernel/genkernel-3.4.9 ; Hibernating done in swap. It all worked fine.

- A 2.6.25-tuxonice-r4 was compiled with sys-kernel/genkernel-3.4.10, and sys-kernel/genkernel-3.4.10-r1 ; Hibernating process works flawlessly, but reboot just ... reboot, no suspend. Nothing in logs. And this leads to a corrupted swap.

The problem can either come from Genkernel, or from Tuxonice-Sources.

However, I've just found this Very Interesting bug reported : https://bugs.gentoo.org/show_bug.cgi?id=220913

I will now try that and report in this topic.

edit : typo

----------

## Gef

Back with :

- a quite good news : Appending real_resume=/dev/sdaX to my grub kernel command line makes the resuming process working

- however, the resumed system (with X and nvidia driver resumed, not restarted or modprobed) freezes  every 3 to 4 seconds : the cpu is 99% busy on one or he other core.

- stopping X, re-modprobe nvidia module, and restarting X, and this issue is gone.

More to come, I hope.

# emerge --info

Portage 2.1.5.4 (default/linux/x86/2008.0/desktop, gcc-4.1.2, glibc-2.6.1-r0, 2.6.25-tuxonice-r4-low i686)

=================================================================

System uname: 2.6.25-tuxonice-r4-low i686 Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz

Timestamp of tree: Sat, 07 Jun 2008 14:16:01 +0000

ccache version 2.4 [enabled]

app-shells/bash:     3.2_p39

dev-java/java-config: 1.3.7, 2.1.6

dev-lang/python:     2.4.4-r13, 2.5.2-r4

dev-python/pycrypto: 2.0.1-r6

dev-util/ccache:     2.4-r7

sys-apps/baselayout: 2.0.0

sys-apps/openrc:     9999

sys-apps/sandbox:    1.2.18.1-r2

sys-devel/autoconf:  2.13, 2.62

sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1-r1

sys-devel/binutils:  2.18-r1

sys-devel/gcc-config: 1.4.0-r4

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.25-r3

ACCEPT_KEYWORDS="x86 ~x86"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=prescott -pipe -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo /etc/udev/rules.d"

CXXFLAGS="-O2 -march=prescott -pipe -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FEATURES="ccache collision-protect distlocks parallel-fetch sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://ftp.free.fr/mirrors/ftp.gentoo.org/ http://mirror.ovh.net/gentoo-distfiles/"

LANG="fr_FR.UTF-8"

LC_ALL="fr_FR.UTF-8"

LDFLAGS=""

LINGUAS="fr fr_FR"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/portage/local/zetaOverlay /usr/portage/local/layman/desktop-effects /usr/portage/local/layman/openrc /usr/portage/local/layman/mozilla /usr/portage/local/layman/wschlich-testing"

SYNC="rsync://rsync.fr.gentoo.org/gentoo-portage"

USE="X acl acpi alsa apm berkdb bluetooth branding bzip2 cairo cdr cli cracklib crypt dbus dri dvd dvdr dvdread eds emboss encode esd evo fam ffmpeg firefox fortran gdbm gif gpm gstreamer gtk hal hda-intel iconv isdnlog jpeg kerberos laptop ldap libnotify mad midi mikmod mp3 mpeg mudflap ncurses nls nptl nptlonly nvidia ogg opengl openmp pam pcre pdf perl png ppds pppd python qt3 qt3support qt4 quicktime readline reflection sdl session spell spl sse sse2 ssl ssse3 startup-notification svg tcpd tiff truetype unicode vorbis win32codecs x86 xml xorg xv zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="synaptics keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="fr fr_FR" USERLAND="GNU" VIDEO_CARDS="nvidia"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

----------

## Gef

Finaly I reverted back to sys-kernel/genkernel-3.4.9, but the freezes are still present after resume. So the problem may come from 2.6.25-r4 sources.

----------

