Skip to main content

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.

Metadata

Release files for setup-hibernate 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for setup-hibernate 1.0.1
File Size Uploaded
setup_hibernate-1.0.1.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for setup-hibernate 1.0.1
File Interpreter ABI Platform
setup_hibernate-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / setup_hibernate-1.0.1.tar.gz

Download URL setup_hibernate-1.0.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5171a1f12d8863e9fb45747ec3437816d211e08d0f262c58b043750f9545c101
BLAKE2b-256 checksum
How to use checksums
7bfbe12a205a9cd54fe26cce79db494d3742783575fb40ef6d512a8a6cda993c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / setup_hibernate-1.0.1-py3-none-any.whl

Download URL setup_hibernate-1.0.1-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29d49d2ee530576d3803b1332bb3b50a714224686fdd40db6d312b1f12dc53be
BLAKE2b-256 checksum
How to use checksums
e7b93326d2b8c71a62f13b58a57692db5e81400dc34d7c46541ec436f5585e8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page