ShaniOS Technical Documentation

Comprehensive guide to the immutable Linux OS with atomic updates

Overview

Welcome to the ShaniOS technical documentation. This wiki provides comprehensive information about ShaniOS's architecture, installation, configuration, and daily use.

New to ShaniOS? Visit shani.dev for an introduction. This wiki focuses on technical implementation and usage details.

Getting Started

What is ShaniOS?

ShaniOS is an immutable Linux distribution that brings enterprise DevOps practices to desktop computing. Built on Arch Linux with Btrfs filesystem, it provides atomic updates, instant rollback, and system integrity by design.

Traditional vs Immutable OS Traditional Linux System Files ✏️ Writable - Can be modified Common Issues: ❌ Updates can break system ❌ Dependency conflicts ❌ Difficult rollback ❌ System drift over time ❌ Security vulnerabilities vs ShaniOS (Immutable) System Files 🔒 Read-Only - Protected Advantages: ✅ Atomic updates (all or nothing) ✅ Instant rollback capability ✅ Zero-downtime updates ✅ Consistent system state ✅ Enhanced security

Immutable systems protect core files from modification, ensuring reliability and security

1. What's Included

ShaniOS comes fully equipped with a comprehensive software stack, carefully curated for desktop computing, development, gaming, and professional workloads. Everything works out of the box—no configuration required.

System Foundation

  • Base: Arch Linux with rolling release updates, latest stable kernel with Intel/AMD microcode
  • Firmware: Comprehensive collection (linux-firmware, broadcom-wl, SOF audio, ALSA firmware)
  • Bootloader: systemd-boot with UEFI and Secure Boot support (Shim, sbctl, mokutil, sbsigntools)
  • Boot Graphics: Plymouth with BGRT theme (displays manufacturer logo)
  • Initramfs: dracut with boot management tools (efibootmgr, efitools, edk2-shell)
  • Filesystem: Btrfs with compression, CoW snapshots, automated maintenance (scrubbing, balancing, defrag, TRIM)
  • Volume Management: LVM2, software RAID (mdadm, dmraid)
  • Encryption: LUKS2 (cryptsetup), fscrypt, ecryptfs-utils, gocryptfs
  • Additional Filesystems: ext4, XFS, F2FS, exFAT, NTFS (full read/write), FAT
  • Network Storage: NFS client/server, Samba/CIFS, SSHFS
  • Advanced Storage: nvme-cli, ndctl (persistent memory), quota-tools, squashfs-tools, fuse-overlayfs, nbd, duperemove, compsize
  • Updates: Atomic deployment via shani-deploy with automatic rollback, GUI notifications (yad)
  • Firmware Updates: fwupd with automatic checks for UEFI, Thunderbolt, storage, peripherals

Security

  • Access Control: AppArmor MAC enabled by default
  • Firewall: firewalld active with pre-configured rules for KDE Connect/GSConnect and Waydroid
  • Intrusion Prevention: fail2ban available
  • TPM: tpm2-tools and tpm2-tss for hardware security
  • Network Security: OpenSSH, Tailscale mesh VPN, cloudflared tunnels

Desktop & Applications

  • Desktop Environment: GNOME or KDE Plasma (chosen at download), Wayland with X11 compatibility
  • Pre-installed Apps: Vivaldi browser (full codecs), OnlyOffice suite, Gear Lever (Flatpak GUI)
  • Package Formats: Flatpak (primary, auto-updates)
  • Containers: Podman with Docker compatibility (podman-docker, podman-compose), Pods GUI, Distrobox, LXC, systemd-nspawn, fuse-overlayfs
  • Android: Waydroid pre-configured with firewall rules, android-tools (adb, fastboot), android-udev
  • VM Guest Tools: spice-vdagent, qemu-guest-agent, virtualbox-guest-utils, open-vm-tools

Multimedia

  • Audio: PipeWire with ALSA/JACK/PulseAudio compatibility (pipewire-alsa, pipewire-jack, pipewire-pulse), plugins (V4L2, libcamera, Zeroconf), WirePlumber session manager, realtime-privileges
  • Video: Complete GStreamer plugins (base, good, bad, ugly) with hardware acceleration (VA-API, PipeWire, libcamera), speech synthesis (espeak)

Graphics Drivers

  • OpenGL: Mesa 3D latest stack
  • Vulkan: Intel (vulkan-intel), AMD (vulkan-radeon), NVIDIA (vulkan-nouveau), software (vulkan-swrast), VMs (vulkan-virtio), DirectX (vulkan-dzn), Qualcomm (vulkan-freedreno), Apple Silicon (vulkan-asahi), Android (vulkan-gfxstream), debugging (vulkan-mesa-layers)
  • Hardware Acceleration: Intel (libva-intel-driver, intel-media-driver, vpl-gpu-rt), NVIDIA (nvidia-open, nvidia-utils, nvidia-prime, libva-nvidia-driver), generic (libvdpau-va-gl)
  • Hybrid Graphics: nvidia-prime, switcheroo-control for dual-GPU laptops
  • Power: power-profiles-daemon (performance/balanced/power-saver)

Printing & Scanning

  • Print System: CUPS with filters, PDF printer (cups-pdf), network browsing (cups-browsed), PolicyKit (cups-pk-helper), ipp-usb (driverless), Avahi (auto-discovery), ghostscript, a2ps
  • Drivers: Foomatic databases, Gutenprint, HP (hplip-minimal), Epson (epson-inkjet-printer-escpr2), Brother (brlaser), Canon (cnijfilter2), generic (foo2zjs-nightly, splix)
  • Scanning: SANE with network support (sane-airscan), color management (colord-sane, argyllcms)

Networking

  • Connection Management: NetworkManager with GUI (nm-connection-editor), ModemManager (3G/4G/5G), wpa_supplicant, wireless-regdb, wireless_tools, usb_modeswitch
  • VPN: OpenVPN, WireGuard, L2TP, PPTP, strongSwan (IPsec), OpenConnect (Cisco), SSTP, Fortinet (openfortivpn)
  • DNS & Services: dnsmasq, openresolv, nss-mdns, Avahi, bind, pacrunner, openldap
  • Web Server: Caddy with auto-HTTPS
  • Diagnostics: nmap, tcpdump, iperf3, mtr, iftop, ethtool, traceroute, whois
  • Utilities: curl, wget, aria2, rsync, zsync, bridge-utils, openbsd-netcat, net-tools, inetutils

Gaming Hardware

  • Controllers: game-devices-udev (8BitDo, PlayStation DS3/DS4/DualSense/Edge, Xbox 360/One/Series, Nintendo Switch Pro/Joy-Cons/GameCube, Stadia, Shield, Steam, Razer, Nacon, Hori, PowerA, PDP, Mad Catz, Astro C40), fight sticks, VR (Vive, PSVR, Index/SteamVR), flight sticks, uinput for mappers
  • Racing Wheels: Logitech (G29/G920/G923/PRO/G25/G27/Driving Force/MOMO), Thrustmaster (T150/T300RS/T500RS/T248/TS-XW/TS-PC), Fanatec with force feedback and deadzone removal
  • RGB Peripherals: OpenRGB udev rules for keyboards, mice, mousepads, accessories (ASUS, Corsair, Razer, SteelSeries, Logitech, MSI, Cooler Master, NZXT)
  • Gaming Mice: libratbag (ratbagd) for DPI, buttons, LEDs
  • Input Mapping: AntiMicroX with uinput access
  • Legacy: linuxconsole (joysticks), inputattach (serial devices)

Wireless & Connectivity

  • Bluetooth: Complete Bluez stack (bluez-utils, bluez-hid2hci, bluez-cups, bluez-plugins, bluez-obex, bluez-mesh, bluez-tools)
  • Biometrics: fprintd (fingerprint readers)
  • Smart Cards: opensc, ccid, acsccid, libnfc (NFC), libfido2 (FIDO2 keys)
  • Mobile: usbmuxd (iOS connectivity/tethering)
  • Sensors: iio-sensor-proxy (accelerometer, ambient light), geoclue (geolocation), gpsd (GPS), lirc (IR remotes)
  • Advanced: bolt (Thunderbolt authorization), apcupsd (UPS monitoring), libdvdcss (encrypted DVD)

Development Tools

  • Version Control: Git, Subversion, Mercurial
  • Editors: Vim, Vi, Nano, Micro, ed, Tmux (multiplexer)
  • Languages: Python with pip, full Arch ecosystem access
  • Debugging: strace, lsof, elfutils
  • Graphics Dev: vulkan-tools, mesa-utils, clinfo (OpenCL)

System Utilities

  • Core Tools: sudo, which, less, diffutils, patch, time, gnupg, man-db, plocate, grep, sed, awk
  • Compression: 7zip, zip/unzip, unrar, unarchiver, unace, arj, lrzip, lzop
  • Monitoring: htop, inxi, dmidecode, tree, ncdu, sysstat
  • Automation: cronie, logrotate, expect, dialog, pv, jq
  • Misc: bc, words, lynx, bsd-games, texinfo

Shell Experience

  • Default: Zsh with fish-style syntax highlighting, autosuggestions, history substring search
  • Prompt: Starship (git integration, environment detection for Python/Node.js/Rust)
  • Smart Search: McFly (neural network command history)
  • Fuzzy Finder: FZF (Ctrl+R history, Ctrl+T files, Alt+C directories)
  • Alternatives: Bash and Fish with full feature parity

Fonts & Accessibility

  • Fonts: Noto Sans/Serif/Mono, CJK (70-noto-cjk.conf), Emoji (75-noto-color-emoji.conf), Indian languages (90-indian-fonts.conf)
  • Input Methods: IBus with typing-booster, Chinese (ibus-libpinyin), Japanese (ibus-anthy), Korean (ibus-hangul), Vietnamese (ibus-unikey)
  • Accessibility: Orca (screen reader), espeakup (console speech), brltty (braille displays)
  • Localization: glibc-locales, lsb-release

2. User Configuration

The primary user is automatically configured with appropriate permissions during installation.

User Groups

  • wheel: Sudo privileges for system administration
  • input: Direct input device access (keyboards, mice, controllers)
  • realtime: Real-time scheduling, HPET/RTC access for audio production and low-latency gaming
  • video: GPU and video hardware access
  • sys: Hardware monitoring and sensor access
  • cups, lp: Printer management and job submission
  • libvirt, kvm: Virtual machine management
  • scanner: Scanner device access

Firewall Rules

  • KDE Connect/GSConnect: Ports opened in public zone for device pairing, file transfer, notifications, remote control
  • Waydroid: DNS (53/udp, 67/udp), packet forwarding enabled, waydroid0 in trusted zone

3. System Optimizations

ShaniOS includes extensive performance, gaming, and reliability optimizations out of the box, eliminating the need for manual tweaking. These enterprise-grade optimizations are pre-configured and active from first boot.

Memory & Storage Management

  • ZRAM Compression: Automatic RAM compression using the zstd algorithm (configured to use full RAM size) provides improved memory efficiency without requiring swap partitions. The system dynamically allocates compressed swap in RAM, reducing disk I/O and extending SSD lifespan.
  • Optimized Swappiness: Tuned to 133 for balanced memory management on modern systems. This value encourages the kernel to use compressed ZRAM swap before evicting clean page cache, maintaining system responsiveness under memory pressure.
  • Btrfs Maintenance: Automated filesystem maintenance runs in the background, including periodic scrubbing for data integrity, balance operations to optimize storage layout, and defragmentation for improved performance. These operations are scheduled to minimize impact on system usage.
  • Profile Sync Daemon: Browser profiles are stored in tmpfs (RAM) for dramatically faster load times and reduced disk writes. Changes are periodically synchronized back to persistent storage, combining speed with data safety. This reduces SSD wear while improving browser responsiveness.
  • Optimized Page Lock Unfairness: Set to 1 to reduce lock contention and improve multi-threaded application performance, particularly beneficial for databases and high-concurrency workloads.

Gaming & Performance Optimizations

ShaniOS is optimized for gaming performance with multiple layers of system tuning:

Gaming Hardware Support:

  • game-devices-udev Package: Comprehensive udev rules for gaming peripherals with user-grade permissions, including:
    • Controllers: 8BitDo, PlayStation (DualShock 3/4, DualSense, DualSense Edge), Xbox (360, One, Series), Nintendo (Switch Pro, Joy-Cons, GameCube adapter), Google Stadia, NVIDIA Shield, Razer, Nacon, Hori, PowerA, PDP, Mad Catz, Astro C40, and more
    • Fight Sticks & Arcade: Razer Panthera, Mad Catz FightStick, Hit Box, and arcade-style controllers
    • VR Equipment: HTC Vive, PlayStation VR, Valve Index/SteamVR devices with full hardware access
    • Flight Sticks & Sim: VKBSim Gladiator, Logitech F310/F710, and other simulation controllers
    • uinput Support: Early creation of /dev/uinput for virtual device emulation (gamepad mappers, streaming tools)
  • Additional RGB & Peripheral Support: OpenRGB udev rules (60-openrgb.rules) for comprehensive RGB control:
    • RGB Keyboards: ASUS Aura, Corsair, Razer, SteelSeries, Logitech G-series, MSI Mystic Light, Cooler Master, NZXT, and dozens more
    • RGB Mice: Gaming mice from all major manufacturers with LED control
    • RGB Mousepads: Corsair, Razer, SteelSeries, and other illuminated mousepads
    • RGB Accessories: Headset stands, mouse docks, PC case lighting, AIO coolers, and more
  • Racing Wheel Support: Full force feedback and configuration access:
    • Logitech wheels (99-logitech-wheel-perms.rules): G29, G920, G923, G PRO, and legacy wheels (G25, G27, Driving Force, MOMO) with range, gain, LED, and force feedback tuning
    • Thrustmaster wheels (99-thrustmaster-wheel-perms.rules): T150, T300RS, T500RS, T248, TS-XW, TS-PC with spring, damper, and friction control
    • Fanatec wheels (99-fanatec-wheel-perms.rules): Full hardware access with deadzone removal via evdev-joystick
  • Game Input Utilities:
    • AntiMicroX: Gamepad to keyboard/mouse mapper with uinput access (60-antimicrox-uinput.rules)
    • Steam Controller support: Native hardware access for Valve's gaming ecosystem

Kernel-Level Gaming Optimizations:

  • Game Compatibility Kernel Parameters: Pre-configured for maximum compatibility:
    • Increased PID limit (65535) supports complex games with many processes
    • Expanded memory map areas (2147483642) accommodates large game worlds and high-resolution texture streaming
    • Enhanced inotify limits (1024 instances, 524288 watches) for games with extensive file monitoring
  • Network Optimization: TCP FIN timeout reduced to 5 seconds (from default 60s) enables games to quickly reuse network ports when restarting. This Valve SteamOS optimization prevents "address already in use" errors in multiplayer games.
  • CPU Scheduler Tuning: Multiple scheduler optimizations for gaming performance:
    • CFS bandwidth slice: 3000μs for improved interactivity and reduced input latency
    • Base slice: 3000000ns (3ms) for consistent frame times
    • Migration cost: 500000ns to prevent excessive CPU migration overhead
    • Migration limit: 8 tasks per balance operation for optimal multi-core utilization
    • Child runs first: Disabled (0) to prevent priority inversion in gaming scenarios
    • Autogroup scheduling: Enabled (1) to automatically group related processes for better desktop responsiveness
  • Advanced Memory Management:
    • MGLRU (Multi-Gen LRU) enabled with aggressive settings for intelligent memory reclaim that preserves recently accessed game data
    • Transparent Hugepage set to madvise for selective large page usage, improving performance for games that explicitly request it
    • Optimized watermark scaling (500) and minimum free memory (1MB) for consistent response times under load
    • Reduced compaction proactiveness (0) minimizes latency spikes during memory allocation
    • Watermark boost factor: Set to 1 (minimal) to reduce aggressive memory reclaim
    • Zone reclaim disabled (0) prevents unnecessary NUMA overhead on multi-socket systems
  • GameMode Integration: GameMode daemon enabled globally for all users, providing automatic performance optimizations when gaming. GameMode dynamically adjusts CPU governor, process priorities, I/O scheduling, and GPU performance levels. Games are automatically detected and optimized without manual configuration.
  • High-Precision Timers: HPET and RTC frequencies increased to 3072 Hz (from default 64 Hz) for superior timing accuracy. This reduces input lag and improves frame pacing in games requiring precise timing, particularly beneficial for rhythm games and competitive shooters.

Process Management & Responsiveness

ShaniOS enables several system services for intelligent resource management:

  • Ananicy-cpp: Automatic process priority management service with game-aware rules (enabled by default). Background tasks are automatically deprioritized when games or media applications are active, ensuring smooth performance without manual nice/renice commands.
  • systemd-oomd: System-wide OOM (Out-Of-Memory) daemon enabled by default prevents system freezes. When memory pressure is detected, systemd-oomd selectively terminates low-priority processes based on memory usage patterns and process priorities, keeping critical services and active applications running.
  • IRQBalance: Service enabled to optimize interrupt distribution across CPU cores, preventing a single core from becoming overwhelmed with hardware interrupts. This is particularly important for systems with high-bandwidth network cards or NVMe drives, ensuring balanced load across all cores.
  • Increased File & Process Limits: Default limits raised to 1,048,576 for both open files (NOFILE) and processes (NPROC). This prevents "too many open files" errors in development environments, containerized workloads, and servers running multiple services.
  • Fast Shutdown: Reduced timeout values (10s for stop, 10s for abort) ensure quick system shutdowns without waiting for unresponsive services. Services that fail to stop gracefully are automatically killed after the timeout.

Security Hardening

  • AppArmor Mandatory Access Control:
    • AppArmor (apparmor.service): Enabled by default to confine system services and applications with security profiles
  • Firewall Protection:
    • firewalld: Active firewall enabled by default, denying inbound connections while allowing essential services
    • Pre-configured rules: Automatic firewall configuration for KDE Connect/GSConnect and Waydroid during installation
  • Kernel Hardening:
    • NMI watchdog disabled for faster boot times and reduced CPU overhead (this is safe on modern systems with other hang detection mechanisms)
    • Unprivileged user namespaces enabled for secure containerization (required for Podman, Flatpak sandboxing, and Distrobox)
    • Magic SysRq keys enabled for emergency recovery (Alt+SysRq+REISUB sequence for safe reboots during system hangs)
  • Hardware Access Controls: The realtime group receives permission to access HPET and RTC devices directly. This is essential for professional audio production, real-time multimedia applications, and low-latency gaming. Users in the realtime group can run applications with real-time scheduling priorities.
  • Blacklisted Kernel Modules:
    • PC speaker (pcspkr) disabled to eliminate annoying beeps
    • Intel Management Engine (mei, mei_me) disabled for enhanced privacy and security, removing Intel's remote management interface

Boot & System Efficiency

  • Plymouth (BGRT Theme): Smooth graphical boot experience with the BGRT (Boot Graphics Resource Table) theme enabled by default. Plymouth provides a polished boot animation while hiding technical boot messages, presenting a clean interface for password entry during LUKS unlock. The BGRT theme displays your manufacturer's logo for a seamless firmware-to-OS transition.
  • Journal Size Limit: SystemD journal capped at 50MB to prevent excessive disk usage from log accumulation. This is particularly important on systems with limited storage, while still maintaining sufficient logs for troubleshooting recent issues.
  • Reduced Kernel Messages: Console printk level set to 3 (errors and critical messages only) for cleaner boot output. This eliminates informational noise while preserving important error messages needed for diagnostics.
  • Optimized Service Startup: Parallel service initialization with optimized dependencies reduces boot time. Non-critical services are delayed or started on-demand, prioritizing services required for desktop readiness.
  • Time Synchronization: systemd-timesyncd enabled by default for automatic network time protocol (NTP) synchronization, ensuring accurate system time without requiring a full NTP daemon.
  • Socket Activation: Many services use socket activation for on-demand startup, reducing boot time and memory usage:
    • pcscd.socket: Smart card daemon (PC/SC) starts only when smart cards are accessed
    • lircd.socket: Linux Infrared Remote Control daemon for IR remote support
    • gpsd.socket: GPS daemon for location services and navigation hardware
    • cups.socket: Printing service starts on-demand when print jobs are sent
    • avahi-daemon.socket: Network service discovery (mDNS/DNS-SD) for zero-configuration networking
    • saned.socket: Scanner daemon starts when scanning is needed

Hardware & Peripheral Support

ShaniOS enables comprehensive hardware support services by default:

  • Printing:
    • CUPS (cups.socket): Common UNIX Printing System for all printer support
    • cups-browsed: Automatic printer discovery on the network
    • ipp-usb: IPP-over-USB support for modern driverless printers
    • Avahi (avahi-daemon.socket): Network printer discovery via Bonjour/mDNS
  • Scanning:
    • SANE (saned.socket): Scanner Access Now Easy for scanner support
    • ipp-usb: Also provides driverless scanning support
  • Biometric Authentication:
    • fprintd: Fingerprint reader support for login and authentication
  • Bluetooth:
    • bluetooth.service: Full Bluetooth stack for wireless peripherals, audio, and file transfer
  • Mobile Devices:
    • usbmuxd: iOS device support for iPhone/iPad connectivity, file transfer, and tethering
  • Networking:
    • NetworkManager: Intelligent network connection management for wired, wireless, VPN, and mobile connections
    • ModemManager: Mobile broadband modem support (3G/4G/5G)
  • Gaming Peripherals:
    • ratbagd: Gaming mouse configuration daemon for DPI, button mapping, and LED control (libratbag)
    • inputattach: Serial input device support (legacy joysticks, game controllers)
  • Location Services:
    • geoclue: Geolocation service for applications requiring location data
    • gpsd.socket: GPS hardware support
  • Thunderbolt Security:
    • bolt: Thunderbolt 3 device authorization and management
  • Power Management:
    • apcupsd: APC UPS monitoring and management for battery backup systems
    • power-profiles-daemon: System power profile management (performance, balanced, power-saver)
    • switcheroo-control: Hybrid graphics switching for laptops with dual GPUs (Intel + NVIDIA/AMD)
  • Firmware Updates:
    • fwupd: Linux Vendor Firmware Service for automatic firmware updates
    • fwupd-refresh.timer: Periodic firmware update checks

Enhanced Shell Experience

ShaniOS provides a modern, feature-rich shell environment that rivals the best developer setups:

  • Zsh as Default Shell: Powerful shell with advanced completion, globbing, and command-line editing. Zsh provides better defaults than Bash while maintaining compatibility with Bash scripts.
  • Fish-Style Features:
    • Syntax highlighting shows valid/invalid commands in real-time as you type
    • Autosuggestions suggests commands from history with ghost text completion
    • History substring search allows arrow-up/down to search through history based on what you've typed
  • Starship Prompt: Fast, minimal, and infinitely customizable prompt with intelligent git integration, showing branch status, ahead/behind commits, and repository state. The prompt adapts to display context-relevant information (Python virtualenv, Node.js version, Rust toolchain, etc.).
  • McFly: Neural network-powered command history search learns from your usage patterns. McFly prioritizes frequently used commands in relevant directories and contexts, providing smarter suggestions than traditional reverse-i-search.
  • FZF (Fuzzy Finder): Integrated fuzzy finding for files, command history, and directory navigation. Ctrl+R searches history, Ctrl+T inserts file paths, and Alt+C changes directories—all with fuzzy matching and preview windows.
  • Multiple Shell Support: Bash and Fish shells included with completion support. Switch shells anytime with chsh while maintaining consistent functionality across all options.

Automated Maintenance

ShaniOS performs regular background maintenance to keep your system healthy without manual intervention. These systemd timers and services are enabled by default:

  • btrfs-scrub.timer: Monthly scrubbing to detect and repair data corruption using filesystem checksums
  • btrfs-balance.timer: Periodic filesystem balancing redistributes data across drives for optimal performance
  • btrfs-defrag.timer: Automatic defragmentation runs on fragmented files to improve read performance
  • btrfs-trim.timer: Regular TRIM operations for SSD optimization and lifespan extension
  • profile-sync-daemon (psd): Browser cache synchronization from RAM to disk happens automatically (enabled globally for all users)
  • systemd-timesyncd: Automatic time synchronization keeps system clock accurate
  • ZRAM compression/decompression: Transparently handles memory pressure without user interaction

All maintenance operations are scheduled during low-usage periods and use minimal system resources to avoid impacting active work.

Note: All these optimizations are pre-configured and active from first boot. No manual configuration, tweaking, or performance tuning required. ShaniOS provides enterprise-grade optimization out of the box.

Key Concepts

1. Immutability

The root filesystem (/) is mounted read-only, preventing any modifications to system files. This ensures:

  • Malware cannot modify system binaries
  • Updates cannot partially fail and corrupt the system
  • System always boots to a known-good state
  • Configuration changes are isolated and manageable

2. Blue-Green Deployment

ShaniOS maintains two complete system images (@blue and @green). While one is active, updates are applied to the inactive one. On next boot, you switch to the updated system. If it fails, automatic rollback occurs.

3. Atomic Updates

Updates either succeed completely or fail safely—no partial updates that leave your system in a broken state. This is achieved through:

  • Updating the inactive system image
  • Switching boot target only after successful update
  • Automatic rollback on boot failure

4. Selective Persistence

While the system is immutable, user data and configurations persist:

  • /home: Your personal files and settings
  • /etc: System configuration (via overlay filesystem)
  • Service data: Application states, databases, containers

Understanding Immutability

ShaniOS's immutability fundamentally changes how you interact with the system. Understanding this concept is key to using ShaniOS effectively.

What You CAN Do

  • ✅ Install applications via Flatpak
  • ✅ Edit configuration files in /etc
  • ✅ Create and modify files in /home
  • ✅ Run containers (Podman, Distrobox, LXC)
  • ✅ Update the entire system atomically
  • ✅ Store data in /data and persistent subvolumes

What You CANNOT Do

  • ❌ Use pacman to install traditional packages
  • ❌ Modify files in / (root filesystem)
  • ❌ Edit files in /usr, /bin, /lib directly
  • ❌ Install software that requires system-level changes

Why This Design?

Security

Malware cannot modify system files or persist across reboots

Reliability

Updates are atomic - they either work completely or fail safely

Rollback

Instant recovery from failed updates or system issues

Consistency

System state is always predictable and reproducible

Blue-Green Deployment

ShaniOS implements blue-green deployment using Btrfs subvolumes—a strategy adapted from DevOps for desktop Linux.

Blue-Green Deployment Model @blue (Active) Currently Running System Mounted as / @green (Inactive) Ready for Update System Standby Mode Update Flow

Two complete system images with only one active at a time

How It Works

  1. System maintains @blue and @green subvolumes
  2. One subvolume is active (mounted as /), the other inactive
  3. Updates apply to inactive subvolume
  4. Bootloader updated to point to updated subvolume
  5. Reboot switches to updated system
  6. Previous version remains available for instant rollback

Advantages

  • Atomic Updates: All-or-nothing updates
  • Zero Downtime: Active system never modified
  • Instant Rollback: Boot into previous version anytime
  • Safe Testing: Validate updates before committing

Atomic Updates

ShaniOS uses an intelligent multi-layered update system with automatic checking, user notifications, and the shani-deploy tool for atomic system updates.

Update Process Flow 1 Check Auto checker runs Finds new release 2 Notify GUI notification User approval 3 Download Mirror discovery Resume support 4 Verify SHA256 checksum GPG signature 5 Deploy Extract to inactive Update bootloader Before Update @blue ✅ Active (Booted) @green ⏸️ Inactive (Old) shani-deploy runs while booted into @blue Update is written to @green After Reboot @blue ⏸️ Inactive (Rollback) @green ✅ Active (Updated!) System boots into @green with new version @blue remains as instant rollback option

Zero-downtime update process with automatic rollback capability

Persistence Strategy

ShaniOS selectively persists data across immutable system updates through bind mounts and dedicated subvolumes.

What Persists Across Updates? ❌ Immutable (Replaced) / (root filesystem) /usr (programs) /bin, /sbin (binaries) /lib (libraries) /opt (optional software) Gets new version on update ✅ Persistent (Kept) /home (your files) /etc (configurations) /var/log (system logs) /data (app data) Flatpak apps Containers & VMs Survives all updates 🔄 Volatile (Temporary) /var (tmpfs) /tmp (temporary) /run (runtime) Cleared on reboot (except bind-mounted) service data)

ShaniOS intelligently separates immutable system files from persistent user data

Location Type Behavior
/ Read-only Immutable system files
/etc Overlay Writable, persists in @data
/var tmpfs Volatile, cleared on reboot
/var/log Btrfs @log Persistent logs
/var/lib/* Bind mount Selective persistence from @data/varlib
/var/spool/* Bind mount Selective persistence from @data/varspool
/home Btrfs @home Persistent user data

Bind-Mounted Service State

Critical service data is bind-mounted from @data subvolume:

# Example bind mounts from fstab

# Network configuration
/data/varlib/NetworkManager /var/lib/NetworkManager none bind,nofail 0 0

# Bluetooth pairings
/data/varlib/bluetooth /var/lib/bluetooth none bind,nofail 0 0

# systemd state
/data/varlib/systemd /var/lib/systemd none bind,nofail 0 0

What Persists

  • Core: dbus, systemd, NetworkManager
  • Authentication: AccountsService, fprint, bluetooth, boltd
  • Display: gdm, sddm
  • Hardware: colord, upower, cups, sane
  • Security: firewalld
  • Networking: geoclue, samba, nfs

Bind Mount Handling

ShaniOS intelligently handles bind mounts during configuration:

  • Source check: Only mounts if source directory exists in @data
  • Target check: Only mounts if service is installed in the system
  • Graceful skipping: Missing services (e.g., sddm on GNOME) don't cause errors
  • Optional services: Services not present in base system are automatically skipped

Spool Directory Persistence

In addition to /var/lib, some /var/spool directories are also persisted:

  • anacron: Scheduled job state
  • cron: Cron job state
  • cups: Print queue
  • samba: Samba print queue

Installation

System Requirements

ShaniOS System Requirements
Component Minimum Recommended
Processor x86_64 dual-core with VT-x/AMD-V x86_64 quad-core or better
Memory 4 GB RAM 8 GB RAM or more
Storage 32 GB (dual-image architecture) 64 GB or more
Firmware UEFI (required) UEFI with TPM 2.0
Installation Media 8 GB USB drive 16 GB USB 3.0 drive

Why 32GB minimum? ShaniOS maintains two complete system images (@blue and @green) for atomic updates. However, Btrfs Copy-on-Write shares unchanged data between them, resulting in only ~18% overhead compared to traditional systems.

Pre-Installation Setup

BIOS/UEFI Configuration

Configure your firmware before installation (typically accessed via F2, F10, Del, or Esc during startup):

1

Enable UEFI Boot

Disable legacy/CSM mode. ShaniOS requires UEFI

2

Disable Fast Boot

Fast Boot can interfere with USB boot and Linux installation

3

Disable Secure Boot (Temporarily)

Required for installation. Can be re-enabled after enrolling ShaniOS MOK keys

4

Set SATA Mode to AHCI

Ensures optimal disk performance and compatibility

5

Enable Virtualization

Enable Intel VT-x or AMD-V for container support

Creating Installation Media

Download the ShaniOS ISO from shani.dev and write it to USB:

  • Recommended: Balena Etcher (cross-platform, user-friendly)
  • Windows: Rufus (advanced options available)
  • Linux/Mac: dd command or GNOME Disks

Installation Steps

Installation takes approximately 10-15 minutes:

1

Boot from USB

Press F12, F2, or Del during startup. Select your USB drive from the boot menu.

2

Select "Install ShaniOS"

Choose the installation option from the boot menu

3

Language & Region

Select language, timezone, and keyboard layout

4

Disk Selection

Choose target disk and partitioning scheme (automatic recommended)

5

Encryption (Optional)

Enable LUKS2 full-disk encryption. Recommended for laptops and portable systems.

6

Install

The installer creates Btrfs subvolumes, installs the base system, and configures the bootloader

7

Reboot

Remove USB drive when prompted and reboot into ShaniOS

First Boot Configuration

On first boot, the Initial Setup wizard guides you through:

  • Creating your user account
  • Configuring network connections
  • Setting privacy preferences
  • Enabling location services (optional)
  • Customizing appearance settings

This approach keeps installation fast while personalizing the system on first use.

Architecture

Btrfs Deep Dive

ShaniOS leverages advanced Btrfs features for immutability and efficiency.

Copy-on-Write (CoW)

Btrfs CoW minimizes storage duplication:

  • Shared data blocks between @blue and @green
  • Only ~18% overhead despite dual root system
  • Modified blocks consume additional space
  • Efficient updates even with two complete systems

Transparent Compression

# Default mount options
compress=zstd,space_cache=v2,autodefrag
  • Reduces disk usage by 30-50%
  • Minimal CPU overhead
  • Improves SSD lifespan

Performance Optimizations

Specific subvolumes use nodatacow:

  • @swap: CoW disabled for swap files (required)
  • @libvirt: VM disk images benefit from direct writes

Mount Options by Subvolume

Subvolume Mount Options Reason
@blue / @green ro,noatime,compress=zstd,space_cache=v2,autodefrag Read-only root with compression
@home, @data, @cache, @log rw,noatime,compress=zstd,autodefrag,space_cache=v2 Read-write with compression
@flatpak, @waydroid, @containers rw,noatime,compress=zstd,autodefrag,space_cache=v2 Application storage with compression
@machines, @lxc rw,noatime,compress=zstd,autodefrag,space_cache=v2 Container storage
@libvirt rw,noatime,nodatacow,nospace_cache VM performance (no CoW, no compression)
@swap rw,noatime,nodatacow,nospace_cache Swap file requirement (no CoW)

Why noatime?

All subvolumes use noatime to improve performance:

  • Prevents writing to disk every time a file is read
  • Significantly reduces SSD wear
  • Improves battery life on laptops
  • No impact on most applications (very few rely on access times)

Filesystem Structure

ShaniOS uses Btrfs with a sophisticated subvolume layout:

Btrfs Subvolume Structure /dev/sda2 (Btrfs) System Images @blue @green Root filesystems Read-only User Data @home @data Persistent Services @flatpak @containers @waydroid Isolated Additional Subvolumes @log @cache @machines @lxc @libvirt @swap

Organized subvolume layout separating system, user data, and services

ShaniOS Subvolume Layout
Subvolume Mount Point Purpose
@blue / @green / Root filesystems for blue-green deployment
@home /home User data and personal configurations
@data /data Overlay storage and persistent service data
@log /var/log System logs across reboots
@cache /var/cache Package manager cache
@flatpak /var/lib/flatpak Flatpak applications and runtimes
@waydroid /var/lib/waydroid Android system images and data
@containers /var/lib/containers Podman/Docker container storage
@machines /var/lib/machines systemd-nspawn containers
@lxc /var/lib/lxc LXC containers
@libvirt /var/lib/libvirt Virtual machine disk images (nodatacow)
@swap /swap Swap file container (nodatacow)

Overlay Filesystem

OverlayFS enables writable /etc on read-only root.

Overlay Filesystem Structure Lower Layer (Read-Only) /etc from @blue/@green Base system configs 🔒 Upper Layer (Writable) /data/overlay/etc/upper Your changes stored here ✏️ Merged View (What you see) /etc appears writable Changes persist across updates Original files remain untouched

Configuration changes persist while system files remain immutable

# /etc overlay mount
overlay /etc overlay rw,lowerdir=/etc,upperdir=/data/overlay/etc/upper,workdir=/data/overlay/etc/work 0 0

Overlay Directories

Both /etc use overlay filesystems with this structure:

@data/overlay/etc/
  ├── lower/      # (unused, just structure)
  ├── upper/      # Your changes stored here
  └── work/       # Overlay working directory

Viewing Changes

# List all overlay modifications
ls -la /data/overlay/etc/upper

# Compare with base system
diff -r /etc /data/overlay/etc/upper

Boot Process

Understanding how ShaniOS boots:

ShaniOS Boot Sequence 1 UEFI Firmware Loads systemd-boot from ESP (/boot/efi) 2 systemd-boot Presents boot menu with @blue and @green entries 3 Kernel Loading Boots selected Unified Kernel Image (UKI) 4 Initramfs Unlocks LUKS (if encrypted), mounts selected root subvolume 5 systemd Init & Filesystem Setup Root read-only, /var tmpfs, /etc overlay, persistent mounts, services start 6 Desktop Environment GNOME or KDE Plasma launches → Ready to use!

Six-stage boot process from firmware to desktop

Important Notes:

  • Dual booting not recommended (other OSes may break bootloader)
  • Use Flatpak, containers, or AppImages for software
  • Root filesystem is immutable by design

Bootloader Configuration

ShaniOS uses systemd-boot with Unified Kernel Images (UKI):

  • Timeout: 5 seconds
  • Console mode: Maximum resolution
  • Editor: Disabled for security (prevents boot parameter tampering)
  • Default entry: Current active slot (@blue or @green)

Boot Entry Naming

Boot menu entries clearly show system state:

  • shanios-blue (Active): Currently running system
  • shanios-green (Candidate): Standby system for next update

After an update, the labels switch automatically.

UEFI Boot Entry

ShaniOS creates a UEFI boot entry during installation:

  • Label: shanios
  • Loader: \EFI\BOOT\BOOTX64.EFI (Shim for Secure Boot)
  • Fallback: Boot entry creation failures don't stop installation

Shim and Secure Boot Chain

The boot chain when Secure Boot is enabled:

UEFI Firmware
    ↓
shimx64.efi (signed by Microsoft, validates next stage)
    ↓
grubx64.efi (actually systemd-boot, signed by MOK)
    ↓
Unified Kernel Image (signed by MOK)
    ↓
Linux Kernel + Initramfs

Kernel Command Line

ShaniOS uses these boot parameters:

quiet splash systemd.volatile=state ro 
lsm=landlock,lockdown,yama,integrity,apparmor,bpf 
rootfstype=btrfs 
rootflags=subvol=@blue,ro,noatime,compress=zstd,space_cache=v2,autodefrag
root=/dev/mapper/shani_root  # If encrypted
rd.luks.uuid=... rd.luks.name=... rd.luks.options=tpm2-device=auto  # If TPM enrolled
resume=UUID=... resume_offset=...  # If swapfile exists

Kernel Hardening

Security-focused kernel parameters are enabled by default:

lsm=landlock,lockdown,yama,integrity,apparmor,bpf

This enables multiple Linux Security Modules for layered protection:

  • Landlock: Sandboxing for unprivileged processes
  • Lockdown: Restricts kernel access from userspace
  • Yama: Ptrace restrictions to prevent debugging attacks
  • Integrity: File integrity measurement
  • AppArmor: Mandatory Access Control profiles
  • BPF: Secure BPF program loading

Kernel Parameter: systemd.volatile=state

The systemd.volatile=state kernel parameter creates a tmpfs (RAM-based) overlay for /var, making it volatile by default:

# From kernel command line
systemd.volatile=state

# Result: /var is tmpfs, cleared on every reboot
# Only explicitly mounted subdirectories persist

Hibernation Support

ShaniOS automatically configures hibernation if a swapfile is created:

  • Swapfile location: /swap/swapfile (in @swap subvolume)
  • Size: Equal to RAM (or less if disk space limited)
  • Resume offset: Automatically calculated using btrfs inspect-internal map-swapfile
  • Btrfs CoW: Disabled on @swap subvolume for reliability

Disk Space for Swapfile: If available disk space is less than RAM size, swapfile creation is skipped and the system uses zram for swap instead. Hibernation will not be available in this case.

Security

Security Features

ShaniOS implements defense-in-depth security:

🔒

Immutable Root

Read-only filesystem prevents malware from modifying system files

🔐

Full-Disk Encryption

LUKS2 with argon2id protects data at rest

📦

App Sandboxing

Flatpak provides application isolation and permission control

🛡️

AppArmor MAC

Mandatory access control confines system services

🔥

Active Firewall

firewalld denies inbound connections by default

Secure Boot Setup

ShaniOS supports UEFI Secure Boot via Machine Owner Keys (MOK).

Automatic Secure Boot Enrollment (If Enabled During Install)

If you enabled Secure Boot during installation:

  1. On first reboot, MOK Manager will appear automatically
  2. Select "Enroll MOK"
  3. Enter the password: shanios
  4. Reboot to complete the enrollment
  5. Secure Boot will be active with ShaniOS keys enrolled

MOK (Machine Owner Key): This allows ShaniOS's signed bootloader and kernel to boot with Secure Boot enabled. The password "shanios" is only used during the one-time enrollment process and is not stored.

Manual Secure Boot Enablement

To enable Secure Boot after installation:

1

Import MOK Key

sudo mokutil --import /etc/secureboot/keys/MOK.der

Set a one-time password when prompted

2

Reboot and Enroll

MOK Manager appears on reboot. Select "Enroll MOK" and enter your password

3

Enable in BIOS

Enter BIOS/UEFI settings and enable Secure Boot if still disabled

4

Verify Enrollment

sudo mokutil --list-enrolled

Note: If MOK Manager doesn't appear, repeat step 1 and reboot. It only triggers when a key is pending enrollment.

TPM-Based Encryption

Enroll your LUKS encryption key to TPM 2.0 for automatic unlocking.

Prerequisites

  • TPM 2.0 hardware module (enabled in BIOS/UEFI)
  • LUKS2 encryption enabled during installation
  • Recommended: Secure Boot enabled for maximum security

Enrollment Process

1

Verify TPM

systemd-cryptenroll --tpm2-device=list
2

Check Secure Boot Status

mokutil --sb-state

If disabled, consider enabling Secure Boot first

3

Find Your LUKS Device

ShaniOS uses /dev/mapper/shani_root as the unlocked LUKS mapping. To find the underlying encrypted device:

# Get the physical encrypted device
LUKS_DEVICE=$(sudo cryptsetup status shani_root | grep 'device:' | awk '{print $2}')
echo "Your encrypted device is: $LUKS_DEVICE"

# Example output: /dev/sda2 or /dev/nvme0n1p2
4

Enroll Encryption Key

With Secure Boot (recommended):

LUKS_DEVICE=$(sudo cryptsetup status shani_root | grep 'device:' | awk '{print $2}')
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 "$LUKS_DEVICE"

Without Secure Boot:

LUKS_DEVICE=$(sudo cryptsetup status shani_root | grep 'device:' | awk '{print $2}')
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0 "$LUKS_DEVICE"

Enter your LUKS password when prompted

5

Regenerate Boot Images

Both @blue and @green must be updated:

sudo gen-efi configure blue
sudo gen-efi configure green
6

Test & Verify

Reboot. System should unlock automatically.

# Verify enrollment
LUKS_DEVICE=$(sudo cryptsetup status shani_root | grep 'device:' | awk '{print $2}')
sudo cryptsetup luksDump "$LUKS_DEVICE" | grep systemd-tpm2

Remove TPM Enrollment

To restore password-only unlocking:

LUKS_DEVICE=$(sudo cryptsetup status shani_root | grep 'device:' | awk '{print $2}')
sudo systemd-cryptenroll --wipe-slot=tpm2 "$LUKS_DEVICE"
sudo gen-efi configure blue
sudo gen-efi configure green

Re-enroll After Enabling Secure Boot

If you enable Secure Boot after TPM enrollment:

# Get the device
LUKS_DEVICE=$(sudo cryptsetup status shani_root | grep 'device:' | awk '{print $2}')

# Remove old enrollment
sudo systemd-cryptenroll --wipe-slot=tpm2 "$LUKS_DEVICE"

# Re-enroll with Secure Boot protection
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 "$LUKS_DEVICE"

# Update boot images
sudo gen-efi configure blue
sudo gen-efi configure green

Important:

  • Your LUKS password remains valid as fallback
  • Firmware changes break TPM unlock (password required)
  • Both boot images must be regenerated
  • Keep LUKS password secure for recovery

Using ShaniOS

System Updates

Automatic Update Checker

ShaniOS includes a background service that automatically checks for updates:

  • shani-update: Runs periodically via systemd user timer
  • Checks SourceForge for new releases matching your system profile
  • Notifies you when updates are available
  • Provides user-friendly GUI dialogs for update approval
  • Automatically launches terminal-based update installer

Manual Update

sudo shani-deploy

The update process includes:

  1. Prerequisites check (root access, internet, disk space)
  2. Power management (prevents sleep/shutdown)
  3. Boot validation (verifies current @blue or @green state)
  4. Mirror discovery (finds fastest SourceForge mirror)
  5. Intelligent download with resume support
  6. Verification (SHA256 checksum and GPG signature)
  7. Deployment to inactive subvolume
  8. UKI generation for both slots
  9. Bootloader update
  10. Configuration migration

Automatic Rollback: If the updated system fails to boot, ShaniOS automatically reverts to the previous working state on next startup. The boot-success marker system tracks successful boots.

Update Channels

ShaniOS supports multiple update channels:

  • stable (default): Thoroughly tested releases
  • latest: Newest features (may be less stable)

Set your preferred channel:

# Choose channel
sudo shani-deploy -t latest

# Or set permanently
echo "latest" | sudo tee /etc/shani-channel

Update Options

# Show help
sudo shani-deploy --help

# Force rollback to previous version
sudo shani-deploy --rollback

# Manual cleanup of old backups and downloads
sudo shani-deploy --cleanup

# Storage analysis with deduplication
sudo shani-deploy --storage-info

# Dry run (simulate without changes)
sudo shani-deploy --dry-run

# Verbose output for troubleshooting
sudo shani-deploy --verbose

Other Updates

# Update Flatpak applications
flatpak update

# Update firmware via LVFS
fwupdmgr refresh
fwupdmgr update

Software Management

ShaniOS uses Flatpak as the primary application delivery method, with containers for development tools and system-level software.

Software Installation Methods 📦 Flatpak Apps Best For: Desktop applications Web browsers Office suites Media players Sandboxed & Isolated Install: flatpak install ... 🐳 Containers Best For: Development tools CLI utilities Build environments Testing software Full Linux Environment Use: distrobox, podman, lxc 📄 AppImage Best For: Portable apps One-time tools Apps not in Flatpak Beta software Self-Contained Run: chmod +x && ./app.AppImage

Choose the right installation method for your needs

Managing Applications via GUI

  • GNOME: Use GNOME Software for graphical app management
  • KDE: Use Discover for browsing and installing Flatpaks
  • Both: Support Flathub integration out of the box

Installing Flatpak Applications

# Search for applications
flatpak search keyword

# Install from Flathub
flatpak install flathub org.application.Name

# List installed apps
flatpak list

# Remove an app
flatpak uninstall org.application.Name

Gaming

Game Launchers:

flatpak install flathub com.valvesoftware.Steam
flatpak install flathub com.heroicgameslauncher.hgl
flatpak install flathub net.lutris.Lutris
flatpak install flathub org.libretro.RetroArch

Gaming Peripherals:

flatpak install flathub io.github.antimicrox.antimicrox  # Gamepad mapper
flatpak install flathub org.freedesktop.Piper            # Mouse configuration
flatpak install flathub org.openrgb.OpenRGB              # RGB lighting

Performance Tools:

flatpak install flathub io.github.benjamimgois.goverlay  # Overlay manager
flatpak install flathub org.freedesktop.Platform.VulkanLayer.MangoHud
flatpak install flathub org.freedesktop.Platform.VulkanLayer.gamescope

Windows Applications

Run Windows apps using Wine via Bottles:

flatpak install flathub com.usebottles.bottles

Using Containers for Development

Distrobox (Recommended for CLI tools):

# Create Ubuntu environment
distrobox create --name ubuntu --image ubuntu:22.04

# Enter environment
distrobox enter ubuntu

# Inside container, install anything with apt
sudo apt update && sudo apt install build-essential nodejs python3

Podman (Docker-compatible):

# Run container
podman run -it --rm ubuntu:22.04 bash

# Docker Compose style
podman compose up -d

LXC System Containers:

lxc launch images:ubuntu/22.04 my-container

Android Applications

Waydroid is pre-installed. Launch from Applications menu and complete setup wizard.

Editing System Configuration

The /etc directory uses overlay filesystem, allowing modifications:

# Edit system configuration
sudo nano /etc/some-config-file

# Changes are stored in /data/overlay/etc/upper
# and persist across system updates

Webhosting

Web Hosting & Networking

ShaniOS lets you host websites and services directly from your desktop or laptop—even on home internet connections without a static IP. All tools listed here are installed for convenience and are not enabled or running by default.

Security First: These services are disabled by default. Only enable what you need, and always configure firewall rules appropriately. Never expose services publicly without understanding the security implications.

How Desktop Web Hosting Works

Desktop Web Hosting Architecture 💻 Your Desktop/Laptop Caddy Web Server Hosting your content localhost:8080 🛡️ firewalld Host Firewall Controls traffic flow Blocks/permits ports 🌐 Cloudflared Tunnel Encrypted Outbound Tunnel No port forwarding needed Hides your real IP PUBLIC ACCESS 🌍 🌍 Public Internet Anyone with URL yoursite.example.com Automatic HTTPS WORLD ACCESSIBLE 🌐 🔐 Tailscale VPN Private Mesh Network WireGuard encrypted Peer-to-peer when possible PRIVATE ONLY 🔒 📱 Your Devices Phone · Tablet · Laptop On Tailscale network Access privately AUTHORIZED ONLY 🔐 PUBLIC PRIVATE Cloudflared: Public HTTPS access · No static IP needed · Hides your home IP Tailscale: Private VPN · Only authorized devices · Peer-to-peer mesh

Two secure paths: 🌐 Public access via Cloudflared tunnel, 🔐 Private access via Tailscale VPN

Pre-installed Networking Tools

Caddy Web Server

Modern, lightweight web server with automatic HTTPS for hosting sites from your desktop. Caddy makes it easy to host personal websites, dashboards, or file servers. It is not active by default and runs only when you start and configure it.

Start Caddy:

sudo systemctl start caddy
sudo systemctl enable caddy  # Auto-start on boot

Ideal for web-hosting directly from your desktop without needing a dedicated server.

Cloudflared

Cloudflared creates an encrypted tunnel to Cloudflare, allowing public HTTPS access to services running on your desktop. It is disabled by default and requires manual setup.

Setup:

# Login to Cloudflare
cloudflared tunnel login

# Create tunnel
cloudflared tunnel create my-tunnel

# Configure tunnel (edit config file)
sudo nano ~/.cloudflared/config.yml

# Example config:
# tunnel: YOUR-TUNNEL-ID
# credentials-file: /home/USER/.cloudflared/YOUR-TUNNEL-ID.json
# 
# ingress:
#   - hostname: mysite.example.com
#     service: http://localhost:8080
#   - service: http_status:404

# Start tunnel
cloudflared tunnel run my-tunnel

# Enable as service
sudo cloudflared service install
sudo systemctl start cloudflared
sudo systemctl enable cloudflared

Firewall Configuration:

# Cloudflared creates OUTBOUND connections only
# No inbound ports need to be opened in firewall
# This is the security advantage of tunnels!

# Verify outbound connections are allowed (default)
sudo firewall-cmd --list-all

# If you have strict outbound rules, allow HTTPS
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --reload

Perfect for hosting websites on home connections or behind NAT/CGNAT, without exposing your real IP address or opening inbound firewall ports.

Security Advantage: Cloudflared tunnels are outbound-only connections, meaning you don't need to open any inbound ports in your firewall. This significantly reduces attack surface while still providing public HTTPS access.

Tailscale

Tailscale creates a private encrypted network between your devices using WireGuard. It is not active unless you sign in and enable it.

Setup:

# Start Tailscale
sudo systemctl start tailscaled
sudo systemctl enable tailscaled

# Login and connect
sudo tailscale up

# Check status
tailscale status

# Allow Tailscale in firewall (UDP 41641)
sudo firewall-cmd --add-port=41641/udp --permanent
sudo firewall-cmd --reload

Use it to access your hosted websites and services privately, without making them public on the internet.

Firewall Note: Tailscale works even without opening ports (NAT traversal), but opening UDP 41641 improves direct peer-to-peer connectivity.

OpenSSH

OpenSSH provides industry-standard encrypted remote access and file transfer (SSH, SCP, SFTP). The SSH server is not enabled by default.

Enable SSH Server:

sudo systemctl start sshd
sudo systemctl enable sshd

# Configure (optional)
sudo nano /etc/ssh/sshd_config

# Restart after changes
sudo systemctl restart sshd

# Allow SSH through firewall (for local/Tailscale access)
sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --reload

Useful for managing your desktop-hosted websites locally, over Tailscale, or through secure tunnels.

Fail2ban

Fail2ban monitors authentication logs and temporarily blocks abusive IP addresses using firewall rules. It is not enabled by default.

Enable Fail2ban:

sudo systemctl start fail2ban
sudo systemctl enable fail2ban

# Check status
sudo fail2ban-client status

# View SSH jail status
sudo fail2ban-client status sshd

Firewall Integration:

# Fail2ban automatically integrates with firewalld
# No manual firewall rules needed

# Verify Fail2ban can control firewall
sudo firewall-cmd --get-active-zones
sudo fail2ban-client status

# Check banned IPs
sudo firewall-cmd --direct --get-all-rules

Recommended when exposing services such as SSH or web applications to the public, adding an extra layer of protection against brute-force attacks.

How it works: Fail2ban monitors logs for failed login attempts and automatically adds temporary firewall rules to block attacking IP addresses. It integrates directly with firewalld—no manual configuration needed.

firewalld

firewalld provides a dynamic firewall with zones and services to control inbound and outbound network traffic. It is active by default with restrictive rules.

Common Commands:

# Check status
sudo firewall-cmd --state

# List active rules
sudo firewall-cmd --list-all

# Open HTTP/HTTPS
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --reload

# Open custom port
sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reload

Use it to restrict access to your hosted websites, SSH, and other services, ensuring that only allowed connections reach your desktop.

Troubleshooting

Boot Issues

System won't boot after update

ShaniOS should automatically rollback. If not:

  1. At boot menu, select the previous entry (@blue or @green)
  2. System will boot to last known working state
  3. Report issue via GitHub or Telegram

LUKS password not working after TPM enrollment

TPM enrollment adds a new unlock method but preserves your password. If experiencing issues:

  1. Wait a few seconds at the unlock prompt
  2. Try entering password again
  3. If persistent, boot from live USB and remove TPM enrollment using chroot

Update Issues

shani-deploy fails with network error

Check network connectivity:

# Test connectivity
ping -c 3 shani.dev

# Check NetworkManager
systemctl status NetworkManager

# Retry update
sudo shani-deploy

Application Issues

Flatpak app won't start

Try these steps:

# Update Flatpak
flatpak update

# Repair installation
flatpak repair

# Check permissions
flatpak override --show org.app.Name

# Reset all overrides for the app
flatpak override --reset org.app.Name

# Run from terminal to see errors
flatpak run org.app.Name

# Check GPU / graphics issues (common for Electron & games)
flatpak run --env=LIBGL_DEBUG=verbose org.app.Name

Encryption & LUKS Issues

How to check if my system is encrypted

# Method 1: Check for active LUKS mapping
sudo cryptsetup status shani_root
# If encrypted, shows: "is active" with device info

# Method 2: Check for crypto_LUKS partitions
sudo blkid | grep crypto_LUKS
# Shows all LUKS encrypted partitions

# Method 3: Check mounted devices
mount | grep mapper
# If encrypted, shows: /dev/mapper/shani_root

# Method 4: List block devices with filesystem types
lsblk -f
# Look for TYPE="crypto_LUKS"

# If none of these show encryption, your system is NOT encrypted
# and you cannot use TPM enrollment

Remove TPM enrollment and return to password-only

# Get your LUKS device
LUKS_DEVICE=$(sudo cryptsetup status shani_root | grep device: | awk '{print $2}')

# Remove TPM enrollment
sudo systemd-cryptenroll --wipe-slot=tpm2 "$LUKS_DEVICE"

# Regenerate boot images
sudo gen-efi configure blue
sudo gen-efi configure green

# Done - system will now require password on boot

Frequently Asked Questions

Can I install traditional Arch packages with pacman?

No. The root filesystem is read-only and immutable by design. This is a core security and stability feature, not a limitation. Use Flatpak for GUI applications, and containers (Distrobox, Podman) for development tools and CLI utilities.

What happens if an update fails?

ShaniOS includes automatic boot failure detection. If the system fails to boot after an update, it automatically reverts to the previous working image on the next boot attempt. No manual intervention required.

Does ShaniOS support hibernation?

Yes. ShaniOS uses a dedicated @swap subvolume with Copy-on-Write disabled, providing reliable hibernation on Btrfs. This approach solves the traditional Btrfs hibernation challenges.

How do I make persistent changes to system configuration?

The /etc directory uses overlay filesystem, making it writable despite the read-only root. Simply edit files in /etc normally—changes are stored in /data/overlay/etc/upper and persist across updates and blue-green switches.

Why does ShaniOS need 32GB minimum storage?

ShaniOS maintains two complete system images (@blue and @green) for atomic updates. However, Btrfs Copy-on-Write shares unchanged data between them, resulting in only ~18% overhead. The benefit is zero-downtime updates and instant rollback capability.

Can I use ShaniOS on legacy BIOS systems?

No. ShaniOS requires UEFI firmware for features like Unified Kernel Images (UKIs), Secure Boot support, and the systemd-boot bootloader. Legacy BIOS is not supported.

Can I dual-boot ShaniOS with Windows or another Linux?

Not recommended. Other operating systems may modify the bootloader or ESP partition, potentially breaking ShaniOS boot entries. For running other systems, use virtual machines (QEMU/KVM) or containers instead.

How do I switch between @blue and @green manually?

At the systemd-boot menu during startup, select the alternative boot entry. Both @blue and @green entries are always available, allowing instant rollback or testing.

Contribute

ShaniOS is open-source and welcomes community contributions.

Code Contributions

Contribute to core development, tools, or installer

GitHub

Bug Reports

Help improve stability and reliability

Telegram

Documentation

Improve this wiki and make ShaniOS more accessible

Contribute

Resources