How to make Puppy hibernate

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
piratesmack
Posts: 100
Joined: Wed 16 Sep 2009, 14:22

How to make Puppy hibernate

#1 Post 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
Last edited by piratesmack on Mon 30 Aug 2010, 17:40, edited 3 times in total.

User avatar
piratesmack
Posts: 100
Joined: Wed 16 Sep 2009, 14:22

#2 Post 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.

User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#3 Post 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.

User avatar
rjbrewer
Posts: 4405
Joined: Tue 22 Jan 2008, 21:41
Location: merriam, kansas

#4 Post by rjbrewer »

Fluppy 004 comes with suspend and hibernate.

Inspiron 700m, Pent.M 1.6Ghz, 1Gb ram.
Msi Wind U100, N270 1.6>2.0Ghz, 1.5Gb ram.
Eeepc 8g 701, 900Mhz, 1Gb ram.
Full installs

jawaharpeter
Posts: 6
Joined: Sat 25 Jun 2011, 03:02
Location: Banglore

please include Hibernate in 5.2.6 please

#5 Post by jawaharpeter »

please include Hibernate in 5.2.6 please

User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#6 Post 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 ?

User avatar
Luluc
Posts: 200
Joined: Wed 16 Mar 2011, 07:10

#7 Post 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.

heywoodj
Posts: 85
Joined: Sun 15 Mar 2009, 04:39

#8 Post by heywoodj »

Edit: Mods, I moved this to Users.

User avatar
Luluc
Posts: 200
Joined: Wed 16 Mar 2011, 07:10

#9 Post 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.

night_mare007
Posts: 30
Joined: Sun 07 Aug 2011, 17:13

#10 Post 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.

User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#11 Post by pemasu »

Install acpitool from repo. Then in console acpitool -s

night_mare007
Posts: 30
Joined: Sun 07 Aug 2011, 17:13

#12 Post 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 !!!!

Egorio
Posts: 3
Joined: Wed 31 Aug 2011, 09:41

#13 Post by Egorio »

maybe that's some sort of bug?
Benefits of Using a [url=http://www.tecmetic.com/benefits-using-mobile-phone-signal-booster/]Mobile Phone Signal Booster[/url]
[url=http://recit.org/marc/wakka.php?wiki=FactsAboutMobilePhoneSignalBooster]Facts About Mobile Phone Signal Booster[/url]

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#14 Post 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.
[size=75]( ͡° ͜ʖ ͡°) :wq[/size]
[url=http://murga-linux.com/puppy/viewtopic.php?p=1028256#1028256][size=75]Fatdog multi-session usb[/url][/size]
[size=75][url=https://hashbang.sh]echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh[/url][/size]

Post Reply