Povolení hibernace na Linuxu: Porovnání verzí

Z ZděchovNET
Skočit na navigaci Skočit na vyhledávání
Bez shrnutí editace
Bez shrnutí editace
Řádek 4: Řádek 4:


sudo swapoff /swapfile
sudo swapoff /swapfile
sudo dd if=/dev/zero of=/swapfile bs=$(cat /proc/meminfo | grep MemTotal | grep -oh '[0-9]*') count=1024 conv=notrun
sudo dd if=/dev/zero of=/swapfile bs=$(cat /proc/meminfo | grep MemTotal | grep -oh '[0-9]*') count=1024 conv=notrunc
sudo mkswap /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon /swapfile
Řádek 32: Řádek 32:


$ sudo swap-offset /swapfile
$ sudo swap-offset /swapfile
resume offset = 34818
resume offset = 34816


* Configure Grub to resume from the swapfile by editing /etc/default/grub and modify the following line:
* Configure Grub to resume from the swapfile by editing /etc/default/grub and modify the following line:

Verze z 5. 7. 2020, 10:00

Povolení hibernace pro Ubuntu 18.04 se swap souborem:

  • Make your /swapfile have at least the size of your RAM
   sudo swapoff /swapfile
   sudo dd if=/dev/zero of=/swapfile bs=$(cat /proc/meminfo | grep MemTotal | grep -oh '[0-9]*') count=1024 conv=notrunc
   sudo mkswap /swapfile
   sudo swapon /swapfile
   Note the UUID of the partition containing your /swapfile:
   $ sudo findmnt -no SOURCE,UUID -T /swapfile
   /dev/nvme0n1p5 20562a02-cfa6-42e0-bb9f-5e936ea763d0
  • Reconfigure the package uswsusp in order to correctly use the swapfile:
   sudo apt install uswsusp
   sudo dpkg-reconfigure -pmedium uswsusp
   # Answer "Yes" to continue without swap space
   # Select "/dev/disk/by-uuid/20562a02-cfa6-42e0-bb9f-5e936ea763d0" replace the UUID with the result from the previous findmnt command
   # Encrypt: "No"
  • Edit the SystemD hibernate service using sudo systemctl edit systemd-hibernate.service and fill it with the following content:
   [Service]
   ExecStart=
   ExecStartPre=-/bin/run-parts -v -a pre /lib/systemd/system-sleep
   ExecStart=/usr/sbin/s2disk
   ExecStartPost=-/bin/run-parts -v --reverse -a post /lib/systemd/system-sleep
  • Note the resume offset of your /swapfile:
   $ sudo swap-offset /swapfile
   resume offset = 34816
  • Configure Grub to resume from the swapfile by editing /etc/default/grub and modify the following line:
   GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=20562a02-cfa6-42e0-bb9f-5e936ea763d0 resume_offset=34818 quiet splash"
  • Update Grub:
   sudo update-grub
  • Create the following /etc/initramfs-tools/conf.d/resume:
   RESUME=UUID=20562a02-cfa6-42e0-bb9e-5e936ea763d0 resume_offset=34816
   # Resume from /swapfile
  • Update initramfs:
   sudo update-initramfs -u -k all
  • K povolení volby hibernace v menu upravte soubor:
sudo mcedit /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

Přidat následující obsah:

[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
ResultActive=yes

Now you can hibernate with:

sudo systemctl hibernate.

Původní návod na stackoverflow