Ugrd
A minimalistic and user friendly POSIX initramfs generator, designed for encrypted systems
Install / Use
/learn @desultory/UgrdREADME
µgRD
Microgram Ramdisk is a framework used to generate POSIX compatible ramdisks using TOML definitions and python functions
Design
µgRD is designed to generate a custom initramfs environment to boot the system which built it.
Generated images are as static and secure as possible, only including components and features required to mount the root and switch to it.
µgRD itself is written in pure Python, and generates POSIX shell scripts to mount the rootfs and continue booting.
The final build environment is left in the specified build_dir, where it can be examined or repacked.
Unless validation is disabled, µgRD attempts to validate most configuration against the host system, raising exceptions or logging warnings warnings if the configuration is invalid.
Project goal and features
The original goal of this project was to create an initramfs suitable for decrypting a LUKS root filesystem with a smartcard, with enough config validation to prevent the user from being left in a broken pre-boot environment.
Auto-detection
- Root mount, using
/proc/mounts.root=androotflags=can be used but are not required - MDRAID auto-configuration
- LVM auto-configuration
- LUKS auto-configuration and validation
- LUKS under LVM support
- LUKS under MDRAID support
- Detached header support
- YubiKey (OpenPGP smartcard) support
- Recovery using a passphrase using
try_nokey - DM-Integrity support
- BTRFS root subvolumes are automatically detected or can be manually set with
root_subvolsubvol_selectorcan be used to interactively select a subvolume at boot time
/usr,/var, and/etcauto-mounting if the init system requires it- Auto-detection of kernel modules required by storage devices and filesystems
- Init system/target auto-detection
Validation
- Configuration validation against the host config in
validatemode - LUKS header and crypto backend validation
- Imported binary and shell function collision detection
- Static output image checks, ensuring necessary files are packed
- QEMU based test framework with
--testor using theugrd.base.testmodule
Example config and features
- OpenPGP Smartcards (YubiKey) with the
ugrd.crypto.smartcardmodule yubikey example - GPG encrypted LUKS keyfiles with the
ugrd.crypto.gpgmodule gpg example - LUKS with detatched headers detached headers example
- Cryptsetup re-attempts and alternative unlock methods
- Allows for late insertion of a smartcard
cryptsetup_retriesandcryptsetup_autoretry - Can fail back to plain password entry
try_nokey
- Allows for late insertion of a smartcard
- Key entry over serial raid crypt serial
Other info
- Automatic CPIO generation (PyCPIO)
- Device nodes are created within the CPIO only, so true root privileges are not required
- Hardlinks are automatically created for files with matching SHA256 hashes
- Automatic xz compression
- "merged usr" symlinks are created by default and can be disabled by setting
merge_usr = false - ZSH and BASH autocompletion for the
ugrdcommand - Basic hibernation/resume support with
ugrd.fs.resume - Similar usage/arguments as Dracut
Support
µgRD is designed to be as portable as possible, but has only been tested on a limited number of systems.
Operating systems
µgRD was designed to work with Gentoo, but has been tested on:
- Garuda linux
- CachyOS
- Debian 12
- Ubuntu 22.04
Shells
µgRD was originally designed for bash, but should work for POSIX compatible shells including:
- dash
- ksh
Some non-POSIX compatible shells may function, but bash, dash, and ksh are part of automated testing.
Filesystems
If userspace tools are not required to mount a the root filesystem, µgRD can be used with any filesystem supported by the kernel.
The following root filesystems have been tested:
- BTRFS
- EXT4
- XFS
- F2FS
- NILFS2
The root mount can automatically be mounted under an overlay filesystem by using the
ugrd.fs.overlayfsmodule.
The following filesystems have limited support:
- BCACHEFS
- ZFS
Additionally, the following filesystems have been tested for non-root mounts:
- FAT32
If the required kernel module is not built into the kernel, and the filesystem is not listed above, the kernel module may need to be included in kmod_init.
The example config has
kmod_autodetect_lsmodenabled which should automatically pull in the required modules, unless the active kernel differs from the build kernel.
Architectures
µgRD was originally designed for modern amd64 systems but has been tested on:
- arm64
- Raspberry Pi 4
- Raspberry Pi 5
- Quartz64 Model A
- Radxa Zero3E
- riscv64
- StarFive VisionFive 2
Docs
Additional documentation can be found in the docs directory.
Related Skills
claude-opus-4-5-migration
82.1kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
model-usage
334.1kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
diffs
334.1kUse the diffs tool to produce real, shareable diffs (viewer URL, file artifact, or both) instead of manual edit summaries.
mcp-for-beginners
15.6kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
