tuxonice.txt 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. --- TuxOnIce, version 3.0 ---
  2. 1. What is it?
  3. 2. Why would you want it?
  4. 3. What do you need to use it?
  5. 4. Why not just use the version already in the kernel?
  6. 5. How do you use it?
  7. 6. What do all those entries in /sys/power/tuxonice do?
  8. 7. How do you get support?
  9. 8. I think I've found a bug. What should I do?
  10. 9. When will XXX be supported?
  11. 10 How does it work?
  12. 11. Who wrote TuxOnIce?
  13. 1. What is it?
  14. Imagine you're sitting at your computer, working away. For some reason, you
  15. need to turn off your computer for a while - perhaps it's time to go home
  16. for the day. When you come back to your computer next, you're going to want
  17. to carry on where you left off. Now imagine that you could push a button and
  18. have your computer store the contents of its memory to disk and power down.
  19. Then, when you next start up your computer, it loads that image back into
  20. memory and you can carry on from where you were, just as if you'd never
  21. turned the computer off. You have far less time to start up, no reopening of
  22. applications or finding what directory you put that file in yesterday.
  23. That's what TuxOnIce does.
  24. TuxOnIce has a long heritage. It began life as work by Gabor Kuti, who,
  25. with some help from Pavel Machek, got an early version going in 1999. The
  26. project was then taken over by Florent Chabaud while still in alpha version
  27. numbers. Nigel Cunningham came on the scene when Florent was unable to
  28. continue, moving the project into betas, then 1.0, 2.0 and so on up to
  29. the present series. During the 2.0 series, the name was contracted to
  30. Suspend2 and the website suspend2.net created. Beginning around July 2007,
  31. a transition to calling the software TuxOnIce was made, to seek to help
  32. make it clear that TuxOnIce is more concerned with hibernation than suspend
  33. to ram.
  34. Pavel Machek's swsusp code, which was merged around 2.5.17 retains the
  35. original name, and was essentially a fork of the beta code until Rafael
  36. Wysocki came on the scene in 2005 and began to improve it further.
  37. 2. Why would you want it?
  38. Why wouldn't you want it?
  39. Being able to save the state of your system and quickly restore it improves
  40. your productivity - you get a useful system in far less time than through
  41. the normal boot process. You also get to be completely 'green', using zero
  42. power, or as close to that as possible (the computer may still provide
  43. minimal power to some devices, so they can initiate a power on, but that
  44. will be the same amount of power as would be used if you told the computer
  45. to shutdown.
  46. 3. What do you need to use it?
  47. a. Kernel Support.
  48. i) The TuxOnIce patch.
  49. TuxOnIce is part of the Linux Kernel. This version is not part of Linus's
  50. 2.6 tree at the moment, so you will need to download the kernel source and
  51. apply the latest patch. Having done that, enable the appropriate options in
  52. make [menu|x]config (under Power Management Options - look for "Enhanced
  53. Hibernation"), compile and install your kernel. TuxOnIce works with SMP,
  54. Highmem, preemption, fuse filesystems, x86-32, PPC and x86_64.
  55. TuxOnIce patches are available from http://tuxonice.net.
  56. ii) Compression support.
  57. Compression support is implemented via the cryptoapi. You will therefore want
  58. to select any Cryptoapi transforms that you want to use on your image from
  59. the Cryptoapi menu while configuring your kernel. We recommend the use of the
  60. LZO compression method - it is very fast and still achieves good compression.
  61. You can also tell TuxOnIce to write its image to an encrypted and/or
  62. compressed filesystem/swap partition. In that case, you don't need to do
  63. anything special for TuxOnIce when it comes to kernel configuration.
  64. iii) Configuring other options.
  65. While you're configuring your kernel, try to configure as much as possible
  66. to build as modules. We recommend this because there are a number of drivers
  67. that are still in the process of implementing proper power management
  68. support. In those cases, the best way to work around their current lack is
  69. to build them as modules and remove the modules while hibernating. You might
  70. also bug the driver authors to get their support up to speed, or even help!
  71. b. Storage.
  72. i) Swap.
  73. TuxOnIce can store the hibernation image in your swap partition, a swap file or
  74. a combination thereof. Whichever combination you choose, you will probably
  75. want to create enough swap space to store the largest image you could have,
  76. plus the space you'd normally use for swap. A good rule of thumb would be
  77. to calculate the amount of swap you'd want without using TuxOnIce, and then
  78. add the amount of memory you have. This swapspace can be arranged in any way
  79. you'd like. It can be in one partition or file, or spread over a number. The
  80. only requirement is that they be active when you start a hibernation cycle.
  81. There is one exception to this requirement. TuxOnIce has the ability to turn
  82. on one swap file or partition at the start of hibernating and turn it back off
  83. at the end. If you want to ensure you have enough memory to store a image
  84. when your memory is fully used, you might want to make one swap partition or
  85. file for 'normal' use, and another for TuxOnIce to activate & deactivate
  86. automatically. (Further details below).
  87. ii) Normal files.
  88. TuxOnIce includes a 'file allocator'. The file allocator can store your
  89. image in a simple file. Since Linux has the concept of everything being a
  90. file, this is more powerful than it initially sounds. If, for example, you
  91. were to set up a network block device file, you could hibernate to a network
  92. server. This has been tested and works to a point, but nbd itself isn't
  93. stateless enough for our purposes.
  94. Take extra care when setting up the file allocator. If you just type
  95. commands without thinking and then try to hibernate, you could cause
  96. irreversible corruption on your filesystems! Make sure you have backups.
  97. Most people will only want to hibernate to a local file. To achieve that, do
  98. something along the lines of:
  99. echo "TuxOnIce" > /hibernation-file
  100. dd if=/dev/zero bs=1M count=512 >> /hibernation-file
  101. This will create a 512MB file called /hibernation-file. To get TuxOnIce to use
  102. it:
  103. echo /hibernation-file > /sys/power/tuxonice/file/target
  104. Then
  105. cat /sys/power/tuxonice/resume
  106. Put the results of this into your bootloader's configuration (see also step
  107. C, below):
  108. ---EXAMPLE-ONLY-DON'T-COPY-AND-PASTE---
  109. # cat /sys/power/tuxonice/resume
  110. file:/dev/hda2:0x1e001
  111. In this example, we would edit the append= line of our lilo.conf|menu.lst
  112. so that it included:
  113. resume=file:/dev/hda2:0x1e001
  114. ---EXAMPLE-ONLY-DON'T-COPY-AND-PASTE---
  115. For those who are thinking 'Could I make the file sparse?', the answer is
  116. 'No!'. At the moment, there is no way for TuxOnIce to fill in the holes in
  117. a sparse file while hibernating. In the longer term (post merge!), I'd like
  118. to change things so that the file could be dynamically resized and have
  119. holes filled as needed. Right now, however, that's not possible and not a
  120. priority.
  121. c. Bootloader configuration.
  122. Using TuxOnIce also requires that you add an extra parameter to
  123. your lilo.conf or equivalent. Here's an example for a swap partition:
  124. append="resume=swap:/dev/hda1"
  125. This would tell TuxOnIce that /dev/hda1 is a swap partition you
  126. have. TuxOnIce will use the swap signature of this partition as a
  127. pointer to your data when you hibernate. This means that (in this example)
  128. /dev/hda1 doesn't need to be _the_ swap partition where all of your data
  129. is actually stored. It just needs to be a swap partition that has a
  130. valid signature.
  131. You don't need to have a swap partition for this purpose. TuxOnIce
  132. can also use a swap file, but usage is a little more complex. Having made
  133. your swap file, turn it on and do
  134. cat /sys/power/tuxonice/swap/headerlocations
  135. (this assumes you've already compiled your kernel with TuxOnIce
  136. support and booted it). The results of the cat command will tell you
  137. what you need to put in lilo.conf:
  138. For swap partitions like /dev/hda1, simply use resume=/dev/hda1.
  139. For swapfile `swapfile`, use resume=swap:/dev/hda2:0x242d.
  140. If the swapfile changes for any reason (it is moved to a different
  141. location, it is deleted and recreated, or the filesystem is
  142. defragmented) then you will have to check
  143. /sys/power/tuxonice/swap/headerlocations for a new resume_block value.
  144. Once you've compiled and installed the kernel and adjusted your bootloader
  145. configuration, you should only need to reboot for the most basic part
  146. of TuxOnIce to be ready.
  147. If you only compile in the swap allocator, or only compile in the file
  148. allocator, you don't need to add the "swap:" part of the resume=
  149. parameters above. resume=/dev/hda2:0x242d will work just as well. If you
  150. have compiled both and your storage is on swap, you can also use this
  151. format (the swap allocator is the default allocator).
  152. When compiling your kernel, one of the options in the 'Power Management
  153. Support' menu, just above the 'Enhanced Hibernation (TuxOnIce)' entry is
  154. called 'Default resume partition'. This can be used to set a default value
  155. for the resume= parameter.
  156. d. The hibernate script.
  157. Since the driver model in 2.6 kernels is still being developed, you may need
  158. to do more than just configure TuxOnIce. Users of TuxOnIce usually start the
  159. process via a script which prepares for the hibernation cycle, tells the
  160. kernel to do its stuff and then restore things afterwards. This script might
  161. involve:
  162. - Switching to a text console and back if X doesn't like the video card
  163. status on resume.
  164. - Un/reloading drivers that don't play well with hibernation.
  165. Note that you might not be able to unload some drivers if there are
  166. processes using them. You might have to kill off processes that hold
  167. devices open. Hint: if your X server accesses an USB mouse, doing a
  168. 'chvt' to a text console releases the device and you can unload the
  169. module.
  170. Check out the latest script (available on tuxonice.net).
  171. e. The userspace user interface.
  172. TuxOnIce has very limited support for displaying status if you only apply
  173. the kernel patch - it can printk messages, but that is all. In addition,
  174. some of the functions mentioned in this document (such as cancelling a cycle
  175. or performing interactive debugging) are unavailable. To utilise these
  176. functions, or simply get a nice display, you need the 'userui' component.
  177. Userui comes in three flavours, usplash, fbsplash and text. Text should
  178. work on any console. Usplash and fbsplash require the appropriate
  179. (distro specific?) support.
  180. To utilise a userui, TuxOnIce just needs to be told where to find the
  181. userspace binary:
  182. echo "/usr/local/sbin/tuxoniceui_fbsplash" > /sys/power/tuxonice/user_interface/program
  183. The hibernate script can do this for you, and a default value for this
  184. setting can be configured when compiling the kernel. This path is also
  185. stored in the image header, so if you have an initrd or initramfs, you can
  186. use the userui during the first part of resuming (prior to the atomic
  187. restore) by putting the binary in the same path in your initrd/ramfs.
  188. Alternatively, you can put it in a different location and do an echo
  189. similar to the above prior to the echo > do_resume. The value saved in the
  190. image header will then be ignored.
  191. 4. Why not just use the version already in the kernel?
  192. The version in the vanilla kernel has a number of drawbacks. The most
  193. serious of these are:
  194. - it has a maximum image size of 1/2 total memory;
  195. - it doesn't allocate storage until after it has snapshotted memory.
  196. This means that you can't be sure hibernating will work until you
  197. see it start to write the image;
  198. - it does not allow you to press escape to cancel a cycle;
  199. - it does not allow you to press escape to cancel resuming;
  200. - it does not allow you to automatically swapon a file when
  201. starting a cycle;
  202. - it does not allow you to use multiple swap partitions or files;
  203. - it does not allow you to use ordinary files;
  204. - it just invalidates an image and continues to boot if you
  205. accidentally boot the wrong kernel after hibernating;
  206. - it doesn't support any sort of nice display while hibernating;
  207. - it is moving toward requiring that you have an initrd/initramfs
  208. to ever have a hope of resuming (uswsusp). While uswsusp will
  209. address some of the concerns above, it won't address all of them,
  210. and will be more complicated to get set up;
  211. - it doesn't have support for suspend-to-both (write a hibernation
  212. image, then suspend to ram; I think this is known as ReadySafe
  213. under M$).
  214. 5. How do you use it?
  215. A hibernation cycle can be started directly by doing:
  216. echo > /sys/power/tuxonice/do_hibernate
  217. In practice, though, you'll probably want to use the hibernate script
  218. to unload modules, configure the kernel the way you like it and so on.
  219. In that case, you'd do (as root):
  220. hibernate
  221. See the hibernate script's man page for more details on the options it
  222. takes.
  223. If you're using the text or splash user interface modules, one feature of
  224. TuxOnIce that you might find useful is that you can press Escape at any time
  225. during hibernating, and the process will be aborted.
  226. Due to the way hibernation works, this means you'll have your system back and
  227. perfectly usable almost instantly. The only exception is when it's at the
  228. very end of writing the image. Then it will need to reload a small (usually
  229. 4-50MBs, depending upon the image characteristics) portion first.
  230. Likewise, when resuming, you can press escape and resuming will be aborted.
  231. The computer will then powerdown again according to settings at that time for
  232. the powerdown method or rebooting.
  233. You can change the settings for powering down while the image is being
  234. written by pressing 'R' to toggle rebooting and 'O' to toggle between
  235. suspending to ram and powering down completely).
  236. If you run into problems with resuming, adding the "noresume" option to
  237. the kernel command line will let you skip the resume step and recover your
  238. system. This option shouldn't normally be needed, because TuxOnIce modifies
  239. the image header prior to the atomic restore, and will thus prompt you
  240. if it detects that you've tried to resume an image before (this flag is
  241. removed if you press Escape to cancel a resume, so you won't be prompted
  242. then).
  243. Recent kernels (2.6.24 onwards) add support for resuming from a different
  244. kernel to the one that was hibernated (thanks to Rafael for his work on
  245. this - I've just embraced and enhanced the support for TuxOnIce). This
  246. should further reduce the need for you to use the noresume option.
  247. 6. What do all those entries in /sys/power/tuxonice do?
  248. /sys/power/tuxonice is the directory which contains files you can use to
  249. tune and configure TuxOnIce to your liking. The exact contents of
  250. the directory will depend upon the version of TuxOnIce you're
  251. running and the options you selected at compile time. In the following
  252. descriptions, names in brackets refer to compile time options.
  253. (Note that they're all dependent upon you having selected CONFIG_TUXONICE
  254. in the first place!).
  255. Since the values of these settings can open potential security risks, the
  256. writeable ones are accessible only to the root user. You may want to
  257. configure sudo to allow you to invoke your hibernate script as an ordinary
  258. user.
  259. - alloc/failure_test
  260. This debugging option provides a way of testing TuxOnIce's handling of
  261. memory allocation failures. Each allocation type that TuxOnIce makes has
  262. been given a unique number (see the source code). Echo the appropriate
  263. number into this entry, and when TuxOnIce attempts to do that allocation,
  264. it will pretend there was a failure and act accordingly.
  265. - alloc/find_max_mem_allocated
  266. This debugging option will cause TuxOnIce to find the maximum amount of
  267. memory it used during a cycle, and report that information in debugging
  268. information at the end of the cycle.
  269. - alt_resume_param
  270. Instead of powering down after writing a hibernation image, TuxOnIce
  271. supports resuming from a different image. This entry lets you set the
  272. location of the signature for that image (the resume= value you'd use
  273. for it). Using an alternate image and keep_image mode, you can do things
  274. like using an alternate image to power down an uninterruptible power
  275. supply.
  276. - block_io/target_outstanding_io
  277. This value controls the amount of memory that the block I/O code says it
  278. needs when the core code is calculating how much memory is needed for
  279. hibernating and for resuming. It doesn't directly control the amount of
  280. I/O that is submitted at any one time - that depends on the amount of
  281. available memory (we may have more available than we asked for), the
  282. throughput that is being achieved and the ability of the CPU to keep up
  283. with disk throughput (particularly where we're compressing pages).
  284. - checksum/enabled
  285. Use cryptoapi hashing routines to verify that Pageset2 pages don't change
  286. while we're saving the first part of the image, and to get any pages that
  287. do change resaved in the atomic copy. This should normally not be needed,
  288. but if you're seeing issues, please enable this. If your issues stop you
  289. being able to resume, enable this option, hibernate and cancel the cycle
  290. after the atomic copy is done. If the debugging info shows a non-zero
  291. number of pages resaved, please report this to Nigel.
  292. - compression/algorithm
  293. Set the cryptoapi algorithm used for compressing the image.
  294. - compression/expected_compression
  295. These values allow you to set an expected compression ratio, which TuxOnice
  296. will use in calculating whether it meets constraints on the image size. If
  297. this expected compression ratio is not attained, the hibernation cycle will
  298. abort, so it is wise to allow some spare. You can see what compression
  299. ratio is achieved in the logs after hibernating.
  300. - debug_info:
  301. This file returns information about your configuration that may be helpful
  302. in diagnosing problems with hibernating.
  303. - did_suspend_to_both:
  304. This file can be used when you hibernate with powerdown method 3 (ie suspend
  305. to ram after writing the image). There can be two outcomes in this case. We
  306. can resume from the suspend-to-ram before the battery runs out, or we can run
  307. out of juice and and up resuming like normal. This entry lets you find out,
  308. post resume, which way we went. If the value is 1, we resumed from suspend
  309. to ram. This can be useful when actions need to be run post suspend-to-ram
  310. that don't need to be run if we did the normal resume from power off.
  311. - do_hibernate:
  312. When anything is written to this file, the kernel side of TuxOnIce will
  313. begin to attempt to write an image to disk and power down. You'll normally
  314. want to run the hibernate script instead, to get modules unloaded first.
  315. - do_resume:
  316. When anything is written to this file TuxOnIce will attempt to read and
  317. restore an image. If there is no image, it will return almost immediately.
  318. If an image exists, the echo > will never return. Instead, the original
  319. kernel context will be restored and the original echo > do_hibernate will
  320. return.
  321. - */enabled
  322. These option can be used to temporarily disable various parts of TuxOnIce.
  323. - extra_pages_allowance
  324. When TuxOnIce does its atomic copy, it calls the driver model suspend
  325. and resume methods. If you have DRI enabled with a driver such as fglrx,
  326. this can result in the driver allocating a substantial amount of memory
  327. for storing its state. Extra_pages_allowance tells TuxOnIce how much
  328. extra memory it should ensure is available for those allocations. If
  329. your attempts at hibernating end with a message in dmesg indicating that
  330. insufficient extra pages were allowed, you need to increase this value.
  331. - file/target:
  332. Read this value to get the current setting. Write to it to point TuxOnice
  333. at a new storage location for the file allocator. See section 3.b.ii above
  334. for details of how to set up the file allocator.
  335. - freezer_test
  336. This entry can be used to get TuxOnIce to just test the freezer and prepare
  337. an image without actually doing a hibernation cycle. It is useful for
  338. diagnosing freezing and image preparation issues.
  339. - full_pageset2
  340. TuxOnIce divides the pages that are stored in an image into two sets. The
  341. difference between the two sets is that pages in pageset 1 are atomically
  342. copied, and pages in pageset 2 are written to disk without being copied
  343. first. A page CAN be written to disk without being copied first if and only
  344. if its contents will not be modified or used at any time after userspace
  345. processes are frozen. A page MUST be in pageset 1 if its contents are
  346. modified or used at any time after userspace processes have been frozen.
  347. Normally (ie if this option is enabled), TuxOnIce will put all pages on the
  348. per-zone LRUs in pageset2, then remove those pages used by any userspace
  349. user interface helper and TuxOnIce storage manager that are running,
  350. together with pages used by the GEM memory manager introduced around 2.6.28
  351. kernels.
  352. If this option is disabled, a much more conservative approach will be taken.
  353. The only pages in pageset2 will be those belonging to userspace processes,
  354. with the exclusion of those belonging to the TuxOnIce userspace helpers
  355. mentioned above. This will result in a much smaller pageset2, and will
  356. therefore result in smaller images than are possible with this option
  357. enabled.
  358. - ignore_rootfs
  359. TuxOnIce records which device is mounted as the root filesystem when
  360. writing the hibernation image. It will normally check at resume time that
  361. this device isn't already mounted - that would be a cause of filesystem
  362. corruption. In some particular cases (RAM based root filesystems), you
  363. might want to disable this check. This option allows you to do that.
  364. - image_exists:
  365. Can be used in a script to determine whether a valid image exists at the
  366. location currently pointed to by resume=. Returns up to three lines.
  367. The first is whether an image exists (-1 for unsure, otherwise 0 or 1).
  368. If an image eixsts, additional lines will return the machine and version.
  369. Echoing anything to this entry removes any current image.
  370. - image_size_limit:
  371. The maximum size of hibernation image written to disk, measured in megabytes
  372. (1024*1024).
  373. - last_result:
  374. The result of the last hibernation cycle, as defined in
  375. include/linux/suspend-debug.h with the values SUSPEND_ABORTED to
  376. SUSPEND_KEPT_IMAGE. This is a bitmask.
  377. - late_cpu_hotplug:
  378. This sysfs entry controls whether cpu hotplugging is done - as normal - just
  379. before (unplug) and after (replug) the atomic copy/restore (so that all
  380. CPUs/cores are available for multithreaded I/O). The alternative is to
  381. unplug all secondary CPUs/cores at the start of hibernating/resuming, and
  382. replug them at the end of resuming. No multithreaded I/O will be possible in
  383. this configuration, but the odd machine has been reported to require it.
  384. - lid_file:
  385. This determines which ACPI button file we look in to determine whether the
  386. lid is open or closed after resuming from suspend to disk or power off.
  387. If the entry is set to "lid/LID", we'll open /proc/acpi/button/lid/LID/state
  388. and check its contents at the appropriate moment. See post_wake_state below
  389. for more details on how this entry is used.
  390. - log_everything (CONFIG_PM_DEBUG):
  391. Setting this option results in all messages printed being logged. Normally,
  392. only a subset are logged, so as to not slow the process and not clutter the
  393. logs. Useful for debugging. It can be toggled during a cycle by pressing
  394. 'L'.
  395. - no_load_direct:
  396. This is a debugging option. If, when loading the atomically copied pages of
  397. an image, TuxOnIce finds that the destination address for a page is free,
  398. it will normally allocate the image, load the data directly into that
  399. address and skip it in the atomic restore. If this option is disabled, the
  400. page will be loaded somewhere else and atomically restored like other pages.
  401. - no_flusher_thread:
  402. When doing multithreaded I/O (see below), the first online CPU can be used
  403. to _just_ submit compressed pages when writing the image, rather than
  404. compressing and submitting data. This option is normally disabled, but has
  405. been included because Nigel would like to see whether it will be more useful
  406. as the number of cores/cpus in computers increases.
  407. - no_multithreaded_io:
  408. TuxOnIce will normally create one thread per cpu/core on your computer,
  409. each of which will then perform I/O. This will generally result in
  410. throughput that's the maximum the storage medium can handle. There
  411. shouldn't be any reason to disable multithreaded I/O now, but this option
  412. has been retained for debugging purposes.
  413. - no_pageset2
  414. See the entry for full_pageset2 above for an explanation of pagesets.
  415. Enabling this option causes TuxOnIce to do an atomic copy of all pages,
  416. thereby limiting the maximum image size to 1/2 of memory, as swsusp does.
  417. - no_pageset2_if_unneeded
  418. See the entry for full_pageset2 above for an explanation of pagesets.
  419. Enabling this option causes TuxOnIce to act like no_pageset2 was enabled
  420. if and only it isn't needed anyway. This option may still make TuxOnIce
  421. less reliable because pageset2 pages are normally used to store the
  422. atomic copy - drivers that want to do allocations of larger amounts of
  423. memory in one shot will be more likely to find that those amounts aren't
  424. available if this option is enabled.
  425. - pause_between_steps (CONFIG_PM_DEBUG):
  426. This option is used during debugging, to make TuxOnIce pause between
  427. each step of the process. It is ignored when the nice display is on.
  428. - post_wake_state:
  429. TuxOnIce provides support for automatically waking after a user-selected
  430. delay, and using a different powerdown method if the lid is still closed.
  431. (Yes, we're assuming a laptop). This entry lets you choose what state
  432. should be entered next. The values are those described under
  433. powerdown_method, below. It can be used to suspend to RAM after hibernating,
  434. then powerdown properly (say) 20 minutes. It can also be used to power down
  435. properly, then wake at (say) 6.30am and suspend to RAM until you're ready
  436. to use the machine.
  437. - powerdown_method:
  438. Used to select a method by which TuxOnIce should powerdown after writing the
  439. image. Currently:
  440. 0: Don't use ACPI to power off.
  441. 3: Attempt to enter Suspend-to-ram.
  442. 4: Attempt to enter ACPI S4 mode.
  443. 5: Attempt to power down via ACPI S5 mode.
  444. Note that these options are highly dependent upon your hardware & software:
  445. 3: When successful, your machine suspends to ram instead of powering off.
  446. The advantage of using this mode is that it doesn't matter whether your
  447. battery has enough charge to make it through to your next resume. If it
  448. lasts, you will simply resume from suspend to ram (and the image on disk
  449. will be discarded). If the battery runs out, you will resume from disk
  450. instead. The disadvantage is that it takes longer than a normal
  451. suspend-to-ram to enter the state, since the suspend-to-disk image needs
  452. to be written first.
  453. 4/5: When successful, your machine will be off and comsume (almost) no power.
  454. But it might still react to some external events like opening the lid or
  455. trafic on a network or usb device. For the bios, resume is then the same
  456. as warm boot, similar to a situation where you used the command `reboot'
  457. to reboot your machine. If your machine has problems on warm boot or if
  458. you want to protect your machine with the bios password, this is probably
  459. not the right choice. Mode 4 may be necessary on some machines where ACPI
  460. wake up methods need to be run to properly reinitialise hardware after a
  461. hibernation cycle.
  462. 0: Switch the machine completely off. The only possible wakeup is the power
  463. button. For the bios, resume is then the same as a cold boot, in
  464. particular you would have to provide your bios boot password if your
  465. machine uses that feature for booting.
  466. - progressbar_granularity_limit:
  467. This option can be used to limit the granularity of the progress bar
  468. displayed with a bootsplash screen. The value is the maximum number of
  469. steps. That is, 10 will make the progress bar jump in 10% increments.
  470. - reboot:
  471. This option causes TuxOnIce to reboot rather than powering down
  472. at the end of saving an image. It can be toggled during a cycle by pressing
  473. 'R'.
  474. - resume:
  475. This sysfs entry can be used to read and set the location in which TuxOnIce
  476. will look for the signature of an image - the value set using resume= at
  477. boot time or CONFIG_PM_STD_PARTITION ("Default resume partition"). By
  478. writing to this file as well as modifying your bootloader's configuration
  479. file (eg menu.lst), you can set or reset the location of your image or the
  480. method of storing the image without rebooting.
  481. - replace_swsusp (CONFIG_TOI_REPLACE_SWSUSP):
  482. This option makes
  483. echo disk > /sys/power/state
  484. activate TuxOnIce instead of swsusp. Regardless of whether this option is
  485. enabled, any invocation of swsusp's resume time trigger will cause TuxOnIce
  486. to check for an image too. This is due to the fact that at resume time, we
  487. can't know whether this option was enabled until we see if an image is there
  488. for us to resume from. (And when an image exists, we don't care whether we
  489. did replace swsusp anyway - we just want to resume).
  490. - resume_commandline:
  491. This entry can be read after resuming to see the commandline that was used
  492. when resuming began. You might use this to set up two bootloader entries
  493. that are the same apart from the fact that one includes a extra append=
  494. argument "at_work=1". You could then grep resume_commandline in your
  495. post-resume scripts and configure networking (for example) differently
  496. depending upon whether you're at home or work. resume_commandline can be
  497. set to arbitrary text if you wish to remove sensitive contents.
  498. - swap/swapfilename:
  499. This entry is used to specify the swapfile or partition that
  500. TuxOnIce will attempt to swapon/swapoff automatically. Thus, if
  501. I normally use /dev/hda1 for swap, and want to use /dev/hda2 for specifically
  502. for my hibernation image, I would
  503. echo /dev/hda2 > /sys/power/tuxonice/swap/swapfile
  504. /dev/hda2 would then be automatically swapon'd and swapoff'd. Note that the
  505. swapon and swapoff occur while other processes are frozen (including kswapd)
  506. so this swap file will not be used up when attempting to free memory. The
  507. parition/file is also given the highest priority, so other swapfiles/partitions
  508. will only be used to save the image when this one is filled.
  509. The value of this file is used by headerlocations along with any currently
  510. activated swapfiles/partitions.
  511. - swap/headerlocations:
  512. This option tells you the resume= options to use for swap devices you
  513. currently have activated. It is particularly useful when you only want to
  514. use a swap file to store your image. See above for further details.
  515. - test_bio
  516. This is a debugging option. When enabled, TuxOnIce will not hibernate.
  517. Instead, when asked to write an image, it will skip the atomic copy,
  518. just doing the writing of the image and then returning control to the
  519. user at the point where it would have powered off. This is useful for
  520. testing throughput in different configurations.
  521. - test_filter_speed
  522. This is a debugging option. When enabled, TuxOnIce will not hibernate.
  523. Instead, when asked to write an image, it will not write anything or do
  524. an atomic copy, but will only run any enabled compression algorithm on the
  525. data that would have been written (the source pages of the atomic copy in
  526. the case of pageset 1). This is useful for comparing the performance of
  527. compression algorithms and for determining the extent to which an upgrade
  528. to your storage method would improve hibernation speed.
  529. - user_interface/debug_sections (CONFIG_PM_DEBUG):
  530. This value, together with the console log level, controls what debugging
  531. information is displayed. The console log level determines the level of
  532. detail, and this value determines what detail is displayed. This value is
  533. a bit vector, and the meaning of the bits can be found in the kernel tree
  534. in include/linux/tuxonice.h. It can be overridden using the kernel's
  535. command line option suspend_dbg.
  536. - user_interface/default_console_level (CONFIG_PM_DEBUG):
  537. This determines the value of the console log level at the start of a
  538. hibernation cycle. If debugging is compiled in, the console log level can be
  539. changed during a cycle by pressing the digit keys. Meanings are:
  540. 0: Nice display.
  541. 1: Nice display plus numerical progress.
  542. 2: Errors only.
  543. 3: Low level debugging info.
  544. 4: Medium level debugging info.
  545. 5: High level debugging info.
  546. 6: Verbose debugging info.
  547. - user_interface/enable_escape:
  548. Setting this to "1" will enable you abort a hibernation cycle or resuming by
  549. pressing escape, "0" (default) disables this feature. Note that enabling
  550. this option means that you cannot initiate a hibernation cycle and then walk
  551. away from your computer, expecting it to be secure. With feature disabled,
  552. you can validly have this expectation once TuxOnice begins to write the
  553. image to disk. (Prior to this point, it is possible that TuxOnice might
  554. about because of failure to freeze all processes or because constraints
  555. on its ability to save the image are not met).
  556. - user_interface/program
  557. This entry is used to tell TuxOnice what userspace program to use for
  558. providing a user interface while hibernating. The program uses a netlink
  559. socket to pass messages back and forward to the kernel, allowing all of the
  560. functions formerly implemented in the kernel user interface components.
  561. - version:
  562. The version of TuxOnIce you have compiled into the currently running kernel.
  563. - wake_alarm_dir:
  564. As mentioned above (post_wake_state), TuxOnIce supports automatically waking
  565. after some delay. This entry allows you to select which wake alarm to use.
  566. It should contain the value "rtc0" if you're wanting to use
  567. /sys/class/rtc/rtc0.
  568. - wake_delay:
  569. This value determines the delay from the end of writing the image until the
  570. wake alarm is triggered. You can set an absolute time by writing the desired
  571. time into /sys/class/rtc/<wake_alarm_dir>/wakealarm and leaving these values
  572. empty.
  573. Note that for the wakeup to actually occur, you may need to modify entries
  574. in /proc/acpi/wakeup. This is done by echoing the name of the button in the
  575. first column (eg PBTN) into the file.
  576. 7. How do you get support?
  577. Glad you asked. TuxOnIce is being actively maintained and supported
  578. by Nigel (the guy doing most of the kernel coding at the moment), Bernard
  579. (who maintains the hibernate script and userspace user interface components)
  580. and its users.
  581. Resources available include HowTos, FAQs and a Wiki, all available via
  582. tuxonice.net. You can find the mailing lists there.
  583. 8. I think I've found a bug. What should I do?
  584. By far and a way, the most common problems people have with TuxOnIce
  585. related to drivers not having adequate power management support. In this
  586. case, it is not a bug with TuxOnIce, but we can still help you. As we
  587. mentioned above, such issues can usually be worked around by building the
  588. functionality as modules and unloading them while hibernating. Please visit
  589. the Wiki for up-to-date lists of known issues and work arounds.
  590. If this information doesn't help, try running:
  591. hibernate --bug-report
  592. ..and sending the output to the users mailing list.
  593. Good information on how to provide us with useful information from an
  594. oops is found in the file REPORTING-BUGS, in the top level directory
  595. of the kernel tree. If you get an oops, please especially note the
  596. information about running what is printed on the screen through ksymoops.
  597. The raw information is useless.
  598. 9. When will XXX be supported?
  599. If there's a feature missing from TuxOnIce that you'd like, feel free to
  600. ask. We try to be obliging, within reason.
  601. Patches are welcome. Please send to the list.
  602. 10. How does it work?
  603. TuxOnIce does its work in a number of steps.
  604. a. Freezing system activity.
  605. The first main stage in hibernating is to stop all other activity. This is
  606. achieved in stages. Processes are considered in fours groups, which we will
  607. describe in reverse order for clarity's sake: Threads with the PF_NOFREEZE
  608. flag, kernel threads without this flag, userspace processes with the
  609. PF_SYNCTHREAD flag and all other processes. The first set (PF_NOFREEZE) are
  610. untouched by the refrigerator code. They are allowed to run during hibernating
  611. and resuming, and are used to support user interaction, storage access or the
  612. like. Other kernel threads (those unneeded while hibernating) are frozen last.
  613. This leaves us with userspace processes that need to be frozen. When a
  614. process enters one of the *_sync system calls, we set a PF_SYNCTHREAD flag on
  615. that process for the duration of that call. Processes that have this flag are
  616. frozen after processes without it, so that we can seek to ensure that dirty
  617. data is synced to disk as quickly as possible in a situation where other
  618. processes may be submitting writes at the same time. Freezing the processes
  619. that are submitting data stops new I/O from being submitted. Syncthreads can
  620. then cleanly finish their work. So the order is:
  621. - Userspace processes without PF_SYNCTHREAD or PF_NOFREEZE;
  622. - Userspace processes with PF_SYNCTHREAD (they won't have NOFREEZE);
  623. - Kernel processes without PF_NOFREEZE.
  624. b. Eating memory.
  625. For a successful hibernation cycle, you need to have enough disk space to store the
  626. image and enough memory for the various limitations of TuxOnIce's
  627. algorithm. You can also specify a maximum image size. In order to attain
  628. to those constraints, TuxOnIce may 'eat' memory. If, after freezing
  629. processes, the constraints aren't met, TuxOnIce will thaw all the
  630. other processes and begin to eat memory until its calculations indicate
  631. the constraints are met. It will then freeze processes again and recheck
  632. its calculations.
  633. c. Allocation of storage.
  634. Next, TuxOnIce allocates the storage that will be used to save
  635. the image.
  636. The core of TuxOnIce knows nothing about how or where pages are stored. We
  637. therefore request the active allocator (remember you might have compiled in
  638. more than one!) to allocate enough storage for our expect image size. If
  639. this request cannot be fulfilled, we eat more memory and try again. If it
  640. is fulfiled, we seek to allocate additional storage, just in case our
  641. expected compression ratio (if any) isn't achieved. This time, however, we
  642. just continue if we can't allocate enough storage.
  643. If these calls to our allocator change the characteristics of the image
  644. such that we haven't allocated enough memory, we also loop. (The allocator
  645. may well need to allocate space for its storage information).
  646. d. Write the first part of the image.
  647. TuxOnIce stores the image in two sets of pages called 'pagesets'.
  648. Pageset 2 contains pages on the active and inactive lists; essentially
  649. the page cache. Pageset 1 contains all other pages, including the kernel.
  650. We use two pagesets for one important reason: We need to make an atomic copy
  651. of the kernel to ensure consistency of the image. Without a second pageset,
  652. that would limit us to an image that was at most half the amount of memory
  653. available. Using two pagesets allows us to store a full image. Since pageset
  654. 2 pages won't be needed in saving pageset 1, we first save pageset 2 pages.
  655. We can then make our atomic copy of the remaining pages using both pageset 2
  656. pages and any other pages that are free. While saving both pagesets, we are
  657. careful not to corrupt the image. Among other things, we use lowlevel block
  658. I/O routines that don't change the pagecache contents.
  659. The next step, then, is writing pageset 2.
  660. e. Suspending drivers and storing processor context.
  661. Having written pageset2, TuxOnIce calls the power management functions to
  662. notify drivers of the hibernation, and saves the processor state in preparation
  663. for the atomic copy of memory we are about to make.
  664. f. Atomic copy.
  665. At this stage, everything else but the TuxOnIce code is halted. Processes
  666. are frozen or idling, drivers are quiesced and have stored (ideally and where
  667. necessary) their configuration in memory we are about to atomically copy.
  668. In our lowlevel architecture specific code, we have saved the CPU state.
  669. We can therefore now do our atomic copy before resuming drivers etc.
  670. g. Save the atomic copy (pageset 1).
  671. TuxOnice can then write the atomic copy of the remaining pages. Since we
  672. have copied the pages into other locations, we can continue to use the
  673. normal block I/O routines without fear of corruption our image.
  674. f. Save the image header.
  675. Nearly there! We save our settings and other parameters needed for
  676. reloading pageset 1 in an 'image header'. We also tell our allocator to
  677. serialise its data at this stage, so that it can reread the image at resume
  678. time.
  679. g. Set the image header.
  680. Finally, we edit the header at our resume= location. The signature is
  681. changed by the allocator to reflect the fact that an image exists, and to
  682. point to the start of that data if necessary (swap allocator).
  683. h. Power down.
  684. Or reboot if we're debugging and the appropriate option is selected.
  685. Whew!
  686. Reloading the image.
  687. --------------------
  688. Reloading the image is essentially the reverse of all the above. We load
  689. our copy of pageset 1, being careful to choose locations that aren't going
  690. to be overwritten as we copy it back (We start very early in the boot
  691. process, so there are no other processes to quiesce here). We then copy
  692. pageset 1 back to its original location in memory and restore the process
  693. context. We are now running with the original kernel. Next, we reload the
  694. pageset 2 pages, free the memory and swap used by TuxOnIce, restore
  695. the pageset header and restart processes. Sounds easy in comparison to
  696. hibernating, doesn't it!
  697. There is of course more to TuxOnIce than this, but this explanation
  698. should be a good start. If there's interest, I'll write further
  699. documentation on range pages and the low level I/O.
  700. 11. Who wrote TuxOnIce?
  701. (Answer based on the writings of Florent Chabaud, credits in files and
  702. Nigel's limited knowledge; apologies to anyone missed out!)
  703. The main developers of TuxOnIce have been...
  704. Gabor Kuti
  705. Pavel Machek
  706. Florent Chabaud
  707. Bernard Blackham
  708. Nigel Cunningham
  709. Significant portions of swsusp, the code in the vanilla kernel which
  710. TuxOnIce enhances, have been worked on by Rafael Wysocki. Thanks should
  711. also be expressed to him.
  712. The above mentioned developers have been aided in their efforts by a host
  713. of hundreds, if not thousands of testers and people who have submitted bug
  714. fixes & suggestions. Of special note are the efforts of Michael Frank, who
  715. had his computers repetitively hibernate and resume for literally tens of
  716. thousands of cycles and developed scripts to stress the system and test
  717. TuxOnIce far beyond the point most of us (Nigel included!) would consider
  718. testing. His efforts have contributed as much to TuxOnIce as any of the
  719. names above.