Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions install/login/limine-snapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ EOF

CMDLINE=$(grep "^[[:space:]]*cmdline:" "$limine_config" | head -1 | sed 's/^[[:space:]]*cmdline:[[:space:]]*//')

# Enable SSD TRIM passthrough for LUKS-encrypted drives
if [[ $CMDLINE == *"cryptdevice="* ]] && [[ $CMDLINE != *"allow-discards"* ]]; then
CMDLINE=$(printf '%s\n' "$CMDLINE" | sed 's/\(cryptdevice=[^ "]*\)/\1:allow-discards/')
fi

sudo cp $OMARCHY_PATH/default/limine/default.conf /etc/default/limine
sudo sed -i "s|@@CMDLINE@@|$CMDLINE|g" /etc/default/limine

Expand Down
28 changes: 28 additions & 0 deletions migrations/1776500000.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
echo "Enable SSD TRIM for LUKS-encrypted drives"

# Only apply if the system uses LUKS encryption
if ! grep -q "cryptdevice=" /etc/default/limine 2>/dev/null; then
exit 0
fi

# Skip if allow-discards is already configured
if grep -q "allow-discards" /etc/default/limine 2>/dev/null; then
exit 0
fi

# Add :allow-discards to the cryptdevice= parameter in the boot config
# Format: cryptdevice=device:dmname -> cryptdevice=device:dmname:allow-discards
sudo sed -i 's/\(cryptdevice=[^ "]*\)/\1:allow-discards/' /etc/default/limine

# Extract the dmname from cryptdevice=device:dmname and enable allow-discards
# on the running LUKS device so TRIM works immediately
DMNAME=$(grep -oP 'cryptdevice=[^: "]+:\K[^: "]+' /etc/default/limine | head -1)
if [[ -n $DMNAME ]] && [[ -b /dev/mapper/$DMNAME ]]; then
sudo cryptsetup --allow-discards --persistent refresh "$DMNAME"
fi

# Regenerate initramfs and boot entry
sudo limine-mkinitcpio
sudo limine-update

echo "SSD TRIM enabled for LUKS encryption"