个人工具

“UbuntuHelp:Suspend2Kernel”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/Suspend2Kernel}} {{Languages|UbuntuHelp:Suspend2Kernel}} == Building and Using Suspend2 Kernels with Ubuntu == Suspending the activity of a lapt...)
 
 
(未显示同一用户的8个中间版本)
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/Suspend2Kernel}}
 
{{From|https://help.ubuntu.com/community/Suspend2Kernel}}
 
{{Languages|UbuntuHelp:Suspend2Kernel}}
 
{{Languages|UbuntuHelp:Suspend2Kernel}}
 
+
<<Include(Tag/Unsupported)>>
 
+
<<Include(Tag/StyleCleanup)>>
== Building and Using Suspend2 Kernels with Ubuntu ==
+
== Building and Using Tux-on-ice Kernels with Ubuntu ==
Suspending the activity of a laptop or desktop can be one of the most frustrating and buggy parts of the Linux user experience.  Some users find that their problems are significantly eased by using kernels patched with the out-of-tree [http://www.suspend2.net suspend2] code.  This code is not supported by the Ubuntu project, so follow these instructions at your own risk.   More information about suspending in Ubuntu is available at SuspendHowto. 
+
Suspending the activity of a laptop or desktop can be one of the most frustrating and buggy parts of the Linux user experience.  Some users find that their problems are significantly eased by using kernels patched with the out-of-tree [http://www.tuxonice.net tuxonice] code.  This code is not supported by the Ubuntu project. Tuxonice was [http://lists.tuxonice.net/lurker/message/20070702.072738.a09b8c89.en.html previously] known as suspend2. Steps to enable tuxonice in Gutsy gibbon are well documented [http://wiki.tuxonice.net/DistroAndHardwareSetup/Ubuntu_Gutsy_Gibbon here].
 
+
== Changes to initramfs ==
'''NOTE: THIS PAGE IS A WORK IN PROGRESS.  ADD ADDITIONAL INFO IF YOU HAVE IT, AND BE AWARE THERE ARE KNOWN PROBLEMS WITH THIS APPROACH'''
+
It is very important to make changes to your initramfs for tuxonice to work properly. For more information see [http://wiki.tuxonice.net/DistroAndHardwareSetup/Ubuntu_Gutsy_Gibbon here] and this [https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/75616 feature request] report. By default, you can be assured that tuxonice will have no effect on your in-kernel suspend known as [http://suspend.sf.net swsusp].
 
+
== Compiling a tux-on-ice Kernel ==
Read this first: http://lists.suspend2.net/lurker/message/20070208.080654.e8d2b635.en.html it might or might not be needed by the time you try this.
+
There are different ways to do this.   
 
+
=== Method 1: patch the Ubuntu linux-source package ===
=== Compiling a Suspend2 Kernel ===
+
 
+
There are a couple of different ways to do this.   
+
 
+
==== Recommended: patch the linux-source package ====
+
 
The easiest and most straightforward way to create your own kernels is to install the linux-source package and patch the resultant source tree.  It's not hard but requires some work at the command-line:
 
The easiest and most straightforward way to create your own kernels is to install the linux-source package and patch the resultant source tree.  It's not hard but requires some work at the command-line:
 
<pre><nowiki>
 
<pre><nowiki>
第20行: 第15行:
 
cd /usr/src
 
cd /usr/src
 
sudo chown root:admin ./
 
sudo chown root:admin ./
tar xjvf linux-source-2.6.20.tar.bz2
+
tar xjvf linux-source-2.6.XXXXX.tar.bz2
cd linux-source-2.6.20
+
cd linux-source-2.6.XXXXX
 
</nowiki></pre>
 
</nowiki></pre>
 
+
Check the http://www.tuxonice.net/ website for a version that matches with your kernel version. Use wget to download the latest patch set to your home directory, modifying the file name as appropriate:
Check the http://www.suspend2.net/ website for the latest version of suspend2 for the 2.6.20 kernel. At the time of writing that is 2.2.10. Use wget to download the latest patchset to your home directory, modifying the file name as appropriate:
+
 
<pre><nowiki>
 
<pre><nowiki>
wget -P ~/ -nd http://www.suspend2.net/downloads/all/suspend2-2.2.10-for-2.6.20.11.patch.bz2  
+
wget http://www.tuxonice.net/downloads/all/tuxonice-3.0-rc5-for-2.6.22.16.patch.bz2
 
</nowiki></pre>
 
</nowiki></pre>
 
Now apply the patch, modifying the file name as appropriate (you should still be inside the linux-source directory):
 
Now apply the patch, modifying the file name as appropriate (you should still be inside the linux-source directory):
 
<pre><nowiki>
 
<pre><nowiki>
bzcat ~/suspend2-2.2.10-for-2.6.20.11.patch.bz2  | patch -p1
+
bzcat ~/tuxonice-XXXX-for-2.6.XXXX.patch.bz2  | patch -p1
 
</nowiki></pre>
 
</nowiki></pre>
Look for any FAILED messages. If there are any, that is probably because the Ubuntu source code differs from the vanilla source code that the Suspend2 patch expects. Open the associated .rej files in a text editor and see if you can apply the patches manually.
+
Look for any FAILED messages. If there are any, that is probably because the Ubuntu source code differs from the vanilla source code that the tuxonice patch expects. Open the associated .rej files in a text editor and see if you can apply the patches manually.
 
+
One problem is, that at the time of writing suspend2 patchs is for 2.6.20-11, but ubuntu uses 2.6.10-15. In this case there may be a FAILED message include/linux/device.h.rej, but place for the additional line can easily be found manually.
+
 
+
 
Finally, we have some work to do to make sure that the kernel package name is compatible with linux-restricted-modules.  Make sure you get this right, or you'll find yourself compiling over and over again.  First, check the abi_version of the official kernels with:
 
Finally, we have some work to do to make sure that the kernel package name is compatible with linux-restricted-modules.  Make sure you get this right, or you'll find yourself compiling over and over again.  First, check the abi_version of the official kernels with:
 
<pre><nowiki>
 
<pre><nowiki>
 
uname -r
 
uname -r
 
</nowiki></pre>
 
</nowiki></pre>
 
 
The abi_version is the number after the -, for example if the output is 2.6.20-15-generic the abi_version is 15.  Next, edit the file "Makefile" in your source directory, setting EXTRAVERSION to the abi_version, for example:
 
The abi_version is the number after the -, for example if the output is 2.6.20-15-generic the abi_version is 15.  Next, edit the file "Makefile" in your source directory, setting EXTRAVERSION to the abi_version, for example:
 
<pre><nowiki>
 
<pre><nowiki>
第53行: 第43行:
 
EXTRAVERSION =-15
 
EXTRAVERSION =-15
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Your kernel tree is now ready.  Next step is to build the kernel source package the debian way:
 
Your kernel tree is now ready.  Next step is to build the kernel source package the debian way:
 
<pre><nowiki>
 
<pre><nowiki>
sudo apt-get install kernel-package
+
sudo apt-get install kernel-package fakeroot
 
sudo apt-get build-dep linux-image-`uname -r`
 
sudo apt-get build-dep linux-image-`uname -r`
 
make gconfig # note you may need to install packages libgtk2.0-dev and libglade2-dev
 
make gconfig # note you may need to install packages libgtk2.0-dev and libglade2-dev
# to make gconfig work
+
            # to make gconfig work
    # an alternative option is to run 'make menuconfig'
+
    # an alternative option is to run 'make menuconfig', for which you need
 +
            # libncurses5-dev
 
make-kpkg --rootcmd fakeroot --initrd --append-to-version=-suspend2 kernel-image kernel-headers kernel-source
 
make-kpkg --rootcmd fakeroot --initrd --append-to-version=-suspend2 kernel-image kernel-headers kernel-source
 
</nowiki></pre>
 
</nowiki></pre>
 
When running gconfig or menuconfig, make sure that the suspend2 options (listed under "power") and the lzf options (listed under "crypto") are checked. It's also a good idea to approximate the ubuntu kernel settings as closely as possible; you can do this by loading the config file for the default kernel image.  If it's installed, you'll find it at <code><nowiki> /boot/config-2.6.20-15-generic </nowiki></code> or similar.   
 
When running gconfig or menuconfig, make sure that the suspend2 options (listed under "power") and the lzf options (listed under "crypto") are checked. It's also a good idea to approximate the ubuntu kernel settings as closely as possible; you can do this by loading the config file for the default kernel image.  If it's installed, you'll find it at <code><nowiki> /boot/config-2.6.20-15-generic </nowiki></code> or similar.   
 
 
The --append-to-version switch gives your kernel a useful identifier, and will be important when we build the restricted-modules package (see below).  It will be, in effect, the custom "flavour" of your kernel.   
 
The --append-to-version switch gives your kernel a useful identifier, and will be important when we build the restricted-modules package (see below).  It will be, in effect, the custom "flavour" of your kernel.   
 
 
Finally, install your packages this way:
 
Finally, install your packages this way:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo dpkg -i ../*.deb
 
sudo dpkg -i ../*.deb
 
</nowiki></pre>
 
</nowiki></pre>
 
+
If you run into trouble, there are some more instructions on building kernels this way at KernelCustomBuild.
If you run into trouble, there are some more instructions on building kernels this way at KernelCustomBuild.  
+
=== Method 2: Vanilla kernel from kernel.org ===
 
+
If you're having trouble building the Ubuntu kernel, then you can, try to build the vanilla upstream kernel. This should pretty much always work. However, you will lose the third-party Ubuntu kernel modules. This method is [http://wiki.tuxonice.net/DistroAndHardwareSetup/Ubuntu_Gutsy_Gibbon documented] directly on the TuxOnIce website.
====  Next-best: the git repository ====
+
=== Method 3: Git repository ===
 
+
If you have brand new hardware it is best to use the bleeding edge code from git. This method is described on the [http://wiki.suspend2.net/BuildingUbuntuKernels TuxOnIce wiki]. 
If you're having some difficulties with the linux-source package, there is another method using git.  This method is described on the [http://wiki.suspend2.net/BuildingUbuntuKernels Suspend2 wiki], and is generally both reliable and very up-to-date.  Unfortunately because of the rapid pace of development in both Ubuntu and suspend2, the two trees can get out of sync and this method can therefore be something of a hassle.  Also, the default build process on Ubuntu is tremendously slow.  This is really only recommended if you need to build a robust set of kernel packages to redistribute to others. However, in some cases it may be the only available option.  In addition to the above link, there is information on building git kernels at CustomKernelBuild and KernelGitGuide. 
+
Tuxonice has a [http://lists.tuxonice.net/lurker/message/20071130.183559.c235f643.en.html patch] available always for the current ubuntu-git-kernel.
 
+
The current [http://kernel.ubuntu.com Ubuntu kernel] git tree is available [http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-gutsy.git;a=summary here].
==== Least-best: build from upstream ====
+
There is information on building git kernels at CustomKernelBuild and KernelGitGuide.
 
+
==  Compiling linux-restricted-modules ==
If you're having trouble building the kernel, then you can, as a last resort, try to build the vanilla upstream kernel. This should pretty much always work. However, you will lose the third-party Ubuntu kernel modules, which you may find out (too late!) that you rely on more than you think. This method is documented directly on the suspend2 website, but is not recommended.
+
This section has moved to its own page, [[UbuntuHelp:CustomRestrictedModules|CustomRestrictedModules]].  Go to that page, but remember to note down your abi_version and kernel flavour before you do so.   
 
+
== Hibernate script ==
===  Compiling linux-restricted-modules ===
+
If you enable CONFIG_SUSPEND2_REPLACE_SWSUSP in your kernel config then gnome-power-manager/equivalent of your desktop environment should simply work. In case your laptop needs some quirks (like unloading some modules, restart network, etc...) then it is better to install [http://wiki.tuxonice.net/HibernateScript hibernate script].
 
+
This section has moved to its own page, CustomRestrictedModules.  Go to that page, but remember to note down your abi_version and kernel flavour before you do so.   
+
 
+
=== Installing and configuring the hibernate script ===
+
 
+
Unfortunately, the Ubuntu power-management tools do not support suspend2 directly. Instead, we need to use the hibernate tools.  These are supported best by trevino through his repo!
+
 
+
Other web sites:
+
 
+
* [http://www.suspend2.net/ Suspend2 Project Page]
+
* [http://download.tuxfamily.org/3v1deb/dists/feisty/suspend2/index.html Treviño’s Ubuntu feisty suspend2 repository] - unofficial, use at your own risk!
+
 
+
 
----
 
----
[[category:CategoryDocumentation]] [[category:CategoryCleanup]]
 
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2009年11月17日 (二) 20:43的最新版本

<<Include(Tag/Unsupported)>> <<Include(Tag/StyleCleanup)>>

Building and Using Tux-on-ice Kernels with Ubuntu

Suspending the activity of a laptop or desktop can be one of the most frustrating and buggy parts of the Linux user experience. Some users find that their problems are significantly eased by using kernels patched with the out-of-tree tuxonice code. This code is not supported by the Ubuntu project. Tuxonice was previously known as suspend2. Steps to enable tuxonice in Gutsy gibbon are well documented here.

Changes to initramfs

It is very important to make changes to your initramfs for tuxonice to work properly. For more information see here and this feature request report. By default, you can be assured that tuxonice will have no effect on your in-kernel suspend known as swsusp.

Compiling a tux-on-ice Kernel

There are different ways to do this.

Method 1: patch the Ubuntu linux-source package

The easiest and most straightforward way to create your own kernels is to install the linux-source package and patch the resultant source tree. It's not hard but requires some work at the command-line:

sudo apt-get install linux-source
cd /usr/src
sudo chown root:admin ./
tar xjvf linux-source-2.6.XXXXX.tar.bz2
cd linux-source-2.6.XXXXX

Check the http://www.tuxonice.net/ website for a version that matches with your kernel version. Use wget to download the latest patch set to your home directory, modifying the file name as appropriate:

wget http://www.tuxonice.net/downloads/all/tuxonice-3.0-rc5-for-2.6.22.16.patch.bz2

Now apply the patch, modifying the file name as appropriate (you should still be inside the linux-source directory):

bzcat ~/tuxonice-XXXX-for-2.6.XXXX.patch.bz2  | patch -p1

Look for any FAILED messages. If there are any, that is probably because the Ubuntu source code differs from the vanilla source code that the tuxonice patch expects. Open the associated .rej files in a text editor and see if you can apply the patches manually. Finally, we have some work to do to make sure that the kernel package name is compatible with linux-restricted-modules. Make sure you get this right, or you'll find yourself compiling over and over again. First, check the abi_version of the official kernels with:

uname -r

The abi_version is the number after the -, for example if the output is 2.6.20-15-generic the abi_version is 15. Next, edit the file "Makefile" in your source directory, setting EXTRAVERSION to the abi_version, for example:

gedit Makefile

changing

EXTRAVERSION =-ubuntu1

to

EXTRAVERSION =-15

Your kernel tree is now ready. Next step is to build the kernel source package the debian way:

sudo apt-get install kernel-package fakeroot
sudo apt-get build-dep linux-image-`uname -r`
make gconfig # note you may need to install packages libgtk2.0-dev and libglade2-dev
             # to make gconfig work
	     # an alternative option is to run 'make menuconfig', for which you need
             # libncurses5-dev
make-kpkg --rootcmd fakeroot --initrd --append-to-version=-suspend2 kernel-image kernel-headers kernel-source

When running gconfig or menuconfig, make sure that the suspend2 options (listed under "power") and the lzf options (listed under "crypto") are checked. It's also a good idea to approximate the ubuntu kernel settings as closely as possible; you can do this by loading the config file for the default kernel image. If it's installed, you'll find it at /boot/config-2.6.20-15-generic or similar. The --append-to-version switch gives your kernel a useful identifier, and will be important when we build the restricted-modules package (see below). It will be, in effect, the custom "flavour" of your kernel. Finally, install your packages this way:

sudo dpkg -i ../*.deb

If you run into trouble, there are some more instructions on building kernels this way at KernelCustomBuild.

Method 2: Vanilla kernel from kernel.org

If you're having trouble building the Ubuntu kernel, then you can, try to build the vanilla upstream kernel. This should pretty much always work. However, you will lose the third-party Ubuntu kernel modules. This method is documented directly on the TuxOnIce website.

Method 3: Git repository

If you have brand new hardware it is best to use the bleeding edge code from git. This method is described on the TuxOnIce wiki. Tuxonice has a patch available always for the current ubuntu-git-kernel. The current Ubuntu kernel git tree is available here. There is information on building git kernels at CustomKernelBuild and KernelGitGuide.

Compiling linux-restricted-modules

This section has moved to its own page, CustomRestrictedModules. Go to that page, but remember to note down your abi_version and kernel flavour before you do so.

Hibernate script

If you enable CONFIG_SUSPEND2_REPLACE_SWSUSP in your kernel config then gnome-power-manager/equivalent of your desktop environment should simply work. In case your laptop needs some quirks (like unloading some modules, restart network, etc...) then it is better to install hibernate script.