2026-01-12 11:14:24 +01:00
# Hibernate Setup
2026-07-16 11:24:24 +02:00
[](https://github.com/sponsors/kevinveenbirkenbach) [](https://www.patreon.com/c/kevinveenbirkenbach) [](https://buymeacoffee.com/kevinveenbirkenbach) [](https://s.veen.world/paypaldonate)
2025-04-02 16:21:03 +02:00
2026-01-12 11:14:24 +01:00
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.
2025-04-02 16:21:03 +02:00
---
## 🛠 Features
2026-01-12 11:14:24 +01:00
* 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
2025-04-02 16:21:03 +02:00
---
## 📦 Installation
2026-01-12 11:14:24 +01:00
### Using pip (recommended)
Install directly from PyPI:
```bash
pip install setup-hibernate
```
Or system-wide:
```bash
sudo pip install setup-hibernate
```
Or isolated using pipx:
2025-04-02 16:21:03 +02:00
```bash
2026-01-12 11:14:24 +01:00
pipx install setup-hibernate
```
---
### From source
```bash
git clone https://github.com/kevinveenbirkenbach/setup-hibernate.git
cd setup-hibernate
pip install .
2025-04-02 16:21:03 +02:00
```
---
## 🚀 Usage
2026-01-12 11:14:24 +01:00
Run the tool as root:
2025-04-02 16:21:03 +02:00
```bash
2026-01-12 11:14:24 +01:00
sudo setup-hibernate [OPTIONS]
2025-04-02 16:21:03 +02:00
```
2026-01-12 11:14:24 +01:00
Or via Python module:
```bash
sudo python -m setup_hibernate [OPTIONS]
```
---
2025-04-02 16:21:03 +02:00
2026-01-12 11:14:24 +01:00
## ⚙ Options
2025-04-02 16:21:03 +02:00
2026-01-12 11:14:24 +01:00
| 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
2025-04-02 16:45:35 +02:00
Create a 40GB swapfile and configure hibernation interactively:
2025-04-02 16:21:03 +02:00
```bash
2026-01-12 11:14:24 +01:00
sudo setup-hibernate --create-swapfile --swap-size 40
2025-04-02 16:21:03 +02:00
```
2025-04-02 16:45:35 +02:00
Preview what would happen without actually doing anything:
```bash
2026-01-12 11:14:24 +01:00
sudo setup-hibernate --create-swapfile --swap-size 40 --preview
2025-04-02 16:45:35 +02:00
```
Non-interactive, suitable for automation:
```bash
2026-01-12 11:14:24 +01:00
sudo setup-hibernate --create-swapfile --swap-size 40 --non-interactive
2025-04-02 16:45:35 +02:00
```
2025-04-02 16:21:03 +02:00
---
## ✅ Requirements
2026-01-12 11:14:24 +01:00
* Python 3.8+
* Tools:
2025-04-02 16:21:03 +02:00
2026-01-12 11:14:24 +01:00
* `fallocate`
* `mkswap`
* `swapon`
* `filefrag`
* `findmnt`
* `mkinitcpio`
* `update-grub`
* Root privileges
2025-04-02 16:21:03 +02:00
2026-01-12 11:14:24 +01:00
No external Python packages are required.
2025-04-02 16:21:03 +02:00
---
## 👤 Author
2026-01-12 11:14:24 +01:00
Developed by **Kevin Veen-Birkenbach **
🌐 [https://www.veen.world ](https://www.veen.world )
2025-04-02 16:21:03 +02:00
---
## 📄 License
2026-01-12 11:14:24 +01:00
This project is licensed under the **MIT License ** .
See [LICENSE ](./LICENSE ) for details.