# Userspace software suspend

## DMoL

Hello!

I'm trying to use suspend feature on my gentoo-box as described here: http://en.gentoo-wiki.com/wiki/Userspace_software_suspend.

The problem is that the system suspends, but does not resume: right after suspend I do normally load getoo as if after normal poweroff.

My dmesg' says:

```
[    3.270684] PM: Hibernation image not present or could not be loaded.

[    3.270750] registered taskstats version 1

[    3.276113]   Magic number: 3:996:986

[    3.281145] md: Waiting for all devices to be available before autodetect

[    3.285683] md: If you don't use raid, use raid=noautodetect

[    3.289236] md: Autodetecting RAID arrays.

[    3.291550] md: Scanned 0 and added 0 devices.

[    3.293843] md: autorun ...

[    3.296114] md: ... autorun DONE.

```

My swap partition is /dev/sda1 and my grub.conf snipplet:

```
title Gentoo Linux

root (hd0,2)

kernel /boot/kernel-2.6.x root=/dev/sda5 radeon.modeset=1 resume=swap:/dev/sda1 

```

I tried to create initramfs as prescribed (and modified grub string was 

```
kernel /boot/kernel-2.6.x root=/dev/sda5 radeon.modeset=1 resume=swap:/dev/sda1 initrd /initramfs.img
```

), but the result was the same. The initialization scripts for initramfs I took from the guide.

What I'm doing wrong? Is the initramfs necessary? 

Thanks for any help.

----------

## Hu

The URL you gave is not valid.  Did you mean Userspace software suspend?

I think the initramfs is not needed if your swap is not encrypted.  However, since you should never hibernate to unencrypted storage, I have not confirmed this.  According to Documentation/power/swsusp.txt, your resume= line should specify the partition on which the image is found.  You included leading junk text of swap:, which probably confused it.

We would need to see the init script for your initramfs to understand why it did not work.

----------

## DMoL

Thank you, Hu for your answer. 

1. Yes, the right URL as you specified.

2. I have removed "swap:" prefix from corresponding kernel command line, and now it says something different:

```
[    2.132665] PM: Checking hibernation image partition /dev/sda1

[    3.301968] PM: Hibernation image partition 8:1 present

[    3.301978] PM: Looking for hibernation image.

[    3.302461] PM: Image not found (code -22)

[    3.302468] PM: Hibernation image not present or could not be loaded.

```

If I do boot without initrd option at all after h2disk, it says the same.

My swap isn't  encrypted, but I use lvm... My disk is partioned as the following (from fstab):

```
/dev/sda3               /boot           ext2            noauto,noatime  1 2

/dev/sda5               /               jfs             rw              0 1

/dev/sda1               none            swap            sw              0 0

# Logical volumes

/dev/vg/usr   /usr    jfs    noatime        0 2

/dev/vg/home  /home   jfs    noatime        0 2

/dev/vg/opt   /opt    jfs    noatime        0 2

/dev/vg/var   /var    reiserfs    noatime        0 2

/dev/vg/datastore   /datastore    ext4    ro,noatime,user        0 2

```

As you can see, the root and boot partitions are not handled via LVM, so methinks I do not need initramfs.

My init is the same as in the guide.

```
# cat ~/initramfs/init 

#!/bin/sh

mount -t proc proc /proc

mount -t sysfs sysfs /sys

sleep 2  # wait for kernel msgs to quiet

if cryptsetup luksOpen /dev/sda6 vault; then

  vgchange -ay vault_vg

  resume

  mount -r /dev/mapper/vault_vg-root /newroot

  if [[ -x /newroot/sbin/init ]]; then

    umount /sys /proc

    exec switch_root /newroot /sbin/init

  fi

fi

```

PS. Hibernation is done via s2disk utility.

----------

