This add-on enables swap partitions on block devices (like /dev/sdb) for Home Assistant OS systems. Unlike traditional swap file solutions, this addon works directly with swap partitions on storage devices.
- Block Device Support: Enable swap on any block device (e.g.,
/dev/sdb,/dev/nvme0n1) - Auto-Discovery: Automatically detect existing swap partitions
- Partition Creation: Optionally create swap partitions on unpartitioned devices
- Priority Control: Set swap priority for multiple swap devices
- Safety Checks: Prevents accidental data loss on devices with existing partitions
- Navigate to the Supervisor panel in your Home Assistant instance
- Click on the "Add-on store" tab
- Add this repository URL
- Install the "HAOS Swap Enabler" add-on
Configure the add-on through the Home Assistant interface with these options:
- device: The block device path (e.g.,
/dev/sdb) - auto_discover: Enable automatic detection of swap partitions
- create_partition: Allow creation of swap partitions on unpartitioned devices
- priority: Swap priority (1-32767, default: 10)
device: "/dev/sdb"
auto_discover: true
create_partition: false
priority: 10device: "/dev/sdb"
auto_discover: false
create_partition: true
priority: 10device: "/dev/sdb1"
auto_discover: false
create_partition: false
priority: 10- Discovery Phase: If auto-discovery is enabled, the addon scans for existing swap partitions
- Device Validation: Checks if the specified device exists and is accessible
- Partition Management: Creates swap partition if requested and safe to do so
- Swap Activation: Enables swap with the specified priority
- Status Reporting: Shows current swap configuration
- Existing Data Protection: Won't create partitions on devices that already have partitions
- Device Validation: Ensures specified devices exist before attempting operations
- Swap Detection: Automatically detects existing swap signatures
- Error Handling: Comprehensive error checking and reporting
- USB storage devices (
/dev/sdb,/dev/sdc, etc.) - NVMe drives (
/dev/nvme0n1,/dev/nvme1n1, etc.) - SATA drives (
/dev/sda,/dev/sdb, etc.) - eMMC devices (
/dev/mmcblk0,/dev/mmcblk1, etc.)
- Device not found: Ensure the device is properly connected and recognized by the system
- Permission denied: The addon runs with required privileges automatically
- Partition creation failed: Check if the device already has partitions
- Swap activation failed: Verify the device has a valid swap signature
Use the auto-discovery mode to see available devices and their current status. The addon will list all suitable block devices in the logs.
If you prefer to prepare partitions manually:
# Create partition table (WARNING: This will erase the device!)
parted /dev/sdb mklabel gpt
# Create swap partition using full device
parted /dev/sdb mkpart primary linux-swap 0% 100%
# Create swap filesystem
mkswap /dev/sdb1- Startup: Runs once at startup to enable configured swap
- Auto-boot: Enabled by default to ensure swap is available on system restart
- One-time Operation: Stops after completing swap setup
- Logging: Provides detailed logs for troubleshooting
- Priority: Higher priority swaps are used first (lower numbers = higher priority)
- Device Speed: Faster storage devices provide better swap performance
- Size: Swap size is determined by the partition size you create
- Requires privileged access to manage block devices
- Only operates on devices explicitly configured
- Includes safety checks to prevent accidental data loss
Inspired by the swap file solutions in the Home Assistant community, adapted to work with block devices and partitions for better performance and flexibility.