Repository navigation
Remove resume kernel parameters when removing hibernation #13584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: quattro
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| # omarchy:requires-sudo=true | ||
|
|
||
| MKINITCPIO_CONF="/etc/mkinitcpio.conf.d/omarchy_resume.conf" | ||
| RESUME_DROP_IN="/etc/limine-entry-tool.d/resume.conf" | ||
|
|
||
| # Check if hibernation is configured | ||
| if [[ ! -f $MKINITCPIO_CONF ]] || ! grep -q "^HOOKS+=(resume)$" "$MKINITCPIO_CONF"; then | ||
|
|
@@ -48,6 +49,13 @@ fi | |
| echo "Removing resume hook" | ||
| sudo rm "$MKINITCPIO_CONF" | ||
|
|
||
| # Remove resume kernel parameters. hibernation-setup only writes these when the | ||
| # drop-in is absent, so a stale one would pin a later setup to this swapfile's offset. | ||
| if [[ -f $RESUME_DROP_IN ]]; then | ||
| echo "Removing resume kernel parameters" | ||
| sudo rm "$RESUME_DROP_IN" | ||
| fi | ||
|
Comment on lines
+54
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| echo "Regenerating initramfs..." | ||
| sudo limine-mkinitcpio | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,17 +128,17 @@ echo "HOOKS+=(resume)" | sudo tee "$MKINITCPIO_CONF" >/dev/null | |
|
|
||
| # Add resume= kernel parameters so the initramfs resume hook knows where to find the | ||
| # hibernation image. Without these, resume happens late (after GPU drivers load) and fails. | ||
| if [[ ! -f $RESUME_DROP_IN ]]; then | ||
| echo "Adding resume kernel parameters" | ||
| sudo swapon -p 0 "$SWAP_FILE" 2>/dev/null | ||
| RESUME_DEVICE=$(findmnt -no SOURCE -T "$SWAP_FILE" | sed 's/\[.*\]//') | ||
| RESUME_OFFSET=$(sudo btrfs inspect-internal map-swapfile -r "$SWAP_FILE") | ||
| if [[ -n $RESUME_OFFSET ]]; then | ||
| sudo mkdir -p /etc/limine-entry-tool.d | ||
| echo "KERNEL_CMDLINE[default]+=\" resume=$RESUME_DEVICE resume_offset=$RESUME_OFFSET\"" | sudo tee "$RESUME_DROP_IN" >/dev/null | ||
| else | ||
| echo "Warning: Could not determine resume offset for $SWAP_FILE" >&2 | ||
| fi | ||
| # Always rewrite them: a drop-in left by an earlier setup names that swapfile's offset. | ||
| echo "Adding resume kernel parameters" | ||
| sudo swapon -p 0 "$SWAP_FILE" 2>/dev/null | ||
| RESUME_DEVICE=$(findmnt -no SOURCE -T "$SWAP_FILE" | sed 's/\[.*\]//') | ||
| RESUME_OFFSET=$(sudo btrfs inspect-internal map-swapfile -r "$SWAP_FILE") | ||
| if [[ -n $RESUME_OFFSET ]]; then | ||
| sudo mkdir -p /etc/limine-entry-tool.d | ||
| echo "KERNEL_CMDLINE[default]+=\" resume=$RESUME_DEVICE resume_offset=$RESUME_OFFSET\"" | sudo tee "$RESUME_DROP_IN" >/dev/null | ||
| else | ||
| sudo rm -f "$RESUME_DROP_IN" | ||
| echo "Warning: Could not determine resume offset for $SWAP_FILE" >&2 | ||
| fi | ||
|
Comment on lines
+139
to
142
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # Use ACPI alarm for RTC wakeup on s2idle systems (needed for suspend-then-hibernate) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #!/bin/bash | ||
|
|
||
| source "$(dirname -- "${BASH_SOURCE[0]}")/base-test.sh" | ||
|
|
||
| # Every resume drop-in hibernation-setup writes must be removed again, or a | ||
| # later setup keeps the old swapfile's resume_offset and resume breaks. | ||
| for drop_in in /etc/mkinitcpio.conf.d/omarchy_resume.conf /etc/limine-entry-tool.d/resume.conf; do | ||
| grep -F "$drop_in" "$ROOT/bin/omarchy-hibernation-setup" >/dev/null || | ||
| fail "hibernation setup writes $drop_in" | ||
| grep -F "$drop_in" "$ROOT/bin/omarchy-hibernation-remove" >/dev/null || | ||
| fail "hibernation remove deletes $drop_in" | ||
| done | ||
| pass "hibernation remove deletes the resume drop-ins setup writes" | ||
|
|
||
| remove_line=$(grep -n 'sudo rm "$RESUME_DROP_IN"' "$ROOT/bin/omarchy-hibernation-remove" | cut -d: -f1) | ||
| rebuild_line=$(grep -n '^sudo limine-mkinitcpio' "$ROOT/bin/omarchy-hibernation-remove" | cut -d: -f1) | ||
| [[ -n $remove_line && -n $rebuild_line ]] || | ||
| fail "hibernation remove keeps recognizable drop-in removal and rebuild steps" | ||
| (( remove_line < rebuild_line )) || | ||
| fail "hibernation remove drops resume parameters before rebuilding the UKI" | ||
| pass "hibernation remove drops resume parameters before rebuilding the UKI" | ||
|
Comment on lines
+15
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # A machine that removed hibernation before remove cleaned up still has the old drop-in. | ||
| ! grep -F '[[ ! -f $RESUME_DROP_IN ]]' "$ROOT/bin/omarchy-hibernation-setup" >/dev/null || | ||
| fail "hibernation setup rewrites a resume drop-in left by an earlier setup" | ||
| grep -F 'sudo tee "$RESUME_DROP_IN"' "$ROOT/bin/omarchy-hibernation-setup" >/dev/null || | ||
| fail "hibernation setup writes the resume drop-in" | ||
| grep -F 'sudo rm -f "$RESUME_DROP_IN"' "$ROOT/bin/omarchy-hibernation-setup" >/dev/null || | ||
| fail "hibernation setup drops a stale resume drop-in when it cannot find the offset" | ||
| pass "hibernation setup rewrites a resume drop-in left by an earlier setup" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resume.confwhenever it reaches the resume-parameter step, rather than writing it only when absent. This comment gives future maintainers the wrong reason for deleting the file and makes the cleanup harder to understand.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!