# please help me suspend my laptop

## koshmar

Hey all,

I am a gentoo novice and I am trying to teach my laptop suspend when I close the lid and then resume when I open. Unfortunatly, I cannot succeed, please help me identify if I am doing something wrong or missing something.

I have lenovo Thinkpad T440p if it matters with custom x64 gentoo install with more or less standard option and kernel generated with genkernel.

```
$ uname -a

Linux kosh-pc 4.9.16-gentoo #1 SMP Sun Mar 26 15:15:33 CST 2017 x86_64 Intel(R) Core(TM) i7-4600M CPU @ 2.90GHz GenuineIntel GNU/Linux
```

First I read Power management/Guide from the wiki and did the following:

```
#emerge --ask app-laptop/laptop-mode-tools
```

checking that I have global "acpi" USE flag.

I added the appropriate service to the boot

```
#rc-update add laptop_mode default
```

and checked if it is running - it is:

```
$ /etc/init.d/acpid status

 * status: started
```

It did not set anything automatically, so my laptop does not go to sleep when I close the lid

So I looked into "/etc/laptop-mode/laptop-mode.conf" and confirmed that following parameters are set:

```

ENABLE_LAPTOP_MODE_TOOLS=1

ENABLE_LAPTOP_MODE_ON_BATTERY=1

ENABLE_LAPTOP_MODE_ON_AC=0

ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=1

```

Still does not work, so I checked that acipid is installed and running

```

$ /etc/init.d/acpid status

 * status: started

```

then I went to Suspend and hibernate wiki page and installed

```
#emerge --ask sys-power/suspend
```

I use xmonad so I do not need any buttons for suspend/resume etc so I did not care about that

I checked 

```
$ cat /sys/power/state

freeze mem disk
```

and it still does not work (nothing happens when I close/open lid)

Now i tried "s2ram" and "s2disk" command

1) s2ram half works -> it puts computer to sleep, but when I trying to wake it up, it is starting to wake up but does not show anything but black screen (screen without power) but it produces sounds as if it works. So I cannot wake it up.

I disabled the security chip in BIOS and it did not help.

When I run s2ram it outputs:

```
KMS graphics driver is in use, skipping quirks.
```

2) s2disk does not work ("s2both" is the same)

```
# s2disk

s2disk: Could not stat the resume device file. Reason: No such file or directory

```

I tried 

```
#echo /dev/sda2 > /sys/power/resume
```

where /dev/sda2 is my working swap

```
# swapon -s

Filename            Type      Size   Used   Priority

/dev/sda2                                 partition   16776188   0   -1

```

I do not know how to trouble-shoot it anymore and make it work. I would write some script to make the lid trigger "s2ram" or "s2disk" but they do not work anyway...

Please help me  :Smile: 

----------

## josephg

http://wiki.gentoo.org/wiki/suspend_and_hibernate

----------

## koshmar

 *josephg wrote:*   

> http://wiki.gentoo.org/wiki/suspend_and_hibernate

 

well, I read it before and still do not have a solution, you can notice that I tried some things from this article (like disabling the security chip in BIOS).

----------

## sebB

Can you you post /etc/default/grub and your fstab?

----------

## Hu

If wake from suspend allows the system to make sound, that suggests that your video card was not reinitialized properly.  This has historically been a common problem with S3.

For your s2disk problem, what resume device file did you set in its configuration?

----------

## koshmar

 *sebB wrote:*   

> Can you you post /etc/default/grub and your fstab?

 

well, I do not use grab, I use gummiboot https://wiki.archlinux.org/index.php/Systemd-boot from my arch

(I have dual boot https://forums.gentoo.org/viewtopic-p-7988896.html?sid=2bdd4dd5827129d2654e6a14608fd30e). So probably relevant part is

```
$ lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT

sr0     11:0    1  1024M  0 rom  

sda      8:0    0 465.8G  0 disk 

├─sda4   8:4    0 193.8G  0 part /

├─sda2   8:2    0    16G  0 part [SWAP]

├─sda3   8:3    0 255.5G  0 part  (comment: here is my arch)

└─sda1   8:1    0   512M  0 part /boot 
```

and my fstab

```
#/dev/sda1      /boot      vfat      noauto,noatime   0 2

/dev/sda4      /      ext4      noatime      0 1

/dev/sda2      none      swap      sw      0 0

```

I usually do not mount my boot. and this is how I boot gentoo

```
# cat /boot/loader/entries/gentoo.conf 

title Gentoo 

linux /kernel-genkernel-x86_64-4.9.16-gentoo

initrd /early_ucode_4.9.16.cpio

initrd /initramfs-genkernel-x86_64-4.9.16-gentoo

options root=/dev/sda4 rw rootfstype=ext4

```

----------

## koshmar

 *Hu wrote:*   

> If wake from suspend allows the system to make sound, that suggests that your video card was not reinitialized properly.  This has historically been a common problem with S3.

 

I just checked: Computer only produces sound as if it works - like HDD is rotating or something, processor working etc, but I cannot hear real sound - I left vlc working with video, then "s2ram" then "woke" it and no sound is present. Sorry but what is S3?

 *Quote:*   

> For your s2disk problem, what resume device file did you set in its configuration?

 

Sorry for stupid question, but what configuration? all I did is

```
#echo /dev/sda2 > /sys/power/resume
```

where sda2 is my swap partition.Last edited by koshmar on Sat Apr 22, 2017 11:04 pm; edited 1 time in total

----------

## sebB

What appen if you modify

```
options root=/dev/sda4 rw rootfstype=ext4
```

by

```
options root=/dev/sda4 rw rootfstype=ext4 resume=/dev/sda2
```

----------

## koshmar

 *sebB wrote:*   

> What appen if you modify
> 
> ```
> options root=/dev/sda4 rw rootfstype=ext4
> ```
> ...

 

well it boots, but there are a lot of errors, because my file system becomes read-only, and it still does not wake up from s2ram.

UPDATE if you think about it, s2ram should not depend on it =) but I guess if my fs is read-only, this option is out.

----------

## koshmar

just checked, 

```
acpid_listen
```

 catches the closing and opening of the lid. Moreover 

```
echo mem > /sys/power/state
```

 can put my computer into sleep but I again cannot resume. even if I set my swap partition like so 

```
echo /dev/sda2 > /sys/power/resume
```

 Probably I need to tell kernel about it... somehow and resume=/dev/sda2 did not work.

----------

## koshmar

well I solved half the problem, for laptop to go to sleep I just needed to add

```
case "$action" in 

.... 

                        lid) 

                                case "$id" in 

                                      close) s2ram;; 

                                      open) :;; 

                                      *)uhd $*;; 

                                esac;; 
```

into my /etc/acpi/default.sh  :Smile:  that was easy. 

Now I need to make my laptop wakeup

----------

## koshmar

well, I modified  /etc/suspend.conf so 

```
snapshot device = /dev/snapshot 

resume device = /dev/sda2 
```

and I managed to make bootloader to pass the parameter to kernel "resume=/dev/sda2"  (I just needed to write parameters in two lines)

so now s2disk runs, but it does not want to wake up.

If I make my laptop go to sleep manually with s2disk comand

it first prints 

```
s2disk: Snapshotting system
```

then goes black screen then wakeups by itself and writes "Snapshotting system" again and hangs. if I use lid to trigger s2disk I only see the black screen

----------

