web-dev-qa-db-ja.com

スワップパーティションなしでLinuxを休止できますか?

私は自分のPCにスワップパーティションを設定していませんでした。これは、a)RAM(8 GB))が豊富であり、b)使いたくない大容量のハードドライブがあるためです。小さな断片なので、私の最小パーティションは50 GiBであり、私はすでにそれらをOS用に使用しています。

今、休止状態にするために、私のLinux(Ubuntu Jaunty)はスワップを必要としました。予備の100 GBのパーティションがあったので、それをスワップとして設定しましたが、それでは満足できません。これはハイバネーションにのみ使用されます(RAM freeが常にあり、システムがスワップに移行することはありません)。また、スワップには少し大きくなります。また、最終的には必要になります他の何か。

Ubuntu Jauntyでスワップパーティションなしで休止(ディスクにサスペンド)するにはどうすればよいですか?

30
Hanno Fietz

テストされていないアイデア:s2diskのラッパー、またはスワップファイルを管理するディスクへのサスペンドを処理するユーティリティ(スワップパーティションではなく)を作成して、再開時に削除しないのはなぜですか?

  • スワップファイルを作成します:dd if=/dev/zero of=/swapfile bs=1024 count=8388608(8GB)
  • スワップファイルをセットアップします:mkswap /swapfile
  • サスペンドを設定する必要がある場合のみ、アクティブにできます:swapon /swapfile
  • 再開すると、無効にすることができます:swapoff /swapfile

スワップファイルからの再開が可能であり、 kernel.orgに記載

23
Robert Munteanu

はい、しかし努力なしではありません。 Linuxで休止(ディスクへのサスペンド)する方法は2つあります。

  1. swswap、これはカーネルに含まれています
  2. tuxonice (以前のsuspend2)ではありません。

Tuxoniceはカーネルへのパッチとして利用可能であり、一時停止イメージを通常のファイルに書き込むことができます。

Wikipedia から:

TuxOnIce (formerly known as Suspend2) is an implementation of the suspend-to-disk (or hibernate) feature which is available as patches for the 2.6 Linux kernel. It was formerly known as 'swsusp'. During the 2.5 kernel era, Pavel Machek forked the original out-of-tree version of swsusp (then at approximately beta 10) and got it merged into the Vanilla kernel, while development continued in the swsusp/Suspend2/TuxOnIce line. TuxOnIce includes support for SMP, highmem and preemption. Its major advantages over swsusp are:

    * It has an extensible architecture that allows for arbitrary transformations on the image and arbitrary backends for writing the image;
    * It prepares the image and allocates storage prior to doing any storage and accounts for memory and storage usage very carefully, thereby becoming more reliable;
    * Its current modules for writing the image have been designed for speed, combining asynchronous I/O, multithreading and readahead with LZF compression in its default configuration to read and write the image as fast as hardware is able;
    * It has an active community supporting it via a wiki, mailing lists and irc channel (see the TuxOnIce website);
    * It is more flexible and configurable (via a /sys/power/tuxonice interface);
    * Whereas the current swsusp (and uswsusp) implementations support writing the image to one swap device only, TuxOnIce supports multiple devices in any combination of swap files and swap partitions. It can also write the image to an ordinary file, thereby avoiding potential race issues in freeing memory when preparing to suspend.
    * It supports encryption by various methods;
    * It can store a full image of memory (resulting in a more responsive system post-resume), while uswsusp and swsusp write at most half the amount of RAM.

デフォルトのカーネルには含まれていないため、残念ながらJauntyで利用可能な kernel patch を取得し、カーネルを自分でコンパイルする必要があります。

いくつかの拡張された指示があります ここ ですが、自分のカーネルイメージをローリングすることに慣れていない限り、この道を歩き回る前にロバートの提案を試してみるとよいでしょう。

4
user4358

JoelとJeffが ポッドキャストで議論 をしているので、スワップをオフにすることは一般に良い考えではありません。そのままにしても、費用はかかりません。ギグは10セント(ユーロセント)未満です!

引用する:

Atwood:ある時点でのすべてのオタクがこの思考プロセスを経ると思います。私は膨大な量のメモリを手に入れました。おそらく、ページファイルを無効にすることができます。私は実際にこれについてのブログエントリを持っています。 ...重要なのは、それだけの価値はないということです。

ポッドキャストを聞いて会話の詳細を確認するか(おおよそ59分から始まります)、またはポッドキャストページにリンクされているserverfaultで質問を読んでください(質問23621)。彼らはWindowsページファイルについて話しますが、引数はUNIXでも同様に有効です(ただし、メモリを別の方法で管理する場合があります)。

3
0x89