Skip to main content

Configure Linux hibernation (swapfile, GRUB resume, mkinitcpio resume hook).

Project description

Hibernate Setup

A Python-based utility for configuring hibernation on Linux systems using a swap file. This tool automates resume configuration for GRUB and initramfs and optionally creates a swap file of configurable size.

Designed for Arch-based systems (Arch Linux, Manjaro) and intended for automation and reproducible system setup.


🛠 Features

  • Optionally create and activate a swap file
  • Automatically detect UUID and resume offset
  • Inject resume and resume_offset into GRUB config
  • Regenerate initramfs via mkinitcpio
  • Interactive confirmation before file changes
  • Preview mode for dry-run without changes
  • Non-interactive mode for automation
  • Root permission required

📦 Installation

Using pip (recommended)

Install directly from PyPI:

pip install setup-hibernate

Or system-wide:

sudo pip install setup-hibernate

Or isolated using pipx:

pipx install setup-hibernate

From source

git clone https://github.com/kevinveenbirkenbach/setup-hibernate.git
cd setup-hibernate
pip install .

🚀 Usage

Run the tool as root:

sudo setup-hibernate [OPTIONS]

Or via Python module:

sudo python -m setup_hibernate [OPTIONS]

⚙ Options

Option Description
--create-swapfile Create and configure a swap file at /swapfile
--swap-size <int> Set the swap file size in GB (default: 32)
-p, --preview Show what would be done without executing any changes (dry-run mode)
--non-interactive Apply all changes automatically without prompting for confirmation

🧪 Examples

Create a 40GB swapfile and configure hibernation interactively:

sudo setup-hibernate --create-swapfile --swap-size 40

Preview what would happen without actually doing anything:

sudo setup-hibernate --create-swapfile --swap-size 40 --preview

Non-interactive, suitable for automation:

sudo setup-hibernate --create-swapfile --swap-size 40 --non-interactive

✅ Requirements

  • Python 3.8+

  • Tools:

    • fallocate
    • mkswap
    • swapon
    • filefrag
    • findmnt
    • mkinitcpio
    • update-grub
  • Root privileges

No external Python packages are required.


👤 Author

Developed by Kevin Veen-Birkenbach 🌐 https://www.veen.world


📄 License

This project is licensed under the MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

setup_hibernate-1.0.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

setup_hibernate-1.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file setup_hibernate-1.0.1.tar.gz.

File metadata

  • Download URL: setup_hibernate-1.0.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for setup_hibernate-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5171a1f12d8863e9fb45747ec3437816d211e08d0f262c58b043750f9545c101
MD5 a7f211d42db0b2b95d97e8ce64ff3486
BLAKE2b-256 7bfbe12a205a9cd54fe26cce79db494d3742783575fb40ef6d512a8a6cda993c

See more details on using hashes here.

File details

Details for the file setup_hibernate-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for setup_hibernate-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 29d49d2ee530576d3803b1332bb3b50a714224686fdd40db6d312b1f12dc53be
MD5 52882a74fef425375af2149aecdc23ba
BLAKE2b-256 e7b93326d2b8c71a62f13b58a57692db5e81400dc34d7c46541ec436f5585e8f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page