WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: tinywake - resume from s2disk with size and speed optimization  (Read 5382 times)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
tinywake - resume from s2disk with size and speed optimization
« on: February 21, 2013, 04:44:30 PM »
This script creates an initramfs to resume from s2disk.

As it is optimized for size (created initrd is ~215Kb on my system) and speed, it is suitable to resume after having suspended to disk with s2disk only, so make sure you have an alternative boot configuration handy in case something should go wrong.

In order to function properly you need to configure items which are #commented
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #1 on: February 22, 2013, 01:43:27 AM »
hi tinypoodle,

do you think that it's possible to adjust the script that it can be used for a live-usbstick, f.e. with the help of LABEL?
gerald_clark told me that there is a way to LABEL the swap-partition, too?
http://forum.tinycorelinux.net/index.php/topic,4147.msg84943.html#msg84943

you gave hints for offsets:
http://forum.tinycorelinux.net/index.php/topic,4147.msg84920.html#msg84920
resume offset = <value>
parameter, where <value> can be obtained with
swap-offset <file_name>
:) would you be so kind and give a more specific example?

s2ram works like a charm, but s2disk would be a convenient alternative, that reduces power-consumption, too :)

« Last Edit: February 22, 2013, 01:54:49 AM by netnomad »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #2 on: February 22, 2013, 05:12:24 PM »
do you think that it's possible to adjust the script that it can be used for a live-usbstick,

Do you refer to using bootloader, kernel & initrd on UFD or do you mean to even include the snapshot itself on UFD?

Quote
f.e. with the help of LABEL?
gerald_clark told me that there is a way to LABEL the swap-partition, too?
http://forum.tinycorelinux.net/index.php/topic,4147.msg84943.html#msg84943

Indeed, see
http://forum.tinycorelinux.net/index.php/topic,4147.msg85046.html#msg85046
but you would have to elaborate how exactly that could be of help for which purpose.

Quote
you gave hints for offsets:
http://forum.tinycorelinux.net/index.php/topic,4147.msg84920.html#msg84920
resume offset = <value>
parameter, where <value> can be obtained with
swap-offset <file_name>
:) would you be so kind and give a more specific example?

Code: [Select]
tc@box:~$ sudo swap-offset /mnt/hda6/tc.swp
resume offset = 384222
tc@box:~$ sudo sh -c 'echo resume offset = 384222 >> /etc/suspend.conf'

N.B. the script is copying suspend.conf into the initramfs, so any edit will be updated by running it again ;)

Quote
s2ram works like a charm, but s2disk would be a convenient alternative, that reduces power-consumption, too :)

AFAIK there is zero power consumption, as s2both is supposed to resume from disk after having run out of power.
« Last Edit: February 22, 2013, 05:22:40 PM by tinypoodle »
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #3 on: February 22, 2013, 11:00:43 PM »
hi tinypoodle,

Quote
Do you refer to using bootloader, kernel & initrd on UFD or do you mean to even include the snapshot itself on UFD?

i want to include the snapshot itself on UFD... as a swap-file or LABEL-swap-partition.
everything should be on the UFD and i prefer a LABEL-configuration, cause it should work in other fstab-environments, too.
did you succeed to run such a configuration yet?

thank you for your support and help.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #4 on: February 23, 2013, 03:30:47 PM »
i want to include the snapshot itself on UFD...
That might get way more tricky.
As an indication, are you able to mount extensions onboot or to auto restore backup without waitusb boot code?
Quote
as a swap-file or LABEL-swap-partition.
everything should be on the UFD and i prefer a LABEL-configuration, cause it should work in other fstab-environments, too.
did you succeed to run such a configuration yet?
"fstab-environments" is totally unrelated and label is irrelevant.
Configuration options determining the swap area are "resume device =" and "resume offset =".
Latter can be ommited in case of partition as it is assumed to be "0".
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #5 on: February 23, 2013, 08:29:49 PM »
Quote
As an indication, are you able to mount extensions onboot or to auto restore backup without waitusb boot code?
i was pretty astonished, but my current sticks do not need any waitusb boot code, at least in the moment!

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #6 on: February 23, 2013, 08:38:43 PM »
Well, in that case if you are daring enough you might just try and see.
There's a chance the kernel would panic if resume would not have access to the snapshot in time.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #7 on: February 24, 2013, 06:22:23 AM »
Ok, found a way to trick resume and have it wait for slow usb devices without a need of adding a particular mechanism into initramfs:

1. Comment the "resume device =" line in /etc/suspend.conf out
2. Run the script
3. After creation of the cpio archive uncomment above line again
4. s2disk (or s2both if preferred)
5. When booting the initramfs, resume will prompt for path to device, type
    "/dev/sdXN", wait until device is ready and then hit "Enter"

 ;D
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #8 on: February 24, 2013, 08:48:18 PM »
Update:

version 1.0.1

Changes:

-- Path to resume does no longer depend on mode
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #9 on: February 25, 2013, 03:28:02 PM »
do you think that it's possible to adjust the script that it can be used for a live-usbstick?
Script modified to add 10 seconds of sleep to wait for slow devices to be initialized (value can be edited as required).

Caveat:
Requires a statically linked busybox featuring "sh" and "sleep" applets to be placed in dir of execution.
For optimization consider compiling busybox statically linked including "sh" (ash) and "sleep" only.

For testing purposes I used a busybox binary as provided by busybox.net which results in an initrd of 749Kb (instead of 215Kb without any other binaries besides from resume).
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: tinywake - resume from s2disk with size and speed optimization
« Reply #10 on: February 27, 2013, 10:43:14 PM »
Update:

tinywake.sh

version 1.0.2

Changes:

-- Change dir to /tmp/ to prevent attempt of mastering cpio archive on incompatible filesystem

-------------------------------------------------------------------------------------------------

wakeusb.sh

version 0.1.1 (BETA)

Changes:

-- Change dir to /tmp/ after copying busybox first from current dir to prevent attempt of mastering
    cpio archive on incompatible filesystem

"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)