# [Solved] uswsusp doesn't resume, always boots normally

## solamour

I've been using TuxOnIce successfully for a while. Then I suddenly wanted to try uswsusp, so I installed "gentoo-sources" (linux-2.6.35-gentoo-r4 to be exact) and followed the instructions at http://en.gentoo-wiki.com/wiki/Userspace_software_suspend.

Issuing "hibernate" saves the current state to a disk and powers off the computer. But when I turn it on, resume doesn't work; it always starts normally. During the booting, I see something like the following.

```
software suspend data detected "rewriting the swap signature"
```

I'm not sure how to proceed from here. I'd appreciate any suggestions.

__

solLast edited by solamour on Thu Sep 23, 2010 12:17 am; edited 2 times in total

----------

## Hu

What is the error message when the initramfs rejects your hibernated image?  This should appear before the Gentoo initscripts take control.

----------

## solamour

I believe I'm not using initramfs, because when I followed Gentoo Handbook, I didn't use genkernel.

/boot/grub/menu.lst

```
title Gentoo 2.6.35-r4

root (hd0,0)

kernel /boot/kernel-2.6.35-gentoo-r4 root=/dev/sda1
```

__

sol

----------

## Hu

If you do not use an initramfs, how do you expect to execute the userspace resume part of uswsusp?  :Wink:   You need to call /sbin/resume from the resuming kernel before it mounts any filesystems used by the hibernated image.  This means either use an initramfs or have a mini-system stored in an otherwise unmounted partition.  The initramfs is considerably less work, and can be quite small.

----------

## solamour

I guess I won't be able to use uswsusp without initramfs, so to make things easier for me, I tried genkernel, but it looks like genkernel doesn't support uswsusp (yet).

Summary: Add support to genkernel for userspace suspend/resume (uswsusp)

https://bugs.gentoo.org/show_bug.cgi?id=156445

I'll stick with TuxOnIce until 1) genkernel supports uswsusp, 2) I figure out what to do with initramfs, or 3) someone shows me steps in layperson's terms. Thank you for taking time to respond.

__

sol

----------

## fau

I've just set it up and it wasn't that hard, although I got stuck once, when I forgot to compile sandbox with "static" use flag.

Just follow gentoo wiki guide omitting parts about encryption. Later you can edit /etc/hibernate/common.conf file and hibernate by hibernate-script.

Here is my initramfs layout and init file if it is going to help you.

```

.:

total 8

drwxr-xr-x 2 root root  32 Sep 18 22:58 bin

drwxr-xr-x 2 root root  48 Sep 19 03:05 dev

drwxr-xr-x 2 root root   8 Sep 18 18:48 etc

-rwxr-xr-x 1 root root 301 Sep 18 23:31 init

-rwxr-xr-x 1 root root 189 Sep 18 18:50 install

drwxr-xr-x 3 root root   8 Sep 18 20:07 mnt

drwxr-xr-x 2 root root   1 Sep 18 18:46 proc

drwxr-xr-x 2 root root   1 Sep 18 20:06 sys

./bin:

total 3992

-rwxr-xr-x 1 root root 1814068 Sep 18 22:58 busybox

-rwxr-xr-x 1 root root 2261780 Sep 18 22:58 resume

lrwxrwxrwx 1 root root       7 Sep 18 22:58 sh -> busybox

./dev:

total 0

crw------- 1 root root  5,   1 Sep 18 16:48 console

brw-rw---- 1 root disk  8,   5 Sep 18 20:23 sda5

brw-rw---- 1 root disk  8,   7 Sep 18 18:27 sda7

crw-rw---- 1 root root 10, 231 Sep 18 18:48 snapshot

crw-rw-rw- 1 root tty   5,   0 Sep 18 22:23 tty

./etc:

total 4

-rw-r--r-- 1 root root 176 Sep 18 18:48 suspend.conf

./mnt:

total 0

drwxr-xr-x 2 root root 1 Sep 18 20:07 root

./mnt/root:

total 0

./proc:

total 0

./sys:

total 0
```

```
#!/bin/sh

mount -t proc proc /proc

mount -t sysfs sysfs /sys

sleep 2

if [ -z "$noresume" ]

then

resume

fi

mount -o ro /dev/sda5 /mnt/root || rescue_shell

#Clean up

umount /sys /proc

exec switch_root /mnt/root /sbin/init

rescue_shell() {

    echo "Rescue Shell"

    busybox --instal -s

    exec /bin/sh

}
```

----------

## solamour

I should have spent time learning how to create initramfs on my own, but I'm lazy, so I shamelessly stole someone else's work at http://lunaryorn.de/articles/initramfs_gentoo.html.

1) Download "init.sh", "makefile.tmpl", and "makeinitramfs.py".

2) Build busybox as static.

```
USE="static" emerge -ptv busybox
```

3) The scripts might work with little or no modifications, but because I don't need fbcondecor, cryptsetup, or LVM, I commented out the parts that are not relevant to me in "init.sh" and "makefile.tmpl". The only thing that needs to be checked is "ROOT" (where the root file system is) in "init.sh".

```
init.sh

export ROOT="/dev/sda1"
```

4) Create "initramfs" file and put it in "/boot" directory.

```
python makeinitramfs.py -z -i
```

5) Update GRUB.

```
/boot/grub/grub.conf

title Gentoo 2.6.34-r6

root (hd0,0)

kernel ...

initrd /boot/initramfs   <-- Add This Line.

```

Now uswsusp works as expected. Thank you everyone for taking time to respond.

__

sol

----------

## rh1

 *Quote:*   

> If you do not use an initramfs, how do you expect to execute the userspace resume part of uswsusp?  You need to call /sbin/resume  from the resuming kernel before it mounts any filesystems used by the hibernated image. This means either use an initramfs or have a mini-system stored in an otherwise unmounted partition. The initramfs is considerably less work, and can be quite small.

 

I've only tried tux so far but I thought adding resume=/dev/blah to the kernel line in grub.conf took care of this regardless? It's even in the wiki:

 *Quote:*   

> Make sure your kernel has suspend support enabled. You can probably leave "Default resume partition" blank if you're using an initramfs. Otherwise, you might (???) have to set it to the path of your swap/resume device (or, alternatively, pass the resume=/dev/YOUR_SWAP_PATH parameter on the kernel command line). 

 

----------

## solamour

 *Quote:*   

> I've only tried tux so far but I thought adding resume=/dev/blah to the kernel line in grub.conf took care of this regardless?

 

If I understand correctly, TuxOnIce does things inside kernel, so "resume=/dev/blah" in grub.conf is enough, but uswsusp requires initramfs in order to work properly.

__

sol

----------

## roothorick

 *Hu wrote:*   

> If you do not use an initramfs, how do you expect to execute the userspace resume part of uswsusp?   You need to call /sbin/resume from the resuming kernel before it mounts any filesystems used by the hibernated image.  This means either use an initramfs or have a mini-system stored in an otherwise unmounted partition.  The initramfs is considerably less work, and can be quite small.

 

That doesn't jive with the wikipage:

 *Quote:*   

> If you use an initramfs  (initrd) -- either homemade or generated by genkernel -- you will likely have to configure your initramfs to support uswsusp. If you're not sure whether you use an initramfs, check for an initrd line in your bootloader configuration (/boot/grub/grub.conf or /boot/lilo/lilo.conf).

 

That strongly implies that you don't need one. Big oversight.

----------

## Hu

 *roothorick wrote:*   

> That doesn't jive with the wikipage:

 Wikis are notoriously subject to modification by users, not all of whom are adequately informed or necessarily excellent writers.

 *roothorick wrote:*   

>  *Quote:*   If you use an initramfs  (initrd) -- either homemade or generated by genkernel -- you will likely have to configure your initramfs to support uswsusp. If you're not sure whether you use an initramfs, check for an initrd line in your bootloader configuration (/boot/grub/grub.conf or /boot/lilo/lilo.conf). That strongly implies that you don't need one. Big oversight.

 Please fix the wording to something more accurate.  Also, you may wish to send a strongly worded e-mail to whoever wrote the original document to inform them of their big oversight.  Finally, please note that though forum regulars may cite the Wiki, we are not necessarily the authors of the content on it, nor are we capable of preventing the upload of inaccurate information.

----------

## solamour

Looks like the site I stole the script from (http://lunaryorn.de/articles/initramfs_gentoo.html) is no longer maintained. But I found dracut (http://wiki.gentoo.org/wiki/Dracut) vastly simpler to use. I just installed it, and hibernation worked right out of the box.

Hibernation and genkernel still don't play well yet.

__

sol

----------

