数理的手法を使いやすくするためのソフトウェア開発

科学技術計算とデータサイエンスについて

メモ:Ubuntu 16.04 を 休止(ハイバネート)させるために (追記:休止できなくなることも)

Ubuntu 16.04 をインストールしただけでは、休止機能を使えませんでした。しかし、作業の途中で電源を落とすために必要なので、なんとか有効にしました。その方法をメモしておきます。

サスペンドできるようにした

インストール直後は、

$ sudo pm-hibernate

としても何も起こりませんでした。 また、もうひとつのコマンドでは、

$ sudo systemctl hibernate
Failed to hibernate system via logind: Sleep verb not supported

とエラーが出ました。

そこで、Ask ubuntu: How can I hibernate on Ubuntu 16.04? ^1

Secure Boot … It turns out that secure boot was the culprit: installing 16.04 you are asked what you want to do with it (which is a new thing as far as I can recall) and I kept it ON without giving it much thought.

After reboot and disabling secure boot in the BIOS settings (these are machine-specific, but usually pretty straightforward) … And indeed calling systemctl hibernate results in a successful hibernate/thaw sequence.

Moreover, after that I could see hibernation available as an option in various places of the graphical interface, without the need of any polkit hack. So it seems that systemd was actually guessing from /sys/power/disk that the system was not able to hibernate.

にしたがって、BIOSメニューから「安全なブートの構成」を見つけて、

安全なブート : 無効

にしました。すると、たしかに、ファイル/sys/power/disk は、

[disabled]

から、

[platform] shutdown reboot suspend

へと書き換えられました。しかし、私の場合、メニューに現れたのは、「ハイバーネート」ではなく、「サスペンド」でした。

そして、メニューのサスペンドを選ぶと、スクリーンはブラックアウトして、電源LEDの色が変わって、サスペンドしました。

そして、

$ sudo pm-hibernate

で、スクリーンはブラックアウトしましたが、電源はオンのままでした。それで、仕方なく、電源ボタン長押しで、強制的に電源を切らざるをえませんでした。

メニューに「ハイバネート」、しかし、電源はオンのまま

Ask ubuntu: Ubuntu 16.04 doesn’t hibernate ^2

You can also enable the hibernate option in the user menus. To do that, use your favorite text editor to create /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla. Add the following to the file and save:

[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes

そのとおりにやってみると、たしかに、メニューに「ハイバーネート」が現れました。しかし、クリックしても、休止せず、電源はオンのままでした。

休止できるようになった

次は、

Ask ubuntu: Ubuntu 16.04 doesn’t hibernate ^2

Since you’re running Ubuntu 16.04, you should consider running the native systemd suspend/hibernate services in lieu of the pm-utils tools.

In my own case, here’s what I’ve done to configure my machine for hibernate/resume using systemd:

にそって、まず、スワップ領域のUUID を、

tail -n -9 /proc/swaps | cut -d ' ' -f 1 | xargs sudo blkid

のように調べました^3

1) /etc/default/grub の GRUB_CMDLINE_LINUX_DEFAULT の行を、

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nomsi  resume=UUID=(上記で調べたUUID)"

のように書き換えました。

2) sudo update-grub

3) /etc/initramfs-tools/conf.d/resume に UUIDが正しく書き込まれていることを確認しました。

4) sudo update-initramfs -u

5) sudo service systemd-logind restart

6) 再起動。

これで、メニューの「ハイバーネート」で、電源がオフになり、電源をオンにすると、Ubuntu の認証画面が現れ、ログインすると、作業途中のデスクトップに戻れました。

これで、私自身もハイバーネートします。おやすみなさい。

追記

2017/05/05

使っているうちに、休止できなくなることが判明しました。休止できるのは、上記ステップ 2) , 4), 5) を繰り返して、再起動して、しばらくの間だけでした。それ以外のときは、メニューの「ハイバーネート」を選んでも、あるいは、 sudo pm-hibernate としても、画面表示は消えるものの、電源はオフにならず、オンのままでした。

また、sudo pm-hibernate を実行する前に、上記ステップ 2) , 4), 5) をしてみたのですが、それでも、画面表示は消えるものの、電源はオンのままでした。


参考

^1:Ask ubuntu: How can I hibernate on Ubuntu 16.04?

^2:Ask ubuntu: Ubuntu 16.04 doesn’t hibernate

^3:Ask ubuntu: Why isn’t Hibernate in Ubuntu 16.04 working and how to fix it?