Page 1 of 1

How to make Puppy hibernate

Posted: Mon 30 Aug 2010, 01:30
by piratesmack
This was tested with a frugal install of Puppy 5.1

Note: Before doing anything, you'll need a swap partition to hibernate. A swap file won't work.


Here's how I did it:

The kernel needs to be recompiled with support for hibernation:
  • * Download the source tarball and DOTconfig from here: http://bkhome.org/sources/kernel-2.6.33.2/
    * Compile the kernel:
    ----------------------------------------------

    To compile kernel
    -----------------

    # make clean
    # make mrproper
    <<<copy in the .config file
    # make menuconfig <<<enable hibernation under power management options
    # make bzImage
    (no need to rebuild modules)
    * Replace your kernel with the new one:

    Code: Select all

    mv /mnt/home/vmlinuz /mnt/home/vmlinuz.old
    cp arch/x86/boot/bzImage /mnt/home/vmlinuz
    
The initrd needs to be modified to resume after hibernating:
  • * Extract the initrd:

    Code: Select all

    mkdir -p /tmp/initrd-tree && cd /tmp/initrd-tree
    zcat /mnt/home/initrd.gz | cpio -id --no-absolute-filenames
    
    * Edit the init script:

    Code: Select all

    geany init
    
    * In between the 'Loading modules to access disk drives' and 'Searching for puppy files' sections, insert the following:

    Code: Select all

    ##############END MODULE LOADING TO ACCESS DRIVES####################
    
    # piratesmack: Resume after hibernation
    #
    # Note: boot parameter 'resume' must be set
    # e.g. resume=sda3, where sda3 is the swap partition you hibernated to
    #
    RESUME="$(tr ' ' '\n' < /proc/cmdline | grep '^resume=' | cut -d= -f2 | sed -e 's:^/dev/::')"
    if [ -n "$RESUME" -a -e "/sys/power/resume" ]; then
      PTRN="$RESUME$"
      # get major and minor number of resume partition
      MAJMIN="$(grep "$PTRN" /proc/partitions | tr -s ' ' | cut -d' ' -f2,3 | tr ' ' :)"
      echo -n $MAJMIN > /sys/power/resume
    fi
    ########################################
    
    #######################FINDING PUPPY FILES###########################
    
    * Now save and exit geany
    * Rebuild the initrd:

    Code: Select all

    mv /mnt/home/initrd.gz /mnt/home/initrd.gz.old
    find . | cpio -o -H newc | gzip -c9 > /mnt/home/initrd.gz
    

You'll also need to edit your boot loader's config file and add "resume=sdXX" as a boot parameter:
  • * here is an example grub menu.lst, replace sda1 with your swap partiiton

    Code: Select all

    title Puppy 5.1
    root (hd0,1)
    kernel /vmlinuz pmedia=atahd resume=sda1
    initrd /initrd.gz
    
Reboot

That's it.

Now you can hibernate with the following command:
echo -n disk > /sys/power/state

I apologize, this probably isn't very newbie-friendly.
You can download a prebuilt kernel and initrd from the following link.

http://www.mediafire.com/?o28pgbbh6jomsz6

Posted: Mon 30 Aug 2010, 14:11
by piratesmack
To hibernate when laptop lid closed:

Download and install acpid from here:
http://distro.ibiblio.org/pub/linux/dis ... 100603.pet

Edit /etc/acpi/actions/suspend.sh:

Code: Select all

geany /etc/acpi/actions/suspend.sh
Find this line:

Code: Select all

echo -n mem > /sys/power/state
Replace it with:

Code: Select all

echo -n disk > /sys/power/state
Save and reboot.

Posted: Wed 01 Sep 2010, 21:16
by pemasu
# acpitool --help
Usage: acpitool [option] . . .
Shows ACPI information from the /proc/acpi filesystem, like battery status,
temperature, or ac power. Can also suspend your machine (if supported).

cut...
-s, --suspend suspend to memory (sleep state S3), if supported
-S suspend to disk (sleep state S4), if supported

I have compiled kernel with hibernation (I give also resume=/dev/sdX parameter when in menuconfig) and then used acpitool for suspend to ram or suspend to disk ( hibernate ). I have also made function keys bindings: acpitool -s and acpitool-S with Xbindkeys-config. Nice tool.

No need for anything else. Acpitool just works for me.

Posted: Wed 01 Sep 2010, 23:18
by rjbrewer
Fluppy 004 comes with suspend and hibernate.

please include Hibernate in 5.2.6 please

Posted: Sat 06 Aug 2011, 03:18
by jawaharpeter
please include Hibernate in 5.2.6 please

Posted: Sat 06 Aug 2011, 10:49
by pemasu
Kernel used in lucid puppy series does not have hibernate enabled in kernel level.

Anyway hibernating takes quite a lot time, because whole RAM content needs to be copied to the swap partition. Hibernation is 10 time slower than shuttind down computer. And you swap partition will be locked before you restart the same puppy version which performed the hibernation.

And you need big enough swap partition so that the whole RAM will be able to copy to the swap and you need kernel boot parameter which defines you swap resume partition. A little complicated.

What useful usage there remains for hibernation in usual puppy usage ?

Posted: Sat 06 Aug 2011, 23:03
by Luluc
pemasu wrote:Kernel used in lucid puppy series does not have hibernate enabled in kernel level.

Anyway hibernating takes quite a lot time, because whole RAM content needs to be copied to the swap partition. Hibernation is 10 time slower than shuttind down computer. And you swap partition will be locked before you restart the same puppy version which performed the hibernation.

And you need big enough swap partition so that the whole RAM will be able to copy to the swap and you need kernel boot parameter which defines you swap resume partition. A little complicated.

What useful usage there remains for hibernation in usual puppy usage ?
Suspend to disk is awfully slow indeed. I never tried it with Puppy, just Slackware and Ubuntu, both were very slow.

But suspend to RAM is awesome. Since I use a notebook with a 7-hour battery that lasts at least two or three days in suspend mode, it is very safe not to shut down the computer anymore, it will sleep well and peacefully even if my AC power supply is interrupted for a few hours for any reason. I just suspend to RAM, it goes to sleep in 5 seconds, then it's another 5 seconds to wake up. Good-bye booting, hello sweet long uptime.

Posted: Mon 08 Aug 2011, 02:58
by heywoodj
Edit: Mods, I moved this to Users.

Posted: Mon 08 Aug 2011, 20:15
by Luluc
Somebody asked me in private how to suspend to RAM. I'd rather answer that question in public, so more people benefit.

First off, configure your screen locking mechanism. Right-click the Lock icon on the desktop area and select "Configure screen locking". Among other things, be sure to create a password you know you will remember. My method doesn't just make the computer hibernate, it locks the screen in case the notebook gets lost or stolen while it is sleeping. So you will have to know that password later on.

There are many ways to achieve suspend to RAM, for example a script. In my case, I just made a shell alias:

Code: Select all

alias hibernate 'xlock -mode blank &; sleep 2; echo -n mem >! /sys/power/state'
I think you add that to your /root/.bash_profile or /root/.bashrc. My shell is tcsh, so I have it in /root/.tcshrc.

Once you have the alias, open a new shell/terminal and run:

Code: Select all

# hibernate
I have no other program, function or script that begins wit 'hib' so all I need to type is hib{tab} to auto complete. Hit Enter and wait 2 or 3 seconds, the operating system goes to sleep.

You can also put that line in a script, then configure your window manager to launch that script when you press a keyboard shortcut. May be more convenient than launching a terminal. In my case, I run Tilda all the time, I spend a lot of time using the Tilda/screen terminal, so it's just there always.

While the OS is suspend to RAM, just press any key to wake everything up again.

Please note, suspend to RAM puts the operating system in RAM, which is volatile. If you disconnect the computer from all power sources (wall outlet/notebook battery), you lose the suspended state, you will have to reboot, and who knows, data may get corrupt too. It is just like pulling the plug on the computer while it is running.

I hope this is useful to someone. Sleep tight.

Posted: Tue 16 Aug 2011, 20:17
by night_mare007
I use Lupu ( puppy 5.25 ) but I can't get SUSPEND TO RAM to works.

when I run:
echo -n mem >! /sys/power/state
or
echo -n mem > /sys/power/state ( without the "!" )

Then my screen flicker for just 1 sec, and return to desktop with this error in the terminal:
bash: echo: write error: No such file or directory

ANY IDEA HOW CAN I RUN S3 ( suspend-to-ram ) in LUPU 5.25 ???

P.S - I even tried to download that acpid.pet - but that doesn't work.
[EDIT]
Forgot to mention that I'm sure my Kernel supports suspend-to-ram, but not to HDD, As I recompiled it and made sure that option on available.

Posted: Wed 17 Aug 2011, 12:35
by pemasu
Install acpitool from repo. Then in console acpitool -s

Posted: Thu 18 Aug 2011, 19:45
by night_mare007
OK... tried that - NOT WORKING:
i've Installed acpitool_0.5-7 from PPM, and then ran in terminal:
sleep 2; acpitool -s

The screen flicker for 1 sec, then return to the desktop.

I tried to ran this acouple more time - the same....

please guide me how to fix this.... PLEASE !!!!

Posted: Fri 02 Sep 2011, 10:56
by Egorio
maybe that's some sort of bug?

Posted: Wed 05 Jun 2019, 16:57
by rufwoof
Old thread I know, but just to add ...

Suspend can work when your swap is encrypted, hibernate doesn't work with a encrypted swap. At least that is my understanding.