# Hibernate (pm-utils) immediately restarts [SOLVED]

## kai.scorpio

Hi all,

I cannot hibernate my laptop, running pm-hibernate seems to hibernate correctly (HDD light flashing, screen off), but then it switches right back on without me touching anything. pm-suspend works fine, it suspends to RAM correctly. I am using gentoo-sources kernel with pm-utils (and KDE). I've found the following suspicious lines in /var/log/pm-suspend.log

```

/usr/lib64/pm-utils/sleep.d/99video hibernate hibernate: success.

Mon Nov 19 17:18:38 GMT 2012: performing hibernate

/usr/lib64/pm-utils/pm-functions: line 316: echo: write error: No such device

Mon Nov 19 17:18:59 GMT 2012: Awake.

Mon Nov 19 17:18:59 GMT 2012: Running hooks for thaw

Running hook /usr/lib64/pm-utils/sleep.d/99video thaw hibernate:

```

I've checked in pm-functions, and this line is

```
echo -n "disk" > /sys/power/state
```

/sys/power/state does exist, and it contains "mem disk".

Does anybody have any idea how to fix this?

KaiLast edited by kai.scorpio on Tue Nov 27, 2012 11:10 am; edited 1 time in total

----------

## Hu

Does your system fail to save state to disk or does it fail to halt after the state is saved?  If the former, then hibernation does not work at all.  If the latter, then the machine is rebooting and resuming when it should have halted.  Based on the error log you provided, it looks like the system does not save state to disk.  Based on your description, it sounds like the machine reboots and resumes.

What is the output of emerge --info?  Are you sure you included in the kernel the required functionality for hibernation?

----------

## kai.scorpio

Sorry for being light on the details, that is about all I can figure out. What are the necessary config files I should be watching? My kernel .config is here http://pastebin.com/cWVc6cRR, and I think I've set all the necessary options found in various linux hibernation guides. I *think* it is writing to disk, since I get a lot of hard disk activity before and after, but I am not sure what else I could check.

Below is emerge --info:

```

Portage 2.1.11.31 (default/linux/amd64/10.0/desktop/kde, gcc-4.5.4, glibc-2.15-r3, 3.5.7-gentoo x86_64)

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

System uname: Linux-3.5.7-gentoo-x86_64-Intel-R-_Core-TM-2_Duo_CPU_P8600_@_2.40GHz-with-gentoo-2.1

Timestamp of tree: Mon, 19 Nov 2012 10:00:01 +0000

ld GNU ld (GNU Binutils) 2.22

app-shells/bash:          4.2_p37

dev-java/java-config:     2.1.11-r3

dev-lang/python:          2.7.3-r2, 3.2.3-r1, 3.3.0

dev-util/cmake:           2.8.9

dev-util/pkgconfig:       0.27.1

sys-apps/baselayout:      2.1-r1

sys-apps/openrc:          0.9.8.4

sys-apps/sandbox:         2.5

sys-devel/autoconf:       2.68

sys-devel/automake:       1.11.6

sys-devel/binutils:       2.22-r1

sys-devel/gcc:            4.5.4

sys-devel/gcc-config:     1.7.3

sys-devel/libtool:        2.4-r1

sys-devel/make:           3.82-r3

sys-kernel/linux-headers: 3.4-r2 (virtual/os-headers)

sys-libs/glibc:           2.15-r3

Repositories: gentoo sunrise kde jtriley x-portage

ACCEPT_KEYWORDS="amd64"

ACCEPT_LICENSE="* -@EULA dlj-1.1"

CBUILD="x86_64-pc-linux-gnu"

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

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0"

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/sandbox.d /etc/terminfo"

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

DISTDIR="/usr/portage/distfiles"

EMERGE_DEFAULT_OPTS=" --usepkg-exclude virtual/* --usepkg-exclude sys-kernel/* --usepkg-exclude app-emulation/emul-linux-* --usepkg-exclude oxygen-icons --usepkg-exclude media-fonts/* --usepkg-exclude kde-wallpapers --usepkg-exclude spotify --usepkg-exclude adobe-flash --usepkg-exclude dev-java/icedtea-bin"

FCFLAGS="-O2 -pipe"

FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles getbinpkg merge-sync news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"

FFLAGS="-O2 -pipe"

GENTOO_MIRRORS="http://mirror.qubenet.net/mirror/gentoo/ ftp://mirror.qubenet.net/mirror/gentoo/ ftp://ftp.mirrorservice.org/sites/www.ibiblio.org/gentoo/"

LANG="en_GB.UTF-8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_EXTRA_OPTS="-e 'ssh -p 3022'"

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

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/var/lib/layman/sunrise /var/lib/layman/kde /var/lib/layman/jtriley /usr/local/portage"

SYNC="ssh://kai@kwohlfahrt.crabdance.com/usr/portage"

USE="X a52 aac acl acpi alsa amd64 avahi berkdb bluetooth branding bzip2 cairo cdda cdr cli consolekit cracklib crypt cups cxx dbus declarative dri dts dvd dvdr emboss encode exif fam firefox flac fortran gdbm gif gpm iconv ipv6 jpeg kde kipi lcms ldap libnotify mad mmx mng modules mp3 mp4 mpeg mudflap multilib ncurses nls nptl ogg opengl openmp pam pango pcre pdf phonon plasma png pni policykit ppds pppd pulseaudio qt3support qt4 readline samba sdl semantic-desktop session spell sse sse2 sse3 ssl ssse3 startup-notification svg symlink tcpd tiff truetype udev udisks unicode upower usb vorbis wxwidgets x264 xcb xcomposite xinerama xml xscreensaver xv xvid zeroconf zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci 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 mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd 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 cgi cgid 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" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" DRACUT_MODULES="plymouth caps" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev wacom" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" PHP_TARGETS="php5-3" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="nouveau nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, USE_PYTHON

```

----------

## Hu

Does the kernel print anything to dmesg when you attempt to hibernate?

----------

## kai.scorpio

No, there is nothing on dmesg after hibernate. There is nothing after a sleep either, but that works correctly. Again, pastebin to a dmesg from a restart, followed by hibernate, followed by sleep here: http://pastebin.com/h3uEjiED

Kai

----------

## Hu

What is the output of free -m?  Have you checked whether a bare hibernate works correctly?

----------

## kai.scorpio

free -m:

```

             total       used       free     shared    buffers     cached

Mem:          3955       2299       1656          0        263        936

-/+ buffers/cache:       1099       2856

Swap:         4095          0       4095

```

What do you mean by 'bare hibernate'? I'll try it as soon as I know  :Smile: 

EDIT: I read a post that says swap must be 2*ram size, rather than just larger than ram size. I've done that, but still no luck. Free now says:

```

kai-laptop ~ # free -m

             total       used       free     shared    buffers     cached

Mem:          3955        716       3239          0          4        136

-/+ buffers/cache:        575       3379

Swap:         8191        956       7235

```

Last edited by kai.scorpio on Thu Nov 22, 2012 11:19 am; edited 1 time in total

----------

## toralf

What happens if you make a simple 

```
echo disk > /sys/power/state
```

as root ?Maybe before that you mshould make a 

```
echo 0 > /sys/power/image_size
```

as root.

----------

## kai.scorpio

Right, here's what happened:

```

kai-laptop ~ # cat /sys/power/image_size 

1657577472

kai-laptop ~ # cat /sys/power/state 

mem disk

kai-laptop ~ # echo disk > /sys/power/state 

echo: write error: no such device

```

At this point the system does the usual 'hibernate' - screen turns off, HDD light flashes for a while, CD drive makes some noise (it is empty) and then I'm back to my desktop (not locked, I'm assuming that's normally a KDE thing).

```

kai-laptop ~ # echo 0 > /sys/power/image_size 

kai-laptop ~ # echo disk > /sys/power/state 

echo: write error: no such device

```

This does the same, but the whole process takes somewhat longer (i.e. screen turns off, but takes longer to come back on, and then the desktop is frozen for a bit while the HDD light is on).

Any ideas? Thanks for the help so far!

Kai

----------

## toralf

And your kernel is configured for hibernation ?

```
tfoerste@n22 ~ $ zgrep CONFIG_PM_STD_PARTITION /proc/config.gz 

CONFIG_PM_STD_PARTITION="/dev/sdb2"

```

and the swap partition (which is used for that) isn't encrypted ?

----------

## kai.scorpio

My .config is posted earlier somewhere, here's the relevant line:

```

kai@kai-laptop ~ % grep CONFIG_PM_STD_PARTITION /usr/src/linux/.config

CONFIG_PM_STD_PARTITION=""

```

I have a swap file rather than a swap partition, what should I set here for this?

Kai

----------

## toralf

the swap partition

----------

## kai.scorpio

I do not have a separate swap partition. I have a swap file that is at /swapfile

Here is my /etc/fstab:

```

/dev/sda2               /boot           ext2            noauto,noatime  1 2

/dev/sda6               /               ext4            noatime         0 1

/swapfile               none            swap            sw,loop         0 0

/dev/cdrom              /mnt/cdrom      auto            noauto,ro       0 0

```

Kai

----------

## toralf

AFAIK you need a separate partition of type "Linux swap" to use s2disk.

----------

## kai.scorpio

Ah, I didn't realize that. Any chance the fancy tuxonice things will be merged into gentoo-sources? That'd be nice  :Smile: 

Meanwhile, hibernate is now working, thanks (minus some residual KDE weirdness on resume). Sorry to cause so much trouble with that, I didn't realize it wasn't supported.

Kai

----------

## ppurka

 *kai.scorpio wrote:*   

> Ah, I didn't realize that. Any chance the fancy tuxonice things will be merged into gentoo-sources? That'd be nice 

 I doubt it will ever be merged into the kernel. Lots of politics.   :Evil or Very Mad: 

----------

