「Uswsusp」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(en:Uswsuspへの転送ページ)
 
1行目: 1行目:
  +
[[Category:電源管理]]
#redirect[[en:Uswsusp]]
 
  +
[[en:Uswsusp]]
  +
{{Related articles start}}
  +
{{Related4|hibernate-script}}
  +
{{Related|Pm-utils}}
  +
{{Related|TuxOnIce}}
  +
{{Related articles end}}
  +
  +
[http://suspend.sourceforge.net/ uswsusp] (userspace software suspend) は Linux 環境でハイバネーション (suspend-to-disk) や サスペンド (suspend-to-RAM あるいは standby) をするために使われるユーザースペースツールのセットです。以下のツールから構成されます:
  +
* '''s2ram''' - サスペンドの前や復帰後にグラフィックアダプタの操作をユーザーランドから行えるようにして復帰後にグラフィック (やシステム全体) を復活させる、カーネルの suspend-to-RAM 機構のラッパー。vbetool や radeontool の機能を取り入れます。動作中のハードウェアの設定リストと適切な操作のセットを読み込むことで正しく復帰を実行します。HAL によって管理されているハードウェアのホワイトリストを使用します - '''s2ram''' は HAL のデータベースオプションを '''s2ram''' のパラメータに翻訳します。
  +
:{{Note|HAL は廃止されユーザー空間の設定を省いて直接 KMS ドライバーがグラフィックカードの状態を保存するため、'''s2ram''' の開発は終了しておりホワイトリストのエントリがこれから追加されることはありません。KMS ドライバーを使っている場合、'''s2ram''' は直接マシンをサスペンドします。}}
  +
* '''s2disk''' - ユーザー空間ソフトウェアサスペンド (µswsusp) のリファレンス実装。システムをサスペンドするのに必要な手順 (プロセスのフリーズやスワップ領域の準備など) をまとめて、イメージの読み書きを処理します。s2disk はイメージの圧縮や暗号化などの機能をサポートしており、他の機能 (例: 見栄えの良いプログレスバー, 外部ディスクへのイメージの保存, 復帰中にテトリスを遊ぶなど) も簡単に追加できます。
  +
  +
* '''s2both''' - バッテリー残量がないときは s2ram と s2disk の機能を組み合わせるのが大いに役立ちます。s2both は (s2disk のように) システムのスナップショットをスワップに書き出して、それから (s2ram のように) マシンを STR 状態にします。バッテリーの残量が十分ある場合は STR から高速に復帰でき、足りないときはディスクから復帰するため作業を喪失することがありません。
  +
  +
== インストール ==
  +
  +
uswsusp は [[AUR]] の {{AUR|uswsusp-git}} からインストールできます。
  +
  +
== 設定 ==
  +
  +
ディスクにサスペンドする前に {{ic|/etc/suspend.conf}} を編集してください。
  +
  +
* スワップパーティションを使う場合:
  +
resume device = /dev/disk/by-label/swap
  +
  +
{{ic|/dev/disk/by-label/swap}} はスワップパーティションが含まれている適当なブロックデバイスに置き換えて下さい。
  +
  +
* [[スワップ#スワップファイル|スワップファイル]]を使う場合:
  +
resume device = /dev/sdXN # the partition which contains swapfile
  +
resume offset = 123456
  +
  +
123456 はスワップファイルのヘッダが存在する resume デバイスの先頭からのオフセットに置き換えて下さい。resume オフセットは以下のコマンドで確認できます:
  +
  +
# swap-offset your-swap-file
  +
  +
* The {{ic|image size}} parameter (optional) can be used to limit the size of the system snapshot image created by s2disk. If it's not possible to create an image of the desired size, s2disk will suspend anyway, using a bigger image. If image size is set to 0, the image will be as small as possible.
  +
  +
* The {{ic|shutdown method}} parameter (optional) specifies the operation that will be carried out when the machine is ready to be powered off. If set to "reboot" the machine will be rebooted immediately. If set to "platform" the machine will be shut down using special power management operations available from the kernel that may be necessary for the hardware to be properly reinitialized after the resume, and may cause the system to resume faster.
  +
  +
* If the {{ic|compute checksum}} parameter is set to 'y', the s2disk and resume tools will use the MD5 algorithm to verify the image integrity.
  +
  +
* If the {{ic|compress}} parameter is set to 'y', the s2disk and resume tools will use the LZF compression algorithm to compress/decompress the image.
  +
  +
* If {{ic|splash}} is set to 'y', s2disk and/or resume will use a splash system. Currently splashy and fbsplash are supported. {{Note|This requires additional {{ic|configure}} flags for uswsusp ({{ic|--enable-splashy}} and {{ic|--enable-fbsplash}}, respectively).}}
  +
  +
* The {{ic|resume pause}} option will introduce a delay after successfully resuming from hibernation, in order to allow the user to read the stats (read and write speed, image size, etc.)
  +
  +
* If {{ic|threads}} is enabled, s2disk will use several threads for compressing, encrypting and writing the image. This is supposed to speed things up. For details, read the comments in [http://git.kernel.org/?p=linux/kernel/git/rafael/suspend-utils.git;a=blob;f=suspend.c;h=166a62f03ea9daaba271e7cebf94c76881d4266f;hb=HEAD suspend.c]
  +
  +
=== 暗号化のサポート ===
  +
* パッケージに含まれている suspend-keygen ユーティリティでキーを生成してください
  +
* {{Ic|/etc/suspend.conf}} にキーの名前を記述します:
  +
encrypt = y
  +
RSA key file = <path_to_keyfile>
  +
  +
=== initramfs の再作成 ===
  +
{{Note|Whenever you modify {{ic|/etc/suspend.conf}}, '''you will need to rebuild''' your initramfs. If you fail to do so, and linux cannot find your image at startup, you will not see an error message indicating this. Your boot process will hang after starting the {{ic|uresume}} hook, typically after the message with the libgcrypt version.}}
  +
{{ic|/etc/mkinitcpio.conf}} ファイルを編集して HOOKS エントリに "uresume" を追加してください:
  +
HOOKS="base udev autodetect block '''uresume''' filesystems"
  +
そして ramdisk を再作成してください:
  +
# mkinitcpio -p linux
  +
  +
=== サンプル設定 ===
  +
  +
{{hc|/etc/suspend.conf|2=
  +
snapshot device = /dev/snapshot
  +
  +
resume device = /dev/disk/by-label/swap
  +
  +
# image size is in bytes
  +
image size = 1468006400
  +
  +
#suspend loglevel = 2
  +
  +
compute checksum = y
  +
  +
compress = y
  +
  +
#encrypt = y
  +
  +
#early writeout = y
  +
  +
#splash = y
  +
  +
# up to 60 (seconds)
  +
#resume pause = 30
  +
  +
threads = y
  +
}}
  +
  +
== 使用方法 ==
  +
  +
=== スタンドアロン ===
  +
  +
ディスクにサスペンドするには、次を実行:
  +
  +
# s2disk
  +
  +
RAM にサスペンドするには、まず次を実行:
  +
  +
# s2ram --test
  +
  +
あなたのマシンが動作確認済みのマシンデータベースに入っているか確認します。"Machine matched entry xyz" などと返ってきたら次を実行:
  +
  +
# s2ram
  +
  +
サスペンドできない場合 --force パラメータを使用したり、他のパラメータと組み合わせる必要があるかもしれません ({{ic|s2ram --help}} を参照)。
  +
  +
[[Pm-utils]] や hibernate-script などの s2disk を内部的に呼び出すユーザースペースツールを使用する必要がある場合もあります。詳しくは [[en2:hibernate-script|hibernate-script]] を見て下さい。
  +
  +
=== pm-utils を使う ===
  +
  +
[[Pm-utils]] は uswsusp を含む、複数の[[Pm-utils#別のサスペンドバックエンドをインストール (任意)|スリープバックエンド]]を使うことができます。{{ic|/etc/pm/config.d/module}} を作成・編集してください:
  +
SLEEP_MODULE=uswsusp
  +
  +
上記の設定で pm-suspend と pm-hibernate は uswsusp を使うようになります。通常ユーザーは以下のコマンドを使うことで uswsusp でサスペンドすることが可能です:
  +
  +
$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
  +
  +
$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
  +
  +
{{Note|ユーザーの[[ウィンドウマネージャ]]や[[デスクトップ環境]]は gdm や kdm などの[[ディスプレイマネージャ|ログインマネージャ]]で起動する必要があります。また、upower をインストールしてください。}}
  +
  +
=== systemd を使う ===
  +
  +
To to put your system into hibernation a.k.a ''Suspend to Disk'' with {{ic|systemctl hibernate}}, do:
  +
  +
# cp /usr/lib/systemd/system/systemd-hibernate.service /etc/systemd/system/
  +
# cd /etc/systemd/system/
  +
  +
Open {{ic|systemd-hibernate.service}} with your preferred text editor and edit the line from this:
  +
  +
{{hc|/etc/systemd/system/systemd-hibernate.service|2=
  +
...
  +
ExecStart=/usr/lib/systemd/systemd-sleep hibernate}}
  +
  +
to this:
  +
  +
{{hc|/etc/systemd/system/systemd-hibernate.service|2=
  +
...
  +
ExecStart=/bin/sh -c 's2disk && run-parts --regex .\* -a post /usr/lib/systemd/system-sleep'}}
  +
  +
After that, execute {{ic|systemctl hibernate}} to put your system into hibernation. Do similar changes for systemd-hybrid-sleep.service to enable uswsusp-based hybrid sleep too.
  +
  +
== トラブルシューティング ==
  +
  +
=== My machine is not whitelisted ===
  +
  +
If {{ic|s2ram}} doesn't match your machine to an entry in its whitelist, it will output some general purpose identification strings for your machine (the same as those provided {{ic|s2ram -i}}). In this case, you may try to force {{ic|s2ram}} to suspend your machine by using {{ic|s2ram -f}}.
  +
  +
=== {{ic|s2ram -f}} が動作しない ===
  +
  +
If {{Ic|s2ram -f}} doesn't work, try the different workarounds offered by {{Ic|s2ram}}. Run {{Ic|s2ram -h}} to get a list of the possible options:
  +
{{hc|# s2ram -h|<nowiki>
  +
Usage: s2ram [-nhi] [-fspmrav]
  +
  +
Options:
  +
-h, --help: this text.
  +
-n, --test: test if the machine is in the database.
  +
returns 0 if known and supported
  +
-i, --identify: prints a string that identifies the machine.
  +
-f, --force: force suspending, even on unknown machines.
  +
  +
The following options are only available with -f/--force:
  +
-s, --vbe_save: save VBE state before suspending and restore after resume.
  +
-p, --vbe_post: VBE POST the graphics card after resume
  +
-m, --vbe_mode: get VBE mode before suspend and set it after resume
  +
-r, --radeontool: turn off the backlight on radeons before suspending.
  +
-a, --acpi_sleep: set the acpi_sleep parameter before suspend
  +
1=s3_bios, 2=s3_mode, 3=both
  +
-v, --pci_save: save the PCI config space for the VGA card.
  +
</nowiki>}}
  +
  +
Try the following variations:
  +
s2ram -f -a 1
  +
s2ram -f -a 2
  +
s2ram -f -a 3
  +
s2ram -f -p -m
  +
s2ram -f -p -s
  +
s2ram -f -m
  +
s2ram -f -s
  +
s2ram -f -p
  +
s2ram -f -a 1 -m
  +
s2ram -f -a 1 -s
  +
  +
If none of those combinations work, start again but add the {{ic|-v}} switch.
  +
  +
Note that mixing the {{ic|-a}} options and the vbetool options ({{ic|-p}}, {{ic|-m}}, {{ic|-s}})
  +
is normally only a measure of last resort, it usually does not make much
  +
sense.
  +
  +
If you find several combinations that work (e.g. {{ic|s2ram -f -a 3}} and {{ic|s2ram -f -p -m}} both work on your machine),
  +
the in-kernel method ({{ic|-a}}) should be preferred over the userspace methods ({{ic|-p}}, {{ic|-m}}, {{ic|-s}}).
  +
  +
Verify all combinations in both cases when reporting success to the {{ic|s2ram}} developers:
  +
* when issuing {{ic|s2ram}} from console
  +
* when issuing {{ic|s2ram}} from X
  +
  +
=== オプションをどのように組み合わせても s2ram が動作しない ===
  +
  +
There is a trick which does not correspond to a command line option, because it requires additional operations from you. It is marked with NOFB in the whitelist and used for those laptops which suspend and resume properly only if no framebuffer is used. If you verify that no command line option of {{Ic|s2ram}} works, you can try disabling the framebuffer. To do this, you need to edit your bootloader configuration, remove any possible {{Ic|1=vga=<foo>}} values from the kernel line and reboot. This at least if you use the VESAFB framebuffer (as in the arch default kernel). If you use a different framebuffer driver, refer to the documentation of the driver to see how to disable it.
  +
  +
== 参照 ==
  +
  +
* [http://suspend.sourceforge.net/ Uswsusp ホームページ]
  +
* ソースコードに含まれている [http://git.kernel.org/?p=linux/kernel/git/rafael/suspend-utils.git;a=blob;f=HOWTO;h=116cddaa76cbdec69eb8b1e87b7df8931d3a73da;hb=HEAD HOWTO ファイル]
  +
* {{ic|/usr/share/doc/suspend/README}} Uswsusp ドキュメント
  +
* {{ic|/usr/share/doc/suspend/README.s2ram-whitelist}} s2ram-whitelist README

2015年12月5日 (土) 23:09時点における版

関連記事

uswsusp (userspace software suspend) は Linux 環境でハイバネーション (suspend-to-disk) や サスペンド (suspend-to-RAM あるいは standby) をするために使われるユーザースペースツールのセットです。以下のツールから構成されます:

  • s2ram - サスペンドの前や復帰後にグラフィックアダプタの操作をユーザーランドから行えるようにして復帰後にグラフィック (やシステム全体) を復活させる、カーネルの suspend-to-RAM 機構のラッパー。vbetool や radeontool の機能を取り入れます。動作中のハードウェアの設定リストと適切な操作のセットを読み込むことで正しく復帰を実行します。HAL によって管理されているハードウェアのホワイトリストを使用します - s2ram は HAL のデータベースオプションを s2ram のパラメータに翻訳します。
ノート: HAL は廃止されユーザー空間の設定を省いて直接 KMS ドライバーがグラフィックカードの状態を保存するため、s2ram の開発は終了しておりホワイトリストのエントリがこれから追加されることはありません。KMS ドライバーを使っている場合、s2ram は直接マシンをサスペンドします。
  • s2disk - ユーザー空間ソフトウェアサスペンド (µswsusp) のリファレンス実装。システムをサスペンドするのに必要な手順 (プロセスのフリーズやスワップ領域の準備など) をまとめて、イメージの読み書きを処理します。s2disk はイメージの圧縮や暗号化などの機能をサポートしており、他の機能 (例: 見栄えの良いプログレスバー, 外部ディスクへのイメージの保存, 復帰中にテトリスを遊ぶなど) も簡単に追加できます。
  • s2both - バッテリー残量がないときは s2ram と s2disk の機能を組み合わせるのが大いに役立ちます。s2both は (s2disk のように) システムのスナップショットをスワップに書き出して、それから (s2ram のように) マシンを STR 状態にします。バッテリーの残量が十分ある場合は STR から高速に復帰でき、足りないときはディスクから復帰するため作業を喪失することがありません。

インストール

uswsusp は AURuswsusp-gitAUR からインストールできます。

設定

ディスクにサスペンドする前に /etc/suspend.conf を編集してください。

  • スワップパーティションを使う場合:
resume device = /dev/disk/by-label/swap

/dev/disk/by-label/swap はスワップパーティションが含まれている適当なブロックデバイスに置き換えて下さい。

resume device = /dev/sdXN  # the partition which contains swapfile 
resume offset = 123456

123456 はスワップファイルのヘッダが存在する resume デバイスの先頭からのオフセットに置き換えて下さい。resume オフセットは以下のコマンドで確認できます:

# swap-offset your-swap-file
  • The image size parameter (optional) can be used to limit the size of the system snapshot image created by s2disk. If it's not possible to create an image of the desired size, s2disk will suspend anyway, using a bigger image. If image size is set to 0, the image will be as small as possible.
  • The shutdown method parameter (optional) specifies the operation that will be carried out when the machine is ready to be powered off. If set to "reboot" the machine will be rebooted immediately. If set to "platform" the machine will be shut down using special power management operations available from the kernel that may be necessary for the hardware to be properly reinitialized after the resume, and may cause the system to resume faster.
  • If the compute checksum parameter is set to 'y', the s2disk and resume tools will use the MD5 algorithm to verify the image integrity.
  • If the compress parameter is set to 'y', the s2disk and resume tools will use the LZF compression algorithm to compress/decompress the image.
  • If splash is set to 'y', s2disk and/or resume will use a splash system. Currently splashy and fbsplash are supported.
    ノート: This requires additional configure flags for uswsusp (--enable-splashy and --enable-fbsplash, respectively).
  • The resume pause option will introduce a delay after successfully resuming from hibernation, in order to allow the user to read the stats (read and write speed, image size, etc.)
  • If threads is enabled, s2disk will use several threads for compressing, encrypting and writing the image. This is supposed to speed things up. For details, read the comments in suspend.c

暗号化のサポート

  • パッケージに含まれている suspend-keygen ユーティリティでキーを生成してください
  • /etc/suspend.conf にキーの名前を記述します:
encrypt = y
RSA key file = <path_to_keyfile>

initramfs の再作成

ノート: Whenever you modify /etc/suspend.conf, you will need to rebuild your initramfs. If you fail to do so, and linux cannot find your image at startup, you will not see an error message indicating this. Your boot process will hang after starting the uresume hook, typically after the message with the libgcrypt version.

/etc/mkinitcpio.conf ファイルを編集して HOOKS エントリに "uresume" を追加してください:

HOOKS="base udev autodetect block uresume filesystems"

そして ramdisk を再作成してください:

# mkinitcpio -p linux

サンプル設定

/etc/suspend.conf
snapshot device = /dev/snapshot

resume device = /dev/disk/by-label/swap

# image size is in bytes
image size = 1468006400

#suspend loglevel = 2

compute checksum = y

compress = y

#encrypt = y

#early writeout = y

#splash = y

# up to 60 (seconds)
#resume pause = 30  

threads = y

使用方法

スタンドアロン

ディスクにサスペンドするには、次を実行:

# s2disk

RAM にサスペンドするには、まず次を実行:

# s2ram --test

あなたのマシンが動作確認済みのマシンデータベースに入っているか確認します。"Machine matched entry xyz" などと返ってきたら次を実行:

# s2ram

サスペンドできない場合 --force パラメータを使用したり、他のパラメータと組み合わせる必要があるかもしれません (s2ram --help を参照)。

Pm-utils や hibernate-script などの s2disk を内部的に呼び出すユーザースペースツールを使用する必要がある場合もあります。詳しくは hibernate-script を見て下さい。

pm-utils を使う

Pm-utils は uswsusp を含む、複数のスリープバックエンドを使うことができます。/etc/pm/config.d/module を作成・編集してください:

SLEEP_MODULE=uswsusp

上記の設定で pm-suspend と pm-hibernate は uswsusp を使うようになります。通常ユーザーは以下のコマンドを使うことで uswsusp でサスペンドすることが可能です:

$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
ノート: ユーザーのウィンドウマネージャデスクトップ環境は gdm や kdm などのログインマネージャで起動する必要があります。また、upower をインストールしてください。

systemd を使う

To to put your system into hibernation a.k.a Suspend to Disk with systemctl hibernate, do:

# cp /usr/lib/systemd/system/systemd-hibernate.service /etc/systemd/system/
# cd /etc/systemd/system/

Open systemd-hibernate.service with your preferred text editor and edit the line from this:

/etc/systemd/system/systemd-hibernate.service
...
ExecStart=/usr/lib/systemd/systemd-sleep hibernate

to this:

/etc/systemd/system/systemd-hibernate.service
...
ExecStart=/bin/sh -c 's2disk && run-parts --regex .\* -a post /usr/lib/systemd/system-sleep'

After that, execute systemctl hibernate to put your system into hibernation. Do similar changes for systemd-hybrid-sleep.service to enable uswsusp-based hybrid sleep too.

トラブルシューティング

My machine is not whitelisted

If s2ram doesn't match your machine to an entry in its whitelist, it will output some general purpose identification strings for your machine (the same as those provided s2ram -i). In this case, you may try to force s2ram to suspend your machine by using s2ram -f.

s2ram -f が動作しない

If s2ram -f doesn't work, try the different workarounds offered by s2ram. Run s2ram -h to get a list of the possible options:

# s2ram -h
Usage: s2ram [-nhi] [-fspmrav]

Options:
    -h, --help:       this text.
    -n, --test:       test if the machine is in the database.
                      returns 0 if known and supported
    -i, --identify:   prints a string that identifies the machine.
    -f, --force:      force suspending, even on unknown machines.

The following options are only available with -f/--force:
    -s, --vbe_save:   save VBE state before suspending and restore after resume.
    -p, --vbe_post:   VBE POST the graphics card after resume
    -m, --vbe_mode:   get VBE mode before suspend and set it after resume
    -r, --radeontool: turn off the backlight on radeons before suspending.
    -a, --acpi_sleep: set the acpi_sleep parameter before suspend
                      1=s3_bios, 2=s3_mode, 3=both
    -v, --pci_save:   save the PCI config space for the VGA card.

Try the following variations:

  s2ram -f -a 1
  s2ram -f -a 2
  s2ram -f -a 3
  s2ram -f -p -m
  s2ram -f -p -s
  s2ram -f -m
  s2ram -f -s
  s2ram -f -p
  s2ram -f -a 1 -m
  s2ram -f -a 1 -s

If none of those combinations work, start again but add the -v switch.

Note that mixing the -a options and the vbetool options (-p, -m, -s) is normally only a measure of last resort, it usually does not make much sense.

If you find several combinations that work (e.g. s2ram -f -a 3 and s2ram -f -p -m both work on your machine), the in-kernel method (-a) should be preferred over the userspace methods (-p, -m, -s).

Verify all combinations in both cases when reporting success to the s2ram developers:

  • when issuing s2ram from console
  • when issuing s2ram from X

オプションをどのように組み合わせても s2ram が動作しない

There is a trick which does not correspond to a command line option, because it requires additional operations from you. It is marked with NOFB in the whitelist and used for those laptops which suspend and resume properly only if no framebuffer is used. If you verify that no command line option of s2ram works, you can try disabling the framebuffer. To do this, you need to edit your bootloader configuration, remove any possible vga=<foo> values from the kernel line and reboot. This at least if you use the VESAFB framebuffer (as in the arch default kernel). If you use a different framebuffer driver, refer to the documentation of the driver to see how to disable it.

参照