Skip to content

Instantly share code, notes, and snippets.

@greenrobot
Created November 10, 2022 08:13
Show Gist options
  • Save greenrobot/869b0a29a68681abc85e6e1f5bf903d1 to your computer and use it in GitHub Desktop.
Save greenrobot/869b0a29a68681abc85e6e1f5bf903d1 to your computer and use it in GitHub Desktop.
Hibernate Linux (Ubuntu 22.04) with freeing caches before
#!/bin/bash
free -h
echo "Pruning caches..."
sync
echo 3 | sudo tee /proc/sys/vm/drop_caches
free -h
echo "Hibernating..."
sudo systemctl hibernate
# Seeting up hibernate via swapfile:
# Increase swapfile size (https://askubuntu.com/a/1264577/75764)
# swapon --show
# sudo swapoff /swapfile
# sudo dd if=/dev/zero of=/swapfile bs=1M count=73728 # 72 GB
# mkswap /mnt/swapfile
# sudo swapon /swapfile
#
# https://ubuntuhandbook.org/index.php/2021/08/enable-hibernate-ubuntu-21-10/
# findmnt -no UUID -T /swapfile
# # cfbd6c20-6bbc-478a-8e17-93da3f961c83
# sudo filefrag -v /swapfile |grep " 0:"| awk '{print $4}'
# # 15751852..
# sudo gedit /etc/default/grub # add uuid and offset
# sudo update-grub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment