# hibernate-ram fails sleep w/ "write error"

## m1ngsheng

After following Power Management Guide regarding sleep states, my laptop (latitude x300) fails to sleep w/ following messages:

```
hibernate-ram: [97] Executing VbetoolSaveState ...

'vbetool' utility not found. Vbetool disabled.

hibernate-ram: [99] Executing DoSysfsPowerStateSuspend ...

hibernate-ram: Activating sysfs power state mem ...

/bin/echo: write error: Operation not permitted

```

...and then proceeds to "wake-up". Any pointers would be greatly appreciated.

----------

## phyzics

I am having having trouble getting my laptop to sleep when I close the lid.  KLaptop did this flawlessly with my old kernel but I recently upgraded to 2.6.14 which does not support sleep states anymore and KLaptop no longer works.

Because /proc/acpi/sleep is deprecated, I only have the option of issuing an "echo -n mem > /sys/power/state" to get the box to sleep - but this does nothing on my machine.  I cannot even find any errors in any logs indicating why it is failing.

I have ACPI compiled into my kernel.

Any ideas?

Thanks in advance.

----------

## babudro

Perhaps...

emerge acpid

/etc/init.d/acpid start

rc-update add acpid default

----------

## phyzics

acpid was already emerged and running - still nothing.

----------

## olof

Are you sure you have acpi sleep support (CONFIG_ACPI_SLEEP) in your kernel? If you have symmetric multiprocessing support (CONFIG_SMP) enabled this disables acpi sleep support. 

(Took me a while to figure that out... and after all that my laptop still hangs on suspend to ram.)

EDIT: Just to clarify: As far as I can tell there is an ongoing change in the handling of the sleep states in recent kernels. To enable sleep states you have to enable CONFIG_ACPI_SLEEP, after this you can put the computer to sleep through /sys/power/state. The old interface /proc/acpi/sleep is deprecated and is not enabled by CONFIG_ACPI_SLEEP.Last edited by olof on Wed Nov 09, 2005 9:27 pm; edited 1 time in total

----------

## Earthwings

Using /proc/acpi/sleep directly is a Bad Thing (tm) anyway. 

```
emerge hibernate-script
```

After configuring it, you can use something like  */etc/acpi/events/lid wrote:*   

> event=button[ /]lid
> 
> action=/usr/sbin/hibernate-ram

 

----------

## phyzics

Ok, I emerged the hibernate script and set up my event in /etc/acpi/events/lid

```
event=button/lid

action=/usr/sbin/hibernate-ram %e
```

But when I trigger the event by closing the lid the laptop does not suspend.

If I execute /usr/sbin/hibernate from the command line it attempts to suspend but then comes back with the error:

 *Quote:*   

> /bin/echo: write error: Invalid argument
> 
> 

 

The contents of /var/log/hibernate.log is:

```
Starting suspend at Wed Nov 9 23:58:04 CST 2005

hibernate-ram: [01] Executing CheckLastResume ...

hibernate-ram: [01] Executing LockFileGet ...

hibernate-ram: [01] Executing NewKernelFileCheck ...

hibernate-ram: [10] Executing EnsureSysfsPowerStateCapable ...

hibernate-ram: [11] Executing XHacksSuspendHook1 ...

hibernate-ram: [89] Executing SaveKernelModprobe ...

hibernate-ram: [91] Executing ModulesUnloadBlacklist ...

hibernate-ram: [95] Executing XHacksSuspendHook2 ...

hibernate-ram: [97] Executing VbetoolSaveState ...

^[[H^[[Jhibernate-ram: [99] Executing DoSysfsPowerStateSuspend ...

hibernate-ram: Activating sysfs power state mem ...

hibernate-ram: [97] Executing VbetoolRestoreState ...

hibernate-ram: [90] Executing ModulesLoad ...

hibernate-ram: [89] Executing RestoreKernelModprobe ...

hibernate-ram: [85] Executing XHacksResumeHook2 ...

hibernate-ram: [70] Executing ClockRestore ...

hibernate-ram: [11] Executing XHacksResumeHook1 ...

hibernate-ram: [01] Executing NoteLastResume ...

hibernate-ram: [01] Executing LockFilePut ...

Resumed at Wed Nov 9 23:58:14 CST 2005

```

which seems to indicate that the error is with the DoSysfsStateSuspend execution.  

Any ideas?

----------

## Earthwings

Someone else reported the same, I'll see whether I get the same when updating both this evening.

----------

## justinCOD

Having the same problem here. I've had hibernate working in the past just fine, it was even working yesterday after I went through the gentoo power management guide again. Today I'm seeing this from the hibernate-script:

```
+ echo hibernate-ram: Activating sysfs power state mem ...

hibernate-ram: Activating sysfs power state mem ...

+ '[' -n '' ']'

+ /bin/echo -n mem

/bin/echo: write error: Operation not permitted

+ return 0

+ ret=0
```

That is with verbose set to 4 in ram.conf. Any ideas? The hibernate.log does not show anything additional even with logging set to 4 too.

----------

## justinCOD

Same problem here, here is the debug output from hibernate script:

```
+ echo hibernate-ram: '[99]' Executing DoSysfsPowerStateSuspend ...

hibernate-ram: [99] Executing DoSysfsPowerStateSuspend ...

+ '[' -n '' ']'

+ DoSysfsPowerStateSuspend

+ '[' -z '' ']'

+ vecho 1 'hibernate-ram: Activating sysfs power state mem ...'

+ local v

+ v=1

+ shift

+ '[' 1 -le 4 ']'

+ echo hibernate-ram: Activating sysfs power state mem ...

hibernate-ram: Activating sysfs power state mem ...

+ '[' -n '' ']'

+ /bin/echo -n mem

/bin/echo: write error: Operation not permitted

+ return 0

+ ret=0

+ '[' 0 -ge 2 ']'

+ '[' 0 -gt 0 ']'

+ '[' -n '' ']'

++ SortResumeBits

++ /bin/echo -ne '30ServicesStart\n60NetworkStart\n90ModulesLoad\n70ClockRestore\n89RestoreKernelModprobe\n01NoteLastResume\n01LockFilePut\n'

++ sort -rn

+ for bit in '`SortResumeBits`'

++ awk 'BEGIN{print substr("90ModulesLoad", 1, 2)}'

+ THIS_POS=90

+ '[' -z 90 ']'
```

----------

## justinCOD

Just some additional information. I just loaded up my 2.6.12-r9 kernel and hibernate works perfectly fine with no other changes. I load up either 2.6.13 or the latest 2.6.14 and it fails with the error noted above.

Only thing that changed for me between the kernels was a switch to udev from devfs. Any ideas?

----------

## m1ngsheng

...why this is happening. after a few years of Gentoo servers, i said goodbye to windoze on my laptop. hibernate doesn't seem so important now that my host OS doesn't take years to startup from power-off.

thus, hibernate has lowered in priority for me...but i would still like to learn technically why it's not working. ideas?

----------

## Earthwings

Merged two topics. Can't look into the problem myself as currently I don't have access to a laptop with a 2.6.14-suspend2 kernel.

----------

## justinCOD

User error on my part. For some reason the "Sleep States" (CONFIG_ACPI_SLEEP:) got removed, or turned off, in my 2.6.14 kernel config. Once I checked it in my kernel config, recompiled, and rebooted w/ the kernel my hibernate started working again. Someone already mentioned this previously in the thread, but I overlooked it when skimming the replys because it had "deprecated" in the same reply. hehe.

So, in short, once again make sure you enable "Sleep States"  (CONFIG_ACPI_SLEEP) under Power Management -> ACPI

```

[*] ACPI Support

[*]   Sleep States 
```

and you should *not* get this error atleast:

```
+ /bin/echo -n mem

/bin/echo: write error: Operation not permitted 
```

----------

## emdej

 *justinCOD wrote:*   

> User error on my part. For some reason the "Sleep States" (CONFIG_ACPI_SLEEP:) got removed, or turned off, in my 2.6.14 kernel config. Once I checked it in my kernel config, recompiled, and rebooted w/ the kernel my hibernate started working again. Someone already mentioned this previously in the thread, but I overlooked it when skimming the replys because it had "deprecated" in the same reply. hehe.
> 
> So, in short, once again make sure you enable "Sleep States"  (CONFIG_ACPI_SLEEP) under Power Management -> ACPI
> 
> 

 

I've 2.6.14-suspend2-r1, tried also linux-2.6.13-suspend2-r4 and linux-2.6.13-suspend2-r5. In none of them I found option "Sleep States". The last kernel showing me this option was linux-2.6.12-suspend2-r6. Has it been removed permanently or what... ?

Could anybody help me with this kernel ?

----------

## justinCOD

 *emdej wrote:*   

> 
> 
> I've 2.6.14-suspend2-r1, tried also linux-2.6.13-suspend2-r4 and linux-2.6.13-suspend2-r5. In none of them I found option "Sleep States". The last kernel showing me this option was linux-2.6.12-suspend2-r6. Has it been removed permanently or what... ?
> 
> Could anybody help me with this kernel ?

 

It's in there, I'm looking at it right now on my machine.

It resides in: Power management options (ACPI, APM)  ---> ACPI (Advanced Configuration and Power Interface) Support  ---> [*]   Sleep States 

This is kernel:  Linux Kernel v2.6.14-gentoo-r3 Configuration

Also, check your .config file:

```
justin@fileserver linux $ grep -i sleep /usr/src/linux/.config

CONFIG_SEMAPHORE_SLEEPERS=y

CONFIG_ACPI_SLEEP=y

CONFIG_ACPI_SLEEP_PROC_FS=y

# CONFIG_ACPI_SLEEP_PROC_SLEEP is not set

```

Are you sure you are in the correct source directory? Assuming you're using "make menuconfig", it does show the right kernel version at the top right?

Justin

----------

## justinCOD

I just noticed you are using the "sys-kernel/suspend2-sources", or atleast it looks like it. Have you tried just regular gentoo-sources?

This is what I'm running:

```
sys-kernel/gentoo-sources-2.6.14-r3 *

```

----------

## emdej

Now I've 2.6.14-suspend2-r7 and there I've found the option  :Wink: . Unfortunetely when my computer wakes up sth goes wrong and the screen becames a set of mixed pixels.. It looks like everything other works fine cause I can work on the computer remotely, but the screen...  :Wink: . I need some more time for testing.

----------

## jorrit

[quote="justinCOD"] *emdej wrote:*   

> 
> 
> This is kernel:  Linux Kernel v2.6.14-gentoo-r3 Configuration
> 
> Justin

 

With kernel 2.6.16-gentoo-r9 I can't find that option anywhere. In the ACPI support menu I have:

 *Quote:*   

> 
> 
>  --- ACPI Support                                                                   │ │
> 
>   │ │ <*>   AC Adapter                                                                   │ │
> ...

 

And that's it.

I'm using gentoo-sources btw.

Greetings,

----------

## agnitio

The answer is allready posted somewhere in the forum, I'm to lazy to find it though, but it goes like this:

You probably have a dual core cpu? If this is the case then you need to enable kernel support for hotpluggable cpus to be able to use sleep states.

----------

## jorrit

 *agnitio wrote:*   

> The answer is allready posted somewhere in the forum, I'm to lazy to find it though, but it goes like this:
> 
> You probably have a dual core cpu? If this is the case then you need to enable kernel support for hotpluggable cpus to be able to use sleep states.

 

No, I don't have a dual core cpu. I just have an AMD64 Turion.

Greetings,

----------

## mc_barron

I am having the same problem - everything worked before (when I was using vanilla kernel 2.6.15.1) but now I get the following error when trying to suspend (with current vanilla kernel 2.6.16.19):

```
/bin/echo: write error: Operation not permitted
```

Output of "zcat /proc/config.gz | grep ACPI":

```
 # Power management options (ACPI, APM)

# ACPI (Advanced Configuration and Power Interface) Support

CONFIG_ACPI=y

CONFIG_ACPI_AC=y

CONFIG_ACPI_BATTERY=y

CONFIG_ACPI_BUTTON=y

CONFIG_ACPI_VIDEO=y

CONFIG_ACPI_HOTKEY=y

CONFIG_ACPI_FAN=y

CONFIG_ACPI_PROCESSOR=y

CONFIG_ACPI_THERMAL=y

# CONFIG_ACPI_ASUS is not set

# CONFIG_ACPI_IBM is not set

# CONFIG_ACPI_TOSHIBA is not set

CONFIG_ACPI_BLACKLIST_YEAR=0

# CONFIG_ACPI_DEBUG is not set

CONFIG_ACPI_EC=y

CONFIG_ACPI_POWER=y

CONFIG_ACPI_SYSTEM=y

# CONFIG_ACPI_CONTAINER is not set

CONFIG_X86_ACPI_CPUFREQ=y

CONFIG_X86_POWERNOW_K7_ACPI=y

CONFIG_X86_POWERNOW_K8_ACPI=y

CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y

# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set

# CONFIG_HOTPLUG_PCI_ACPI is not set

CONFIG_PNPACPI=y

CONFIG_SERIAL_8250_ACPI=y
```

And I don't have a dual-core either - it's just a pentium celeron.

----------

## pielgrzym

I've got the same damn problem with a properly configured for smp kernel. Hotplugable cpus enabled, acpi sleep states too and no freaking way to force this shit to suspend  :Sad: 

Kernel: 2.6.20-viper6

----------

## pielgrzym

Hi peeps,

I've just installed kernel .21 (the latest one) and ahci can suspend the computer. Unfortunately I cannot resume it  :Sad:  the disks start spinning but nothing happens (mouse/kbd are dead).

----------

